Skip to content

Commit

Permalink
Merge pull request #2 from go-coldbrew/feat/clientstreaminterceptor
Browse files Browse the repository at this point in the history
Adding Client Stream Interceptors
  • Loading branch information
ankurs authored Dec 30, 2021
2 parents 07a2724 + e392c3f commit 98c7e76
Show file tree
Hide file tree
Showing 5 changed files with 396 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ test:
go test ./...

doc:
go get github.com/princjef/gomarkdoc/cmd/gomarkdoc
go install github.com/princjef/gomarkdoc/cmd/gomarkdoc
gomarkdoc ./...
50 changes: 34 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Almost all of these interceptors are reusable and can be used in any other proje
- [func DebugLoggingInterceptor() grpc.UnaryServerInterceptor](<#func-debuglogginginterceptor>)
- [func DefaultClientInterceptor(defaultOpts ...interface{}) grpc.UnaryClientInterceptor](<#func-defaultclientinterceptor>)
- [func DefaultClientInterceptors(defaultOpts ...interface{}) []grpc.UnaryClientInterceptor](<#func-defaultclientinterceptors>)
- [func DefaultClientStreamInterceptor(defaultOpts ...interface{}) grpc.StreamClientInterceptor](<#func-defaultclientstreaminterceptor>)
- [func DefaultClientStreamInterceptors(defaultOpts ...interface{}) []grpc.StreamClientInterceptor](<#func-defaultclientstreaminterceptors>)
- [func DefaultInterceptors() []grpc.UnaryServerInterceptor](<#func-defaultinterceptors>)
- [func DefaultStreamInterceptors() []grpc.StreamServerInterceptor](<#func-defaultstreaminterceptors>)
- [func DoHTTPtoGRPC(ctx context.Context, svr interface{}, handler func(ctx context.Context, req interface{}) (interface{}, error), in interface{}) (interface{}, error)](<#func-dohttptogrpc>)
Expand All @@ -44,19 +46,19 @@ Almost all of these interceptors are reusable and can be used in any other proje
```go
var (
//FilterMethods is the list of methods that are filtered by default
FilterMethods = []string{"Healthcheck", "HealthCheck", "healthcheck"}
FilterMethods = []string{"healthcheck", "readycheck", "serverreflectioninfo"}
)
```

## func [DebugLoggingInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L139>)
## func [DebugLoggingInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L162>)

```go
func DebugLoggingInterceptor() grpc.UnaryServerInterceptor
```

DebugLoggingInterceptor is the interceptor that logs all request/response from a handler

## func [DefaultClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L134>)
## func [DefaultClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L152>)

```go
func DefaultClientInterceptor(defaultOpts ...interface{}) grpc.UnaryClientInterceptor
Expand All @@ -72,6 +74,22 @@ func DefaultClientInterceptors(defaultOpts ...interface{}) []grpc.UnaryClientInt

DefaultClientInterceptors are the set of default interceptors that should be applied to all client calls

## func [DefaultClientStreamInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L157>)

```go
func DefaultClientStreamInterceptor(defaultOpts ...interface{}) grpc.StreamClientInterceptor
```

DefaultClientStreamInterceptor are the set of default interceptors that should be applied to all stream client calls

## func [DefaultClientStreamInterceptors](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L123>)

```go
func DefaultClientStreamInterceptors(defaultOpts ...interface{}) []grpc.StreamClientInterceptor
```

DefaultClientStreamInterceptors are the set of default interceptors that should be applied to all stream client calls

## func [DefaultInterceptors](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L85>)

```go
Expand All @@ -80,7 +98,7 @@ func DefaultInterceptors() []grpc.UnaryServerInterceptor

DefaultInterceptors are the set of default interceptors that are applied to all coldbrew methods

## func [DefaultStreamInterceptors](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L123>)
## func [DefaultStreamInterceptors](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L141>)

```go
func DefaultStreamInterceptors() []grpc.StreamServerInterceptor
Expand Down Expand Up @@ -121,83 +139,83 @@ func FilterMethodsFunc(ctx context.Context, fullMethodName string) bool

FilterMethodsFunc is the default implementation of Filter function

## func [GRPCClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L238>)
## func [GRPCClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L261>)

```go
func GRPCClientInterceptor(options ...grpc_opentracing.Option) grpc.UnaryClientInterceptor
```

GRPCClientInterceptor is the interceptor that intercepts all cleint requests and adds tracing info to them

## func [HystrixClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L243>)
## func [HystrixClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L266>)

```go
func HystrixClientInterceptor(defaultOpts ...grpc.CallOption) grpc.UnaryClientInterceptor
```

HystrixClientInterceptor is the interceptor that intercepts all client requests and adds hystrix info to them

## func [NRHttpTracer](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L314>)
## func [NRHttpTracer](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L337>)

```go
func NRHttpTracer(pattern string, h http.HandlerFunc) (string, http.HandlerFunc)
```

NRHttpTracer adds newrelic tracing to this http function

## func [NewRelicClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L227>)
## func [NewRelicClientInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L250>)

```go
func NewRelicClientInterceptor() grpc.UnaryClientInterceptor
```

NewRelicClientInterceptor intercepts all client actions and reports them to newrelic

## func [NewRelicInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L174>)
## func [NewRelicInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L197>)

```go
func NewRelicInterceptor() grpc.UnaryServerInterceptor
```

NewRelicInterceptor intercepts all server actions and reports them to newrelic

## func [OptionsInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L165>)
## func [OptionsInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L188>)

```go
func OptionsInterceptor() grpc.UnaryServerInterceptor
```

## func [PanicRecoveryInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L205>)
## func [PanicRecoveryInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L228>)

```go
func PanicRecoveryInterceptor() grpc.UnaryServerInterceptor
```

## func [ResponseTimeLoggingInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L149>)
## func [ResponseTimeLoggingInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L172>)

```go
func ResponseTimeLoggingInterceptor(ff FilterFunc) grpc.UnaryServerInterceptor
```

ResponseTimeLoggingInterceptor logs response time for each request on server

## func [ResponseTimeLoggingStreamInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L282>)
## func [ResponseTimeLoggingStreamInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L305>)

```go
func ResponseTimeLoggingStreamInterceptor() grpc.StreamServerInterceptor
```

ResponseTimeLoggingStreamInterceptor logs response time for stream RPCs\.

## func [ServerErrorInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L186>)
## func [ServerErrorInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L209>)

```go
func ServerErrorInterceptor() grpc.UnaryServerInterceptor
```

ServerErrorInterceptor intercepts all server actions and reports them to error notifier

## func [ServerErrorStreamInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L294>)
## func [ServerErrorStreamInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L317>)

```go
func ServerErrorStreamInterceptor() grpc.StreamServerInterceptor
Expand All @@ -213,7 +231,7 @@ func SetFilterFunc(ctx context.Context, ff FilterFunc)

SetFilterFunc sets the default filter function to be used by interceptors

## func [TraceIdInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L336>)
## func [TraceIdInterceptor](<https://github.com/go-coldbrew/interceptors/blob/main/interceptors.go#L359>)

```go
func TraceIdInterceptor() grpc.UnaryServerInterceptor
Expand Down
49 changes: 41 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,49 @@ go 1.15

require (
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/go-coldbrew/errors v0.1.0
github.com/apache/thrift v0.13.0 // indirect
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a // indirect
github.com/aws/aws-lambda-go v1.13.3 // indirect
github.com/bufbuild/buf v0.37.0 // indirect
github.com/bugsnag/bugsnag-go v2.1.2+incompatible // indirect
github.com/bugsnag/panicwrap v1.3.4 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/go-coldbrew/errors v0.1.1
github.com/go-coldbrew/log v0.1.0
github.com/go-coldbrew/options v0.1.0
github.com/go-coldbrew/tracing v0.0.0-20210315144405-14fc34cc65e1
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-sql-driver/mysql v1.4.0 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.4.0
github.com/newrelic/go-agent/v3 v3.9.0
github.com/newrelic/go-agent/v3/integrations/nrgrpc v1.1.0
github.com/princjef/gomarkdoc v0.1.3 // indirect
github.com/prometheus/client_golang v1.9.0 // indirect
google.golang.org/grpc v1.37.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.2
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/lightstep/lightstep-tracer-go v0.18.1 // indirect
github.com/newrelic/go-agent/v3 v3.15.2
github.com/newrelic/go-agent/v3/integrations/nrgrpc v1.3.1
github.com/oklog/oklog v0.3.2 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/opentracing/basictracer-go v1.0.0 // indirect
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5 // indirect
github.com/pact-foundation/pact-go v1.0.4 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/performancecopilot/speed v3.0.0+incompatible // indirect
github.com/posener/goreadme v1.3.4 // indirect
github.com/princjef/gomarkdoc v0.3.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da // indirect
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 // indirect
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect
google.golang.org/grpc v1.43.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.0.0 // indirect
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 // indirect
)
Loading

0 comments on commit 98c7e76

Please sign in to comment.