package nnet import ( "git.noahlan.cn/northlan/nnet/component" "git.noahlan.cn/northlan/nnet/log" "git.noahlan.cn/northlan/nnet/pipeline" "time" ) type Option func(options *Options) type WSOption func(opts *WSOptions) func WithLogger(logger log.Logger) Option { return func(_ *Options) { log.SetLogger(logger) } } func WithPipeline(pipeline pipeline.Pipeline) Option { return func(options *Options) { options.Pipeline = pipeline } } func WithComponents(components *component.Components) Option { return func(options *Options) { options.Components = components } } func WithHeartbeatInterval(d time.Duration) Option { return func(options *Options) { options.HeartbeatInterval = d } } func WithWebsocket(wsOpts ...WSOption) Option { return func(options *Options) { for _, opt := range wsOpts { opt(&options.WS) } options.WS.IsWebsocket = true } } func WithWSPath(path string) WSOption { return func(opts *WSOptions) { opts.WebsocketPath = path } } func WithWSTLS(certificate, key string) WSOption { return func(opts *WSOptions) { opts.TLSCertificate = certificate opts.TLSKey = key } }