Skip to content

Commit

Permalink
Clean up yarpc package
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Mar 7, 2017
1 parent 318bddd commit 99bb14f
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 230 deletions.
5 changes: 1 addition & 4 deletions modules/yarpc/handler.go → modules/yarpc/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
const _panicResponse = "Server Error"

type contextInboundMiddleware struct {
service.Host
statsClient *statsClient
}

Expand All @@ -54,9 +53,7 @@ func (f contextInboundMiddleware) Handle(
return handler.Handle(ctx, req, resw)
}

type contextOnewayInboundMiddleware struct {
service.Host
}
type contextOnewayInboundMiddleware struct{}

func (f contextOnewayInboundMiddleware) HandleOneway(
ctx context.Context,
Expand Down
38 changes: 18 additions & 20 deletions modules/yarpc/handler_test.go → modules/yarpc/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,9 @@ import (
ztest "go.uber.org/zap/testutils"
)

type fakeEnveloper struct {
serviceName string
}

func (f fakeEnveloper) MethodName() string {
return f.serviceName
}

func (f fakeEnveloper) EnvelopeType() wire.EnvelopeType {
return wire.Reply
}

func (f fakeEnveloper) ToWire() (wire.Value, error) {
return wire.NewValueStruct(wire.Struct{}), nil
}

func TestInboundMiddleware_Context(t *testing.T) {
host := service.NopHost()
unary := contextInboundMiddleware{host, newStatsClient(host.Metrics())}
unary := contextInboundMiddleware{newStatsClient(host.Metrics())}
testutils.WithInMemoryLogger(t, nil, func(loggerWithZap *zap.Logger, buf *ztest.Buffer) {
defer ulog.SetLogger(loggerWithZap)()
tracing.WithSpan(t, loggerWithZap, func(span opentracing.Span) {
Expand All @@ -71,9 +55,7 @@ func TestInboundMiddleware_Context(t *testing.T) {
}

func TestOnewayInboundMiddleware_Context(t *testing.T) {
oneway := contextOnewayInboundMiddleware{
Host: service.NopHost(),
}
oneway := contextOnewayInboundMiddleware{}
testutils.WithInMemoryLogger(t, nil, func(loggerWithZap *zap.Logger, buf *ztest.Buffer) {
defer ulog.SetLogger(loggerWithZap)()
tracing.WithSpan(t, loggerWithZap, func(span opentracing.Span) {
Expand Down Expand Up @@ -153,6 +135,22 @@ func testPanicHandler(t *testing.T, testScope tally.Scope) {
assert.True(t, counters["panic"].Value() > 0)
}

type fakeEnveloper struct {
serviceName string
}

func (f fakeEnveloper) MethodName() string {
return f.serviceName
}

func (f fakeEnveloper) EnvelopeType() wire.EnvelopeType {
return wire.Reply
}

func (f fakeEnveloper) ToWire() (wire.Value, error) {
return wire.NewValueStruct(wire.Struct{}), nil
}

type fakeUnary struct {
t *testing.T
}
Expand Down

0 comments on commit 99bb14f

Please sign in to comment.