Skip to content

Commit

Permalink
move pilosa.Config to pilosa/server.Config
Browse files Browse the repository at this point in the history
step 1 of FeatureBaseDB#1203

The Config object is really just a specification of the options to pilosa
server, so it makes sense to have it in that package.
  • Loading branch information
jaffee committed Apr 19, 2018
1 parent 5a740eb commit 876ed56
Show file tree
Hide file tree
Showing 21 changed files with 308 additions and 307 deletions.
5 changes: 4 additions & 1 deletion broadcast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ func testMessageMarshal(t *testing.T, m proto.Message) {
// Ensure that BroadcastReceiver can register a BroadcastHandler.
func TestBroadcast_BroadcastReceiver(t *testing.T) {

s := pilosa.NewServer()
s, err := pilosa.NewServer()
if err != nil {
t.Fatalf("getting new server: %v", err)
}

sbr := NewSimpleBroadcastReceiver()
sbh := NewSimpleBroadcastHandler()
Expand Down
5 changes: 1 addition & 4 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ const (
// DefaultPartitionN is the default number of partitions in a cluster.
DefaultPartitionN = 256

// DefaultReplicaN is the default number of replicas per partition.
DefaultReplicaN = 1

// ClusterState represents the state returned in the /status endpoint.
ClusterStateStarting = "STARTING"
ClusterStateNormal = "NORMAL"
Expand Down Expand Up @@ -276,7 +273,7 @@ func NewCluster() *Cluster {
return &Cluster{
Hasher: &jmphasher{},
PartitionN: DefaultPartitionN,
ReplicaN: DefaultReplicaN,
ReplicaN: 1,
EventReceiver: NopEventReceiver,

joiningLeavingNodes: make(chan nodeAction, 10), // buffered channel
Expand Down
8 changes: 4 additions & 4 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"testing"
"time"

"github.com/pilosa/pilosa"
"github.com/pilosa/pilosa/cmd"
_ "github.com/pilosa/pilosa/test"
"github.com/pilosa/pilosa/toml"
)

func TestServerHelp(t *testing.T) {
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestServerConfig(t *testing.T) {
v.Check(cmd.Server.Config.Bind, "localhost:10111")
v.Check(cmd.Server.Config.Cluster.ReplicaN, 2)
v.Check(cmd.Server.Config.Cluster.Hosts, []string{"localhost:10111", "localhost:10110"})
v.Check(cmd.Server.Config.Cluster.LongQueryTime, pilosa.Duration(time.Second*90))
v.Check(cmd.Server.Config.Cluster.LongQueryTime, toml.Duration(time.Second*90))
v.Check(cmd.Server.Config.MaxWritesPerRequest, 2000)
return v.Error()
},
Expand All @@ -86,7 +86,7 @@ func TestServerConfig(t *testing.T) {
validation: func() error {
v := validator{}
v.Check(cmd.Server.Config.Cluster.Hosts, []string{"localhost:1110", "localhost:1111"})
v.Check(cmd.Server.Config.AntiEntropy.Interval, pilosa.Duration(time.Minute*9))
v.Check(cmd.Server.Config.AntiEntropy.Interval, toml.Duration(time.Minute*9))
return v.Error()
},
},
Expand All @@ -113,7 +113,7 @@ func TestServerConfig(t *testing.T) {
validation: func() error {
v := validator{}
v.Check(cmd.Server.Config.Cluster.Hosts, []string{"localhost:19444"})
v.Check(cmd.Server.Config.AntiEntropy.Interval, pilosa.Duration(time.Minute*11))
v.Check(cmd.Server.Config.AntiEntropy.Interval, toml.Duration(time.Minute*11))
v.Check(cmd.Server.CPUProfile, profFile.Name())
v.Check(cmd.Server.CPUTime, time.Minute)
v.Check(cmd.Server.Config.LogPath, logFile.Name())
Expand Down
226 changes: 0 additions & 226 deletions config.go

This file was deleted.

5 changes: 3 additions & 2 deletions ctl/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"

"github.com/pilosa/pilosa"
"github.com/pilosa/pilosa/server"
)

// BackupCommand represents a command for backing up a view.
Expand All @@ -39,7 +40,7 @@ type BackupCommand struct {
// Standard input/output
*pilosa.CmdIO

TLS pilosa.TLSConfig
TLS server.TLSConfig
}

// NewBackupCommand returns a new instance of BackupCommand.
Expand Down Expand Up @@ -88,6 +89,6 @@ func (cmd *BackupCommand) TLSHost() string {
return cmd.Host
}

func (cmd *BackupCommand) TLSConfiguration() pilosa.TLSConfig {
func (cmd *BackupCommand) TLSConfiguration() server.TLSConfig {
return cmd.TLS
}
5 changes: 3 additions & 2 deletions ctl/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/pilosa/pilosa"
"github.com/pilosa/pilosa/internal"
"github.com/pilosa/pilosa/server"
)

// BenchCommand represents a command for benchmarking index operations.
Expand All @@ -42,7 +43,7 @@ type BenchCommand struct {
// Standard input/output
*pilosa.CmdIO

TLS pilosa.TLSConfig
TLS server.TLSConfig
}

// NewBenchCommand returns a new instance of BenchCommand.
Expand Down Expand Up @@ -110,6 +111,6 @@ func (cmd *BenchCommand) TLSHost() string {
return cmd.Host
}

func (cmd *BenchCommand) TLSConfiguration() pilosa.TLSConfig {
func (cmd *BenchCommand) TLSConfiguration() server.TLSConfig {
return cmd.TLS
}
3 changes: 2 additions & 1 deletion ctl/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import (
"crypto/tls"

"github.com/pilosa/pilosa"
"github.com/pilosa/pilosa/server"
"github.com/spf13/pflag"
)

// CommandWithTLSSupport is the interface for commands which has TLS settings
type CommandWithTLSSupport interface {
TLSHost() string
TLSConfiguration() pilosa.TLSConfig
TLSConfiguration() server.TLSConfig
}

// SetTLSConfig creates common TLS flags
Expand Down
3 changes: 2 additions & 1 deletion ctl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (

toml "github.com/pelletier/go-toml"
"github.com/pilosa/pilosa"
"github.com/pilosa/pilosa/server"
)

// ConfigCommand represents a command for printing a default config.
type ConfigCommand struct {
*pilosa.CmdIO
Config *pilosa.Config
Config *server.Config
}

// NewConfigCommand returns a new instance of ConfigCommand.
Expand Down
4 changes: 2 additions & 2 deletions ctl/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"strings"
"testing"

"github.com/pilosa/pilosa"
"github.com/pilosa/pilosa/server"
)

func TestConfigCommand_Run(t *testing.T) {
rder := []byte{}
stdin := bytes.NewReader(rder)
r, w, _ := os.Pipe()
cm := NewConfigCommand(stdin, w, os.Stderr)
cm.Config = pilosa.NewConfig()
cm.Config = server.NewConfig()

err := cm.Run(context.Background())
w.Close()
Expand Down
Loading

0 comments on commit 876ed56

Please sign in to comment.