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 {
@ -27,6 +28,7 @@ type ReadWriteHandlers struct {
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,6 +49,9 @@ 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{
@ -56,6 +61,7 @@ func (rwh *ReadWriteHandlers) Clone() *ReadWriteHandlers {
PingPeriod: rwh.PingPeriod, PingPeriod: rwh.PingPeriod,
EnableCompression: rwh.EnableCompression, EnableCompression: rwh.EnableCompression,
CompressionLevel: rwh.CompressionLevel, CompressionLevel: rwh.CompressionLevel,
CompressionThreshold: rwh.CompressionThreshold,
validated: rwh.validated, validated: rwh.validated,
} }
} }
@ -93,5 +99,9 @@ func (rwh *ReadWriteHandlers) Validate() error {
} }
} }
if 0 > rwh.CompressionThreshold {
rwh.CompressionThreshold = server.DefaultCompressionThreshold
}
return nil return nil
} }