mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
22 lines
695 B
Go
22 lines
695 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 {
|
|
klog.Warning(err)
|
|
}
|
|
klog.Infof("%v handler finished", info.FullMethod)
|
|
return
|
|
}
|