@@ -20,7 +20,7 @@ import NIOCore
20
20
/// Background work can also be executed after returning the response. After closing the response stream by calling
21
21
/// ``LambdaResponseStreamWriter/finish()`` or ``LambdaResponseStreamWriter/writeAndFinish(_:)``,
22
22
/// the ``handle(_:responseWriter:context:)`` function is free to execute any background work.
23
- package protocol StreamingLambdaHandler {
23
+ public protocol StreamingLambdaHandler {
24
24
/// The handler function -- implement the business logic of the Lambda function here.
25
25
/// - Parameters:
26
26
/// - event: The invocation's input data.
@@ -45,7 +45,7 @@ package protocol StreamingLambdaHandler {
45
45
46
46
/// A writer object to write the Lambda response stream into. The HTTP response is started lazily.
47
47
/// before the first call to ``write(_:)`` or ``writeAndFinish(_:)``.
48
- package protocol LambdaResponseStreamWriter {
48
+ public protocol LambdaResponseStreamWriter {
49
49
/// Write a response part into the stream. Bytes written are streamed continually.
50
50
/// - Parameter buffer: The buffer to write.
51
51
func write( _ buffer: ByteBuffer ) async throws
@@ -64,7 +64,7 @@ package protocol LambdaResponseStreamWriter {
64
64
///
65
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
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.
67
- package protocol LambdaHandler {
67
+ public protocol LambdaHandler {
68
68
/// Generic input type.
69
69
/// The body of the request sent to Lambda will be decoded into this type for the handler to consume.
70
70
associatedtype Event : Decodable
@@ -85,7 +85,7 @@ package protocol LambdaHandler {
85
85
/// This is achieved by not having a return type in the `handle` function. The output is instead written into a
86
86
/// ``LambdaResponseWriter``that is passed in as an argument, meaning that the ``handle(_:)`` function is then free to implement
87
87
/// any background work after the result has been sent to the AWS Lambda control plane.
88
- package protocol LambdaWithBackgroundProcessingHandler {
88
+ public protocol LambdaWithBackgroundProcessingHandler {
89
89
/// Generic input type.
90
90
/// The body of the request sent to Lambda will be decoded into this type for the handler to consume.
91
91
associatedtype Event : Decodable
@@ -109,7 +109,7 @@ package protocol LambdaWithBackgroundProcessingHandler {
109
109
/// Used with ``LambdaWithBackgroundProcessingHandler``.
110
110
/// A mechanism to "return" an output from ``LambdaWithBackgroundProcessingHandler/handle(_:outputWriter:context:)`` without the function needing to
111
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.
112
- package protocol LambdaResponseWriter < Output> {
112
+ public protocol LambdaResponseWriter < Output> {
113
113
associatedtype Output
114
114
/// Sends the generic ``Output`` object (representing the computed result of the handler)
115
115
/// to the AWS Lambda response endpoint.
@@ -120,12 +120,12 @@ package protocol LambdaResponseWriter<Output> {
120
120
121
121
/// A ``StreamingLambdaHandler`` conforming handler object that can be constructed with a closure.
122
122
/// Allows for a handler to be defined in a clean manner, leveraging Swift's trailing closure syntax.
123
- package struct StreamingClosureHandler : StreamingLambdaHandler {
123
+ public struct StreamingClosureHandler : StreamingLambdaHandler {
124
124
let body : @Sendable ( ByteBuffer, LambdaResponseStreamWriter, LambdaContext) async throws -> Void
125
125
126
126
/// Initialize an instance from a handler function in the form of a closure.
127
127
/// - Parameter body: The handler function written as a closure.
128
- package init (
128
+ public init (
129
129
body: @Sendable @escaping ( ByteBuffer, LambdaResponseStreamWriter, LambdaContext) async throws -> Void
130
130
) {
131
131
self . body = body
@@ -137,7 +137,7 @@ package struct StreamingClosureHandler: StreamingLambdaHandler {
137
137
/// - responseWriter: A ``LambdaResponseStreamWriter`` to write the invocation's response to.
138
138
/// If no response or error is written to `responseWriter` an error will be reported to the invoker.
139
139
/// - context: The ``LambdaContext`` containing the invocation's metadata.
140
- package func handle(
140
+ public func handle(
141
141
_ request: ByteBuffer ,
142
142
responseWriter: some LambdaResponseStreamWriter ,
143
143
context: LambdaContext
@@ -148,34 +148,34 @@ package struct StreamingClosureHandler: StreamingLambdaHandler {
148
148
149
149
/// A ``LambdaHandler`` conforming handler object that can be constructed with a closure.
150
150
/// Allows for a handler to be defined in a clean manner, leveraging Swift's trailing closure syntax.
151
- package struct ClosureHandler < Event: Decodable , Output> : LambdaHandler {
151
+ public struct ClosureHandler < Event: Decodable , Output> : LambdaHandler {
152
152
let body : ( Event , LambdaContext ) async throws -> Output
153
153
154
154
/// Initialize with a closure handler over generic `Input` and `Output` types.
155
155
/// - Parameter body: The handler function written as a closure.
156
- package init ( body: @escaping ( Event , LambdaContext ) async throws -> Output ) where Output: Encodable {
156
+ public init ( body: @escaping ( Event , LambdaContext ) async throws -> Output ) where Output: Encodable {
157
157
self . body = body
158
158
}
159
159
160
160
/// Initialize with a closure handler over a generic `Input` type, and a `Void` `Output`.
161
161
/// - Parameter body: The handler function written as a closure.
162
- package init ( body: @escaping ( Event , LambdaContext ) async throws -> Void ) where Output == Void {
162
+ public init ( body: @escaping ( Event , LambdaContext ) async throws -> Void ) where Output == Void {
163
163
self . body = body
164
164
}
165
165
166
166
/// Calls the provided `self.body` closure with the generic ``Event`` object representing the incoming event, and the ``LambdaContext``
167
167
/// - Parameters:
168
168
/// - event: The generic ``Event`` object representing the invocation's input data.
169
169
/// - context: The ``LambdaContext`` containing the invocation's metadata.
170
- package func handle( _ event: Event , context: LambdaContext ) async throws -> Output {
170
+ public func handle( _ event: Event , context: LambdaContext ) async throws -> Output {
171
171
try await self . body ( event, context)
172
172
}
173
173
}
174
174
175
175
extension LambdaRuntime {
176
176
/// Initialize an instance with a ``StreamingLambdaHandler`` in the form of a closure.
177
177
/// - Parameter body: The handler in the form of a closure.
178
- package convenience init (
178
+ public convenience init (
179
179
body: @Sendable @escaping ( ByteBuffer, LambdaResponseStreamWriter, LambdaContext) async throws -> Void
180
180
) where Handler == StreamingClosureHandler {
181
181
self . init ( handler: StreamingClosureHandler ( body: body) )
@@ -185,7 +185,7 @@ extension LambdaRuntime {
185
185
/// - Parameter body: The handler in the form of a closure.
186
186
/// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``.
187
187
/// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type.
188
- package convenience init <
188
+ public convenience init <
189
189
Event: Decodable ,
190
190
Output: Encodable ,
191
191
Encoder: LambdaOutputEncoder ,
@@ -217,7 +217,7 @@ extension LambdaRuntime {
217
217
/// - Parameter body: The handler in the form of a closure.
218
218
/// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``.
219
219
/// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type.
220
- package convenience init < Event: Decodable , Decoder: LambdaEventDecoder > (
220
+ public convenience init < Event: Decodable , Decoder: LambdaEventDecoder > (
221
221
decoder: Decoder ,
222
222
body: @escaping ( Event , LambdaContext ) async throws -> Void
223
223
)
0 commit comments