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

Function processEvents

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

Source from the content-addressed store, hash-verified

44}
45
46func processEvents(ctx context.Context) {
47 for {
48 select {
49 case <-ctx.Done():
50 return
51 default:
52 println(printPrefix, "Waiting for event...")
53 res, err := extensionClient.NextEvent(ctx)
54 if err != nil {
55 println(printPrefix, "Error:", err)
56 println(printPrefix, "Exiting")
57 return
58 }
59 println(printPrefix, "Received event:", prettyPrint(res))
60 // Exit if we receive a SHUTDOWN event
61 if res.EventType == extension.Shutdown {
62 println(printPrefix, "Received SHUTDOWN event")
63 println(printPrefix, "Exiting")
64 return
65 }
66 }
67 }
68}
69
70func prettyPrint(v interface{}) string {
71 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