mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
* Enable gofmt and move related work to linter job 1. Introduce gofmt github action 2. Move goimports from build job to lint job 3. Run gofmt -s -w to simplify test codes and fix all lint issues in apiserver and cli projects * Fix lint errors in apiserver * Fix lint errors in cli * Fix goimports error
23 lines
720 B
Go
23 lines
720 B
Go
package interceptor
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc"
|
|
"k8s.io/klog/v2"
|
|
)
|
|
|
|
// ApiServerInterceptor implements UnaryServerInterceptor that provides the common wrapping logic
|
|
// to be executed before and after all API handler calls, e.g. Logging, error handling.
|
|
// For more details, see https://github.com/grpc/grpc-go/blob/master/interceptor.go
|
|
func ApiServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
|
klog.Infof("%v handler starting", info.FullMethod)
|
|
resp, err = handler(ctx, req)
|
|
if err != nil {
|
|
// TODO: handle errors
|
|
klog.Warning(err)
|
|
}
|
|
klog.Infof("%v handler finished", info.FullMethod)
|
|
return
|
|
}
|