From 3d279ffcfdf42799f0af49e4db026b4e3a777925 Mon Sep 17 00:00:00 2001 From: Asim Date: Tue, 8 Dec 2015 00:11:51 +0000 Subject: [PATCH] Select is a better method --- client/node_selector.go | 4 ++-- client/node_selector_test.go | 2 +- client/rpc_client.go | 4 ++-- examples/client/node_selector/node_selector.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/node_selector.go b/client/node_selector.go index ea2590ad..737fa467 100644 --- a/client/node_selector.go +++ b/client/node_selector.go @@ -16,7 +16,7 @@ import ( // response from a client call. Reset is called to zero out // any state. type NodeSelector interface { - Retrieve(context.Context, Request) (*registry.Node, error) + Select(context.Context, Request) (*registry.Node, error) Response(*registry.Node, error) Reset() } @@ -30,7 +30,7 @@ type nodeSelector struct { r registry.Registry } -func (n *nodeSelector) Retrieve(ctx context.Context, req Request) (*registry.Node, error) { +func (n *nodeSelector) Select(ctx context.Context, req Request) (*registry.Node, error) { service, err := n.r.GetService(req.Service()) if err != nil { return nil, errors.InternalServerError("go.micro.client", err.Error()) diff --git a/client/node_selector_test.go b/client/node_selector_test.go index 64dae191..6f5db95a 100644 --- a/client/node_selector_test.go +++ b/client/node_selector_test.go @@ -59,7 +59,7 @@ func TestNodeSelector(t *testing.T) { } for i := 0; i < 100; i++ { - n, err := n.Retrieve(context.Background(), newRpcRequest("foo", "Foo.Bar", nil, "")) + n, err := n.Select(context.Background(), newRpcRequest("foo", "Foo.Bar", nil, "")) if err != nil { t.Errorf("Expected node, got err: %v", err) } diff --git a/client/rpc_client.go b/client/rpc_client.go index 2e2d8724..0f07a7de 100644 --- a/client/rpc_client.go +++ b/client/rpc_client.go @@ -154,7 +154,7 @@ func (r *rpcClient) CallRemote(ctx context.Context, address string, request Requ // TODO: Call(..., opts *Options) error { func (r *rpcClient) Call(ctx context.Context, request Request, response interface{}) error { - node, err := r.sel.Retrieve(ctx, request) + node, err := r.sel.Select(ctx, request) if err != nil { return err } @@ -174,7 +174,7 @@ func (r *rpcClient) StreamRemote(ctx context.Context, address string, request Re } func (r *rpcClient) Stream(ctx context.Context, request Request, responseChan interface{}) (Streamer, error) { - node, err := r.sel.Retrieve(ctx, request) + node, err := r.sel.Select(ctx, request) if err != nil { return nil, err } diff --git a/examples/client/node_selector/node_selector.go b/examples/client/node_selector/node_selector.go index 06e12a01..9181dc8c 100644 --- a/examples/client/node_selector/node_selector.go +++ b/examples/client/node_selector/node_selector.go @@ -22,7 +22,7 @@ type nodeSelector struct { r registry.Registry } -func (n *nodeSelector) Retrieve(ctx context.Context, req client.Request) (*registry.Node, error) { +func (n *nodeSelector) Select(ctx context.Context, req client.Request) (*registry.Node, error) { service, err := n.r.GetService(req.Service()) if err != nil { return nil, errors.InternalServerError("go.micro.client", err.Error())