mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 10:57:51 +00:00
Store commandOptions on test.Main for use in Reopen(); unexport serverOptions
This commit is contained in:
parent
ff7c3cb512
commit
e448d47004
2 changed files with 7 additions and 5 deletions
|
|
@ -77,14 +77,14 @@ type Command struct {
|
|||
Handler pilosa.Handler
|
||||
ln net.Listener
|
||||
|
||||
ServerOptions []pilosa.ServerOption
|
||||
serverOptions []pilosa.ServerOption
|
||||
}
|
||||
|
||||
type CommandOption func(c *Command) error
|
||||
|
||||
func OptCommandServerOptions(opts ...pilosa.ServerOption) CommandOption {
|
||||
return func(c *Command) error {
|
||||
c.ServerOptions = append(c.ServerOptions, opts...)
|
||||
c.serverOptions = append(c.serverOptions, opts...)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ func (m *Command) SetupServer() error {
|
|||
pilosa.OptServerClusterDisabled(m.Config.Cluster.Disabled, m.Config.Cluster.Hosts),
|
||||
}
|
||||
|
||||
serverOptions = append(serverOptions, m.ServerOptions...)
|
||||
serverOptions = append(serverOptions, m.serverOptions...)
|
||||
|
||||
m.Server, err = pilosa.NewServer(serverOptions...)
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ import (
|
|||
type Main struct {
|
||||
*server.Command
|
||||
|
||||
commandOptions []server.CommandOption
|
||||
|
||||
Stdin bytes.Buffer
|
||||
Stdout bytes.Buffer
|
||||
Stderr bytes.Buffer
|
||||
|
|
@ -64,7 +66,7 @@ func NewMain(opts ...server.CommandOption) *Main {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
m := &Main{Command: server.NewCommand(os.Stdin, os.Stdout, os.Stderr, opts...)}
|
||||
m := &Main{Command: server.NewCommand(os.Stdin, os.Stdout, os.Stderr, opts...), commandOptions: opts}
|
||||
m.Config.DataDir = path
|
||||
m.Config.Bind = "http://localhost:0"
|
||||
m.Config.Cluster.Disabled = true
|
||||
|
|
@ -156,7 +158,7 @@ func (m *Main) Reopen() error {
|
|||
|
||||
// Create new main with the same config.
|
||||
config := m.Command.Config
|
||||
m.Command = server.NewCommand(os.Stdin, os.Stdout, os.Stderr, server.OptCommandServerOptions(m.ServerOptions...))
|
||||
m.Command = server.NewCommand(os.Stdin, os.Stdout, os.Stderr, m.commandOptions...)
|
||||
m.Command.Config = config
|
||||
err := m.SetupServer()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue