From 5378004c6c4d9e70c9e4be0364755b4eab026b3e Mon Sep 17 00:00:00 2001 From: NoahLan <6995syu@163.com> Date: Tue, 19 Dec 2023 23:31:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20katagoengine=20=E6=B7=BB=E5=8A=A0linebu?= =?UTF-8?q?ffersize=E7=9A=84option=EF=BC=8C=E4=BB=A5=E4=BE=BF=E4=BA=8E?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E3=80=82=E5=90=8C=E6=97=B6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4buffer=E5=88=B0=E5=8E=9F=E6=9C=AC4=E5=80=8D?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ngochess/katago/engine_analysis.go | 12 ++++++++---- ngochess/katago/options.go | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ngochess/katago/engine_analysis.go b/ngochess/katago/engine_analysis.go index 8a891a6..02d460d 100644 --- a/ngochess/katago/engine_analysis.go +++ b/ngochess/katago/engine_analysis.go @@ -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, })) diff --git a/ngochess/katago/options.go b/ngochess/katago/options.go index dddff63..4cb3fa0 100644 --- a/ngochess/katago/options.go +++ b/ngochess/katago/options.go @@ -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 + } +}