feat: katagoengine 添加linebuffersize的option,以便于配置。同时增加默认buffer到原本4倍。

main v1.3.10
NoahLan 1 year ago
parent fba9789145
commit 5378004c6c

@ -19,9 +19,10 @@ var ErrTimeout = errors.New("timeout")
type (
Options struct {
DevMode bool `json:",default=false"` // 开发模式
MaxMessageId uint64 `json:",default=9999999"` // 最大消息ID
Timeout time.Duration `json:""` // 单条命令最大等待时间默认10min
DevMode bool `json:",default=false"` // 开发模式
MaxMessageId uint64 `json:",default=9999999"` // 最大消息ID
Timeout time.Duration `json:""` // 单条命令最大等待时间默认10min
LineBufferSize int `json:""` // LineBufferSize
}
Option func(options *Options)
@ -63,6 +64,9 @@ func NewKatagoAnalysisEngine(opts ...Option) *AnalysisEngine {
if ret.Timeout == 0 {
ret.Timeout = DefaultTimeout
}
if ret.LineBufferSize == 0 {
ret.LineBufferSize = ncmd.DEFAULT_LINE_BUFFER_SIZE * 4
}
ret.serializer = serializer
ret.Cmd = ncmd.NewCmd(ncmd.WithOptions(&ncmd.Options{
@ -70,7 +74,7 @@ func NewKatagoAnalysisEngine(opts ...Option) *AnalysisEngine {
Buffered: false,
CombinedOutput: false,
Streaming: true,
LineBufferSize: ncmd.DEFAULT_LINE_BUFFER_SIZE,
LineBufferSize: ncmd.DEFAULT_LINE_BUFFER_SIZE * 4,
DevMode: ret.DevMode,
}))

@ -7,6 +7,7 @@ func WithOptions(opt Options) Option {
options.DevMode = opt.DevMode
options.MaxMessageId = opt.MaxMessageId
options.Timeout = opt.Timeout
options.LineBufferSize = opt.LineBufferSize
}
}
@ -27,3 +28,9 @@ func WithTimeout(timeout time.Duration) Option {
options.Timeout = timeout
}
}
func WithLineBufferSize(size int) Option {
return func(options *Options) {
options.LineBufferSize = size
}
}

Loading…
Cancel
Save