Skip to content
Permalink
Browse files

`middleare` -> `middleware` (#217)

* `middleare` -> `middleware`

* Fix test
  • Loading branch information...
seanhagen authored and domgreen committed Sep 11, 2019
1 parent f07c72d commit 6e1e746222237c7c04fd6e0c7ca13ca44d94b5ed
Showing with 4 additions and 4 deletions.
  1. +2 −2 ratelimit/ratelimit.go
  2. +2 −2 ratelimit/ratelimit_test.go
@@ -18,7 +18,7 @@ type Limiter interface {
func UnaryServerInterceptor(limiter Limiter) grpc.UnaryServerInterceptor {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
if limiter.Limit() {
return nil, status.Errorf(codes.ResourceExhausted, "%s is rejected by grpc_ratelimit middleare, please retry later.", info.FullMethod)
return nil, status.Errorf(codes.ResourceExhausted, "%s is rejected by grpc_ratelimit middleware, please retry later.", info.FullMethod)
}
return handler(ctx, req)
}
@@ -28,7 +28,7 @@ func UnaryServerInterceptor(limiter Limiter) grpc.UnaryServerInterceptor {
func StreamServerInterceptor(limiter Limiter) grpc.StreamServerInterceptor {
return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
if limiter.Limit() {
return status.Errorf(codes.ResourceExhausted, "%s is rejected by grpc_ratelimit middleare, please retry later.", info.FullMethod)
return status.Errorf(codes.ResourceExhausted, "%s is rejected by grpc_ratelimit middleware, please retry later.", info.FullMethod)
}
return handler(srv, stream)
}
@@ -47,7 +47,7 @@ func TestUnaryServerInterceptor_RateLimitFail(t *testing.T) {
}
req, err := interceptor(nil, nil, info, handler)
assert.Nil(t, req)
assert.EqualError(t, err, "rpc error: code = ResourceExhausted desc = FakeMethod is rejected by grpc_ratelimit middleare, please retry later.")
assert.EqualError(t, err, "rpc error: code = ResourceExhausted desc = FakeMethod is rejected by grpc_ratelimit middleware, please retry later.")
}

func TestStreamServerInterceptor_RateLimitPass(t *testing.T) {
@@ -71,5 +71,5 @@ func TestStreamServerInterceptor_RateLimitFail(t *testing.T) {
FullMethod: "FakeMethod",
}
err := interceptor(nil, nil, info, handler)
assert.EqualError(t, err, "rpc error: code = ResourceExhausted desc = FakeMethod is rejected by grpc_ratelimit middleare, please retry later.")
assert.EqualError(t, err, "rpc error: code = ResourceExhausted desc = FakeMethod is rejected by grpc_ratelimit middleware, please retry later.")
}

0 comments on commit 6e1e746

Please sign in to comment.
You can’t perform that action at this time.