diff --git a/client.go b/client.go index 56cba08e1..b5dbe809a 100644 --- a/client.go +++ b/client.go @@ -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 diff --git a/executor.go b/executor.go index 25fc98ac9..17fef6165 100644 --- a/executor.go +++ b/executor.go @@ -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(), } diff --git a/holder_test.go b/holder_test.go index 4375d970f..b56863bb0 100644 --- a/holder_test.go +++ b/holder_test.go @@ -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 diff --git a/http/client_test.go b/http/client_test.go index 3853d2335..1cc972ff6 100644 --- a/http/client_test.go +++ b/http/client_test.go @@ -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 diff --git a/server.go b/server.go index a324ebd49..d73c9ce82 100644 --- a/server.go +++ b/server.go @@ -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 diff --git a/test/executor.go b/test/executor.go index ae0a412d5..c04f91eca 100644 --- a/test/executor.go +++ b/test/executor.go @@ -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