Skip to content

Commit

Permalink
Move GetHandlerSpec aside (as ChooseProcedure)
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Nov 15, 2016
1 parent 197ebf7 commit 0956c7e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
6 changes: 3 additions & 3 deletions transport/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ func (m MapRegistry) ServiceProcedures() []ServiceProcedure {
return procs
}

// GetHandlerSpec retrieves the HandlerSpec for the given Procedure or returns an
// ChooseProcedure retrieves the HandlerSpec for the given Procedure or returns an
// error.
func (m MapRegistry) GetHandlerSpec(service, procedure string) (HandlerSpec, error) {
func (m MapRegistry) ChooseProcedure(service, procedure string) (HandlerSpec, error) {
if service == "" {
service = m.defaultService
}
Expand All @@ -135,7 +135,7 @@ func (m MapRegistry) GetHandlerSpec(service, procedure string) (HandlerSpec, err
// Choose retrives the HandlerSpec for the service and procedure noted on the
// transport request, or returns an error.
func (m MapRegistry) Choose(ctx context.Context, req *Request) (HandlerSpec, error) {
return m.GetHandlerSpec(req.Service, req.Procedure)
return m.ChooseProcedure(req.Service, req.Procedure)
}

type byServiceProcedure []ServiceProcedure
Expand Down
6 changes: 3 additions & 3 deletions transport/register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ func TestMapRegistry(t *testing.T) {
}

for _, tt := range tests {
got, err := m.GetHandlerSpec(tt.service, tt.procedure)
got, err := m.ChooseProcedure(tt.service, tt.procedure)
if tt.want != nil {
assert.NoError(t, err,
"GetHandlerSpec(%q, %q) failed", tt.service, tt.procedure)
"ChooseProcedure(%q, %q) failed", tt.service, tt.procedure)
assert.True(t, tt.want == got.Unary(), // want == match, not deep equals
"GetHandlerSpec(%q, %q) did not match", tt.service, tt.procedure)
"ChooseProcedure(%q, %q) did not match", tt.service, tt.procedure)
} else {
assert.Error(t, err)
}
Expand Down
8 changes: 0 additions & 8 deletions transport/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ func (r staticRegistry) ServiceProcedures() []transport.ServiceProcedure {
return []transport.ServiceProcedure{{Service: testService, Procedure: testProcedure}}
}

func (r staticRegistry) GetHandlerSpec(service string, procedure string) (transport.HandlerSpec, error) {
if procedure == testProcedure {
return transport.NewUnaryHandlerSpec(r.Handler), nil
} else {
return transport.NewOnewayHandlerSpec(r.OnewayHandler), nil
}
}

func (r staticRegistry) Choose(ctx context.Context, req *transport.Request) (transport.HandlerSpec, error) {
if req.Procedure == testProcedure {
return transport.NewUnaryHandlerSpec(r.Handler), nil
Expand Down
11 changes: 0 additions & 11 deletions transport/transporttest/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ func (_mr *_MockRegistryRecorder) Choose(arg0, arg1 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "Choose", arg0, arg1)
}

func (_m *MockRegistry) GetHandlerSpec(_param0 string, _param1 string) (transport.HandlerSpec, error) {
ret := _m.ctrl.Call(_m, "GetHandlerSpec", _param0, _param1)
ret0, _ := ret[0].(transport.HandlerSpec)
ret1, _ := ret[1].(error)
return ret0, ret1
}

func (_mr *_MockRegistryRecorder) GetHandlerSpec(arg0, arg1 interface{}) *gomock.Call {
return _mr.mock.ctrl.RecordCall(_mr.mock, "GetHandlerSpec", arg0, arg1)
}

func (_m *MockRegistry) ServiceProcedures() []transport.ServiceProcedure {
ret := _m.ctrl.Call(_m, "ServiceProcedures")
ret0, _ := ret[0].([]transport.ServiceProcedure)
Expand Down

0 comments on commit 0956c7e

Please sign in to comment.