MCPcopy Index your code
hub / github.com/PasarGuard/node / LoggingStreamInterceptor

Function LoggingStreamInterceptor

controller/rpc/middleware.go:159–185  ·  view source on GitHub ↗
(s *Service)

Source from the content-addressed store, hash-verified

157}
158
159func LoggingStreamInterceptor(s *Service) grpc.StreamServerInterceptor {
160 return func(
161 srv interface{},
162 ss grpc.ServerStream,
163 info *grpc.StreamServerInfo,
164 handler grpc.StreamHandler,
165 ) error {
166 clientIP := "unknown"
167 if p, ok := peer.FromContext(ss.Context()); ok {
168 clientIP = p.Addr.String()
169 }
170 log.Printf("Trying To Open Stream Connection, IP: %s, Method: %s,", clientIP, strings.TrimPrefix(info.FullMethod, "/service.NodeService/"))
171
172 // Handle the request
173 err := handler(srv, ss)
174
175 // Log the request
176 logRequest(ss.Context(), info.FullMethod, err)
177
178 // Track successful requests
179 if err == nil {
180 s.NewRequest()
181 }
182
183 return err
184 }
185}
186
187var backendMethods = map[string]bool{
188 "/service.NodeService/GetStats": true,

Callers 1

Calls 3

logRequestFunction · 0.85
NewRequestMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected