MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / Process

Method Process

fs/runtime/grpc/grpc_func.go:250–288  ·  view source on GitHub ↗
(req *proto.FunctionProcessRequest, stream proto.Function_ProcessServer)

Source from the content-addressed store, hash-verified

248}
249
250func (f *FunctionServerImpl) Process(req *proto.FunctionProcessRequest, stream proto.Function_ProcessServer) error {
251 runtime, err := f.reconcileSvr.getFunc(req.Name)
252 if err != nil {
253 return err
254 }
255 log := runtime.log
256 log.Info("Start processing events using GRPC")
257 runtime.readyOnce.Do(func() {
258 runtime.readyCh <- err
259 })
260 errCh := make(chan error)
261
262 defer func() {
263 if runtime.processing.Load() {
264 runtime.output <- nil
265 runtime.processing.Store(false)
266 }
267 }()
268
269 logCounter := common.LogCounter()
270 for {
271 select {
272 case event := <-runtime.input:
273 log.Debug("sending event", "count", logCounter)
274 runtime.processing.Store(true)
275 err := stream.Send(&proto.Event{Payload: string(event.GetPayload())}) // TODO: Change payload type to bytes
276 if err != nil {
277 log.Error(err, "failed to send event")
278 return err
279 }
280 case <-stream.Context().Done():
281 return nil
282 case <-runtime.ctx.Done():
283 return nil
284 case e := <-errCh:
285 return e
286 }
287 }
288}
289
290func (f *FunctionServerImpl) getFunctionRuntime(ctx context.Context) (*FuncRuntime, error) {
291 md, ok := metadata.FromIncomingContext(ctx)

Callers

nothing calls this directly

Calls 8

LogCounterFunction · 0.92
getFuncMethod · 0.80
DebugMethod · 0.80
ErrorMethod · 0.80
LoadMethod · 0.65
SendMethod · 0.65
GetPayloadMethod · 0.65
ContextMethod · 0.65

Tested by

no test coverage detected