MCPcopy Create free account
hub / github.com/OpenFunction/samples / ForwardToKafka

Function ForwardToKafka

functions/knative/with-output-binding/sender.go:10–27  ·  view source on GitHub ↗
(ctx ofctx.Context, in []byte)

Source from the content-addressed store, hash-verified

8)
9
10func ForwardToKafka(ctx ofctx.Context, in []byte) (ofctx.Out, error) {
11 var greeting []byte
12 if in != nil {
13 log.Printf("http - Data: %s", in)
14 greeting = in
15 } else {
16 log.Print("http - Data: Received")
17 greeting, _ = json.Marshal(map[string]string{"message": "Hello"})
18 }
19
20 _, err := ctx.Send("kafka-server", greeting)
21 if err != nil {
22 log.Print(err.Error())
23 return ctx.ReturnOnInternalError(), err
24 }
25
26 return ctx.ReturnOnSuccess(), nil
27}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected