(config *Config)
| 209 | } |
| 210 | |
| 211 | func WithConfig(config *Config) ServerOption { |
| 212 | return serverOptionFunc(func(o *serverOptions) (*serverOptions, error) { |
| 213 | ln, err := net.Listen("tcp", config.ListenAddr) |
| 214 | if err != nil { |
| 215 | return nil, err |
| 216 | } |
| 217 | o.httpListener = ln |
| 218 | o.enableTls = config.EnableTLS |
| 219 | if o.enableTls { |
| 220 | if config.TLSCertFile == "" || config.TLSKeyFile == "" { |
| 221 | return nil, fmt.Errorf("TLS certificate and key file must be provided") |
| 222 | } |
| 223 | o.tlsCertFile = config.TLSCertFile |
| 224 | o.tlsKeyFile = config.TLSKeyFile |
| 225 | } |
| 226 | o.tubeConfig = config.TubeConfig |
| 227 | o.queueConfig = config.Queue |
| 228 | o.runtimeConfig = config.RuntimeConfig |
| 229 | if config.StateStore != nil { |
| 230 | stateStore, err := o.stateStoreLoader(config.StateStore) |
| 231 | if err != nil { |
| 232 | return nil, err |
| 233 | } |
| 234 | o.managerOpts = append(o.managerOpts, fs.WithStateStore(stateStore)) |
| 235 | } |
| 236 | o.functionStore = config.FunctionStore |
| 237 | return o, nil |
| 238 | }) |
| 239 | } |
| 240 | |
| 241 | func NewServer(opts ...ServerOption) (*Server, error) { |
| 242 | options := &serverOptions{} |
no test coverage detected