mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
NewExecutor doesn't return an error; renamed NewClient to NewInternalHTTPClient
This commit is contained in:
parent
838d56011c
commit
66650ec1f7
11 changed files with 19 additions and 34 deletions
|
|
@ -50,8 +50,8 @@ type InternalHTTPClient struct {
|
|||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// NewClient returns a new instance of InternalHTTPClient to connect to host.
|
||||
func NewClient(host string, options *ClientOptions) (*InternalHTTPClient, error) {
|
||||
// NewInternalHTTPClient returns a new instance of InternalHTTPClient to connect to host.
|
||||
func NewInternalHTTPClient(host string, options *ClientOptions) (*InternalHTTPClient, error) {
|
||||
if host == "" {
|
||||
return nil, ErrHostRequired
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,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) {
|
||||
e, err := pilosa.NewExecutor(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
e := pilosa.NewExecutor(nil)
|
||||
e.Holder = hldr[0].Holder
|
||||
e.Scheme = cluster.Nodes[0].Scheme
|
||||
e.Host = cluster.Nodes[0].Host
|
||||
|
|
@ -65,10 +62,7 @@ func TestClient_MultiNode(t *testing.T) {
|
|||
return e.Execute(ctx, index, query, slices, opt)
|
||||
}
|
||||
s[1].Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
e, err := pilosa.NewExecutor(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
e := pilosa.NewExecutor(nil)
|
||||
e.Holder = hldr[1].Holder
|
||||
e.Scheme = cluster.Nodes[1].Scheme
|
||||
e.Host = cluster.Nodes[1].Host
|
||||
|
|
@ -76,10 +70,7 @@ func TestClient_MultiNode(t *testing.T) {
|
|||
return e.Execute(ctx, index, query, slices, opt)
|
||||
}
|
||||
s[2].Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
e, err := pilosa.NewExecutor(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
e := pilosa.NewExecutor(nil)
|
||||
e.Holder = hldr[2].Holder
|
||||
e.Scheme = cluster.Nodes[2].Scheme
|
||||
e.Host = cluster.Nodes[2].Host
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func CommandClient(cmd CommandWithTLSSupport) (*pilosa.InternalHTTPClient, error
|
|||
}
|
||||
clientOptions = &pilosa.ClientOptions{TLS: TLSConfig}
|
||||
}
|
||||
client, err := pilosa.NewClient(cmd.TLSHost(), clientOptions)
|
||||
client, err := pilosa.NewInternalHTTPClient(cmd.TLSHost(), clientOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ type Executor struct {
|
|||
}
|
||||
|
||||
// NewExecutor returns a new instance of Executor.
|
||||
func NewExecutor(clientOptions *ClientOptions) (*Executor, error) {
|
||||
func NewExecutor(clientOptions *ClientOptions) *Executor {
|
||||
if clientOptions == nil {
|
||||
clientOptions = &ClientOptions{}
|
||||
}
|
||||
return &Executor{
|
||||
client: NewClientFromURI(nil, clientOptions),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Execute executes a PQL query.
|
||||
|
|
|
|||
|
|
@ -1714,7 +1714,7 @@ func (s *FragmentSyncer) SyncFragment() error {
|
|||
}
|
||||
|
||||
// Retrieve remote blocks.
|
||||
client, err := NewClient(node.Host, s.ClientOptions)
|
||||
client, err := NewInternalHTTPClient(node.Host, s.ClientOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1793,7 +1793,7 @@ func (s *FragmentSyncer) syncBlock(id int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
client, err := NewClient(node.Host, s.ClientOptions)
|
||||
client, err := NewInternalHTTPClient(node.Host, s.ClientOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -515,7 +515,7 @@ func (s *HolderSyncer) syncIndex(index string) error {
|
|||
|
||||
// Sync with every other host.
|
||||
for _, node := range Nodes(s.Cluster.Nodes).FilterHost(s.URI.HostPort()) {
|
||||
client, err := NewClient(node.Host, s.ClientOptions)
|
||||
client, err := NewInternalHTTPClient(node.Host, s.ClientOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -560,7 +560,7 @@ func (s *HolderSyncer) syncFrame(index, name string) error {
|
|||
|
||||
// Sync with every other host.
|
||||
for _, node := range Nodes(s.Cluster.Nodes).FilterHost(s.URI.HostPort()) {
|
||||
client, err := NewClient(node.Host, s.ClientOptions)
|
||||
client, err := NewInternalHTTPClient(node.Host, s.ClientOptions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -314,10 +314,7 @@ func TestHolderSyncer_SyncHolder(t *testing.T) {
|
|||
defer s.Close()
|
||||
s.Handler.Holder = hldr1.Holder
|
||||
s.Handler.Executor.ExecuteFn = func(ctx context.Context, index string, query *pql.Query, slices []uint64, opt *pilosa.ExecOptions) ([]interface{}, error) {
|
||||
e, err := pilosa.NewExecutor(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
e := pilosa.NewExecutor(nil)
|
||||
e.Holder = hldr1.Holder
|
||||
e.Scheme = cluster.Nodes[1].Scheme
|
||||
e.Host = cluster.Nodes[1].Host
|
||||
|
|
|
|||
|
|
@ -164,10 +164,7 @@ func (s *Server) Open() error {
|
|||
s.createDefaultClient()
|
||||
|
||||
// Create executor for executing queries.
|
||||
e, err := NewExecutor(&ClientOptions{TLS: s.TLS})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e := NewExecutor(&ClientOptions{TLS: s.TLS})
|
||||
e.Holder = s.Holder
|
||||
e.Scheme = s.URI.Scheme()
|
||||
e.Host = s.URI.HostPort()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func TestMain_Set_Quick(t *testing.T) {
|
|||
defer m.Close()
|
||||
|
||||
// Create client.
|
||||
client, err := pilosa.NewClient(m.Server.URI.HostPort(), nil)
|
||||
client, err := pilosa.NewInternalHTTPClient(m.Server.URI.HostPort(), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ func TestMain_FrameRestore(t *testing.T) {
|
|||
defer m2.Close()
|
||||
|
||||
// Import from first cluster.
|
||||
client, err := pilosa.NewClient(m2.Server.URI.HostPort(), nil)
|
||||
client, err := pilosa.NewInternalHTTPClient(m2.Server.URI.HostPort(), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if err := m2.Client().CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil && err != pilosa.ErrIndexExists {
|
||||
|
|
@ -697,7 +697,7 @@ func (m *Main) URL() string { return "http://" + m.Server.Addr().String() }
|
|||
|
||||
// Client returns a client to connect to the program.
|
||||
func (m *Main) Client() *pilosa.InternalHTTPClient {
|
||||
client, err := pilosa.NewClient(m.Server.URI.HostPort(), nil)
|
||||
client, err := pilosa.NewInternalHTTPClient(m.Server.URI.HostPort(), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ type Client struct {
|
|||
|
||||
// MustNewClient returns a new instance of Client. Panic on error.
|
||||
func MustNewClient(host string) *Client {
|
||||
c, err := pilosa.NewClient(host, nil)
|
||||
c, err := pilosa.NewInternalHTTPClient(host, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ type Executor struct {
|
|||
// NewExecutor returns a new instance of Executor.
|
||||
// The executor always matches the hostname of the first cluster node.
|
||||
func NewExecutor(holder *pilosa.Holder, cluster *pilosa.Cluster) *Executor {
|
||||
executor, _ := pilosa.NewExecutor(nil)
|
||||
executor := pilosa.NewExecutor(nil)
|
||||
e := &Executor{Executor: executor}
|
||||
e.Holder = holder
|
||||
e.Cluster = cluster
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue