This commit is contained in:
crusader 2018-07-01 01:52:05 +09:00
parent d1d485c711
commit 20a63b3de6

View File

@ -16,6 +16,7 @@ type ReadWriteHandler interface {
IsEnableCompression() bool IsEnableCompression() bool
GetCompressionLevel() int GetCompressionLevel() int
GetCompressionThreshold() int
} }
type ReadWriteHandlers struct { type ReadWriteHandlers struct {
@ -25,8 +26,9 @@ type ReadWriteHandlers struct {
PingTimeout time.Duration `json:"pingTimeout,omitempty"` PingTimeout time.Duration `json:"pingTimeout,omitempty"`
PingPeriod time.Duration `json:"pingPeriod,omitempty"` PingPeriod time.Duration `json:"pingPeriod,omitempty"`
EnableCompression bool `json:"enableCompression,omitempty"` EnableCompression bool `json:"enableCompression,omitempty"`
CompressionLevel int `json:"compressionLevel,omitempty"` CompressionLevel int `json:"compressionLevel,omitempty"`
CompressionThreshold int `json:"compressionThreshold,omitempty"`
validated atomic.Value validated atomic.Value
} }
@ -47,16 +49,20 @@ func (rwh *ReadWriteHandlers) IsEnableCompression() bool {
func (rwh *ReadWriteHandlers) GetCompressionLevel() int { func (rwh *ReadWriteHandlers) GetCompressionLevel() int {
return rwh.CompressionLevel return rwh.CompressionLevel
} }
func (rwh *ReadWriteHandlers) GetCompressionThreshold() int {
return rwh.CompressionThreshold
}
func (rwh *ReadWriteHandlers) Clone() *ReadWriteHandlers { func (rwh *ReadWriteHandlers) Clone() *ReadWriteHandlers {
return &ReadWriteHandlers{ return &ReadWriteHandlers{
ReadWriteHandlers: *rwh.ReadWriteHandlers.Clone(), ReadWriteHandlers: *rwh.ReadWriteHandlers.Clone(),
PongTimeout: rwh.PongTimeout, PongTimeout: rwh.PongTimeout,
PingTimeout: rwh.PingTimeout, PingTimeout: rwh.PingTimeout,
PingPeriod: rwh.PingPeriod, PingPeriod: rwh.PingPeriod,
EnableCompression: rwh.EnableCompression, EnableCompression: rwh.EnableCompression,
CompressionLevel: rwh.CompressionLevel, CompressionLevel: rwh.CompressionLevel,
validated: rwh.validated, CompressionThreshold: rwh.CompressionThreshold,
validated: rwh.validated,
} }
} }
@ -93,5 +99,9 @@ func (rwh *ReadWriteHandlers) Validate() error {
} }
} }
if 0 > rwh.CompressionThreshold {
rwh.CompressionThreshold = server.DefaultCompressionThreshold
}
return nil return nil
} }