Improve naming

This commit is contained in:
Cody Soyland 2018-06-13 09:18:50 -05:00
parent daffa3b125
commit ecbbd31b4e
6 changed files with 11 additions and 10 deletions

View file

@ -18,7 +18,7 @@ type Bit struct {
Timestamp int64
}
// FieldValues represents the value for a column within a
// FieldValue represents the value for a column within a
// range-encoded field.
type FieldValue struct {
ColumnID uint64

View file

@ -52,9 +52,10 @@ type Executor struct {
MaxWritesPerRequest int
}
type ExecutorOpt func(e *Executor) error
// ExecutorOption is a functional option type for pilosa.Executor
type ExecutorOption func(e *Executor) error
func ExecutorOptInternalQueryClient(c InternalQueryClient) ExecutorOpt {
func OptExecutorInternalQueryClient(c InternalQueryClient) ExecutorOption {
return func(e *Executor) error {
e.client = c
return nil
@ -62,7 +63,7 @@ func ExecutorOptInternalQueryClient(c InternalQueryClient) ExecutorOpt {
}
// NewExecutor returns a new instance of Executor.
func NewExecutor(opts ...ExecutorOpt) *Executor {
func NewExecutor(opts ...ExecutorOption) *Executor {
e := &Executor{
client: NewNopInternalQueryClient(),
}

View file

@ -373,7 +373,7 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
defer hldr1.Close()
s.Handler.API.Holder = hldr1.Holder
s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
e := pilosa.NewExecutor(pilosa.ExecutorOptInternalQueryClient(httpClient))
e := pilosa.NewExecutor(pilosa.OptExecutorInternalQueryClient(httpClient))
e.Holder = hldr1.Holder
e.Node = cluster.Nodes[1]
e.Cluster = cluster

View file

@ -62,7 +62,7 @@ func TestClient_MultiNode(t *testing.T) {
s[0].Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
httpClient := http.NewInternalClientFromURI(&cluster.Nodes[0].URI, defaultClient)
e := pilosa.NewExecutor(pilosa.ExecutorOptInternalQueryClient(httpClient))
e := pilosa.NewExecutor(pilosa.OptExecutorInternalQueryClient(httpClient))
e.Holder = hldr[0].Holder
e.Node = cluster.Nodes[0]
e.Cluster = cluster
@ -70,7 +70,7 @@ func TestClient_MultiNode(t *testing.T) {
}
s[1].Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
httpClient := http.NewInternalClientFromURI(&cluster.Nodes[0].URI, defaultClient)
e := pilosa.NewExecutor(pilosa.ExecutorOptInternalQueryClient(httpClient))
e := pilosa.NewExecutor(pilosa.OptExecutorInternalQueryClient(httpClient))
e.Holder = hldr[1].Holder
e.Node = cluster.Nodes[1]
e.Cluster = cluster
@ -78,7 +78,7 @@ func TestClient_MultiNode(t *testing.T) {
}
s[2].Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
httpClient := http.NewInternalClientFromURI(&cluster.Nodes[0].URI, defaultClient)
e := pilosa.NewExecutor(pilosa.ExecutorOptInternalQueryClient(httpClient))
e := pilosa.NewExecutor(pilosa.OptExecutorInternalQueryClient(httpClient))
e.Holder = hldr[2].Holder
e.Node = cluster.Nodes[2]
e.Cluster = cluster

View file

@ -173,7 +173,7 @@ func OptServerRemoteClient(c *http.Client) ServerOption {
func OptServerInternalClient(c InternalClient) ServerOption {
return func(s *Server) error {
s.executor = NewExecutor(ExecutorOptInternalQueryClient(c))
s.executor = NewExecutor(OptExecutorInternalQueryClient(c))
s.defaultClient = c
s.Cluster.InternalClient = c
return nil

View file

@ -38,7 +38,7 @@ func init() {
// The executor always matches the uri of the first cluster node.
func NewExecutor(holder *pilosa.Holder, cluster *pilosa.Cluster) *Executor {
client := http.NewInternalClientFromURI(nil, remoteClient)
executor := pilosa.NewExecutor(pilosa.ExecutorOptInternalQueryClient(client))
executor := pilosa.NewExecutor(pilosa.OptExecutorInternalQueryClient(client))
e := &Executor{Executor: executor}
e.Holder = holder
e.Cluster = cluster