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
GetCompressionLevel() int
GetCompressionThreshold() int
}
type ReadWriteHandlers struct {
@ -27,6 +28,7 @@ type ReadWriteHandlers struct {
EnableCompression bool `json:"enableCompression,omitempty"`
CompressionLevel int `json:"compressionLevel,omitempty"`
CompressionThreshold int `json:"compressionThreshold,omitempty"`
validated atomic.Value
}
@ -47,6 +49,9 @@ func (rwh *ReadWriteHandlers) IsEnableCompression() bool {
func (rwh *ReadWriteHandlers) GetCompressionLevel() int {
return rwh.CompressionLevel
}
func (rwh *ReadWriteHandlers) GetCompressionThreshold() int {
return rwh.CompressionThreshold
}
func (rwh *ReadWriteHandlers) Clone() *ReadWriteHandlers {
return &ReadWriteHandlers{
@ -56,6 +61,7 @@ func (rwh *ReadWriteHandlers) Clone() *ReadWriteHandlers {
PingPeriod: rwh.PingPeriod,
EnableCompression: rwh.EnableCompression,
CompressionLevel: rwh.CompressionLevel,
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
}