You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Initializes an instance given an encoder, decoder, and a handler with a non-`Void` output.
89
+
/// - Parameters:
90
+
/// - encoder: The encoder object that will be used to encode the generic ``Output`` obtained from the `handler`'s `outputWriter` into a ``ByteBuffer``.
91
+
/// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`.
/// Initializes an instance given a decoder, and a handler with a `Void` output.
100
+
/// - Parameters:
101
+
/// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`.
/// Initializes an instance given an encoder and an underlying ``LambdaResponseStreamWriter``.
133
+
/// - Parameters:
134
+
/// - encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``, which will then be passed to `streamWriter`.
135
+
/// - streamWriter: The underlying ``LambdaResponseStreamWriter`` that will be wrapped.
/// This handler protocol is intended to serve the most common use-cases.
62
+
/// This protocol is completely agnostic to any encoding/decoding -- decoding the received event invocation into an ``Event`` object and encoding the returned ``Output`` object is handled by the library.
63
+
/// The``handle(_:context:)`` function simply receives the generic ``Event`` object as input and returns the generic ``Output`` object.
64
+
///
65
+
/// - note: This handler protocol does not support response streaming because the output has to be encoded prior to it being sent, e.g. it is not possible to encode a partial/incomplete JSON string.
66
+
/// This protocol also does not support the execution of background work after the response has been returned -- the ``LambdaWithBackgroundProcessingHandler`` protocol caters for such use-cases.
32
67
packageprotocolNewLambdaHandler{
68
+
/// Generic input type.
69
+
/// The body of the request sent to Lambda will be decoded into this type for the handler to consume.
33
70
associatedtypeEvent:Decodable
71
+
/// Generic output type.
72
+
/// This is the return type of the ``handle(_:context:)`` function.
34
73
associatedtypeOutput
35
74
75
+
/// Implement the business logic of the Lambda function here.
76
+
/// - Parameters:
77
+
/// - event: The generic ``Event`` object representing the invocation's input data.
78
+
/// - context: The ``NewLambdaContext`` containing the invocation's metadata.
79
+
/// - Returns: A generic ``Output`` object representing the computed result.
/// The body of the request sent to Lambda will be decoded into this type for the handler to consume.
40
91
associatedtypeEvent:Decodable
92
+
/// Generic output type.
93
+
/// This is the type that the `handle` function will send through the ``LambdaResponseWriter``.
41
94
associatedtypeOutput
42
95
43
-
/// The business logic of the Lambda function. Receives a generic input type and returns a generic output type.
44
-
/// Agnostic to JSON encoding/decoding
96
+
/// Implement the business logic of the Lambda function here.
97
+
/// - Parameters:
98
+
/// - event: The generic ``Event`` object representing the invocation's input data.
99
+
/// - outputWriter: The writer to send the computed response to. A call to `outputWriter.write(_:)` will return the response to the AWS Lambda response endpoint.
100
+
/// Any background work can then be executed before returning.
101
+
/// - context: The ``NewLambdaContext`` containing the invocation's metadata.
45
102
func handle(
46
103
_ event:Event,
47
104
outputWriter:someLambdaResponseWriter<Output>,
48
105
context:NewLambdaContext
49
106
)asyncthrows
50
107
}
51
108
109
+
/// Used with ``LambdaWithBackgroundProcessingHandler``.
110
+
/// A mechanism to "return" an output from ``LambdaWithBackgroundProcessingHandler/handle(_:outputWriter:context:)`` without the function needing to
111
+
/// have a return type and exit at that point. This allows for background work to be executed _after_ a response has been sent to the AWS Lambda response endpoint.
0 commit comments