MCPcopy Create free account
hub / github.com/aws-samples/aws-lambda-extensions / processEvents

Function processEvents

go-example-ipc-extension/main.go:54–77  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

52}
53
54func processEvents(ctx context.Context) {
55 for {
56 select {
57 case <-ctx.Done():
58 return
59 default:
60 println(printPrefix, "Waiting for event...")
61 res, err := extensionClient.NextEvent(ctx)
62 if err != nil {
63 println(printPrefix, "Error:", err)
64 println(printPrefix, "Exiting")
65 return
66 }
67
68 println(printPrefix, "Received event:", prettyPrint(res))
69 // Exit if we receive a SHUTDOWN event
70 if res.EventType == extension.Shutdown {
71 println(printPrefix, "Received SHUTDOWN event")
72 println(printPrefix, "Exiting")
73 return
74 }
75 }
76 }
77}
78
79func prettyPrint(v interface{}) string {
80 data, err := json.MarshalIndent(v, "", "\t")

Callers 1

mainFunction · 0.70

Calls 2

prettyPrintFunction · 0.70
NextEventMethod · 0.45

Tested by

no test coverage detected