add metrics, tracing, validation interceptors, add options: WithInterceptors, With{Client,Server}Interceptors

This commit is contained in:
2021-11-21 14:58:49 +01:00
parent 9ae20eab1e
commit dc78a2c688
15 changed files with 401 additions and 41 deletions

View File

@ -107,10 +107,10 @@ func newService(opts ...Option) (*service, error) {
}
return s.run()
}
ui := grpcmiddleware.ChainUnaryServer(s.opts.serverInterceptors...)
ui := grpcmiddleware.ChainUnaryServer(s.opts.unaryServerInterceptors...)
s.inproc = s.inproc.WithServerUnaryInterceptor(ui)
si := grpcmiddleware.ChainStreamServer(/*TODO(adphi): add to options*/)
si := grpcmiddleware.ChainStreamServer( /*TODO(adphi): add to options*/ )
s.inproc = s.inproc.WithServerStreamInterceptor(si)
gopts := []grpc.ServerOption{
@ -181,8 +181,8 @@ func (s *service) run() error {
if reflect.DeepEqual(s.opts.cors, cors.Options{}) {
s.opts.cors = cors.Options{
AllowedHeaders: []string{"*"},
AllowedMethods: []string{
AllowedHeaders: []string{"*"},
AllowedMethods: []string{
http.MethodGet,
http.MethodPost,
http.MethodPut,
@ -235,7 +235,7 @@ func (s *service) run() error {
logrus.Warnf("received %v", sig)
return s.Close()
case err := <-errs:
if err != nil && !ignoreMuxError(err){
if err != nil && !ignoreMuxError(err) {
logrus.Error(err)
return err
}