-
Notifications
You must be signed in to change notification settings - Fork 113
Make v2 API functions and types public #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ import NIOCore | |
|
||
/// The protocol a decoder must conform to so that it can be used with ``LambdaCodableAdapter`` to decode incoming | ||
/// ``ByteBuffer`` events. | ||
package protocol LambdaEventDecoder { | ||
public protocol LambdaEventDecoder { | ||
/// Decode the ``ByteBuffer`` representing the received event into the generic ``Event`` type | ||
/// the handler will receive. | ||
/// - Parameters: | ||
|
@@ -28,7 +28,7 @@ package protocol LambdaEventDecoder { | |
|
||
/// The protocol an encoder must conform to so that it can be used with ``LambdaCodableAdapter`` to encode the generic | ||
/// ``Output`` object into a ``ByteBuffer``. | ||
package protocol LambdaOutputEncoder { | ||
public protocol LambdaOutputEncoder { | ||
associatedtype Output | ||
|
||
/// Encode the generic type `Output` the handler has returned into a ``ByteBuffer``. | ||
|
@@ -38,15 +38,17 @@ package protocol LambdaOutputEncoder { | |
func encode(_ value: Output, into buffer: inout ByteBuffer) throws | ||
} | ||
|
||
package struct VoidEncoder: LambdaOutputEncoder { | ||
package typealias Output = Void | ||
public struct VoidEncoder: LambdaOutputEncoder { | ||
public typealias Output = Void | ||
|
||
public init() {} | ||
|
||
@inlinable | ||
package func encode(_ value: Void, into buffer: inout NIOCore.ByteBuffer) throws {} | ||
public func encode(_ value: Void, into buffer: inout NIOCore.ByteBuffer) throws {} | ||
} | ||
fabianfett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Adapts a ``LambdaHandler`` conforming handler to conform to ``LambdaWithBackgroundProcessingHandler``. | ||
package struct LambdaHandlerAdapter< | ||
public struct LambdaHandlerAdapter< | ||
Event: Decodable, | ||
Output, | ||
Handler: LambdaHandler | ||
|
@@ -56,7 +58,7 @@ package struct LambdaHandlerAdapter< | |
/// Initializes an instance given a concrete handler. | ||
/// - Parameter handler: The ``LambdaHandler`` conforming handler that is to be adapted to ``LambdaWithBackgroundProcessingHandler``. | ||
@inlinable | ||
package init(handler: Handler) { | ||
public init(handler: Handler) { | ||
self.handler = handler | ||
} | ||
|
||
|
@@ -67,7 +69,7 @@ package struct LambdaHandlerAdapter< | |
/// - outputWriter: The writer to write the computed response to. | ||
/// - context: The ``LambdaContext`` containing the invocation's metadata. | ||
@inlinable | ||
package func handle( | ||
public func handle( | ||
fabianfett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_ event: Event, | ||
outputWriter: some LambdaResponseWriter<Output>, | ||
context: LambdaContext | ||
|
@@ -78,7 +80,7 @@ package struct LambdaHandlerAdapter< | |
} | ||
|
||
/// Adapts a ``LambdaWithBackgroundProcessingHandler`` conforming handler to conform to ``StreamingLambdaHandler``. | ||
package struct LambdaCodableAdapter< | ||
public struct LambdaCodableAdapter< | ||
Handler: LambdaWithBackgroundProcessingHandler, | ||
Event: Decodable, | ||
Output, | ||
|
@@ -88,7 +90,6 @@ package struct LambdaCodableAdapter< | |
@usableFromInline let handler: Handler | ||
@usableFromInline let encoder: Encoder | ||
@usableFromInline let decoder: Decoder | ||
// | ||
@usableFromInline var byteBuffer: ByteBuffer = .init() | ||
|
||
/// Initializes an instance given an encoder, decoder, and a handler with a non-`Void` output. | ||
|
@@ -97,7 +98,7 @@ package struct LambdaCodableAdapter< | |
/// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`. | ||
/// - handler: The handler object. | ||
@inlinable | ||
package init(encoder: Encoder, decoder: Decoder, handler: Handler) where Output: Encodable { | ||
public init(encoder: Encoder, decoder: Decoder, handler: Handler) where Output: Encodable { | ||
self.encoder = encoder | ||
self.decoder = decoder | ||
self.handler = handler | ||
|
@@ -108,7 +109,7 @@ package struct LambdaCodableAdapter< | |
/// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`. | ||
/// - handler: The handler object. | ||
@inlinable | ||
package init(decoder: Decoder, handler: Handler) where Output == Void, Encoder == VoidEncoder { | ||
public init(decoder: Decoder, handler: Handler) where Output == Void, Encoder == VoidEncoder { | ||
self.encoder = VoidEncoder() | ||
self.decoder = decoder | ||
self.handler = handler | ||
|
@@ -120,7 +121,7 @@ package struct LambdaCodableAdapter< | |
/// - outputWriter: The writer to write the computed response to. | ||
/// - context: The ``LambdaContext`` containing the invocation's metadata. | ||
@inlinable | ||
package mutating func handle<Writer: LambdaResponseStreamWriter>( | ||
public mutating func handle<Writer: LambdaResponseStreamWriter>( | ||
_ request: ByteBuffer, | ||
responseWriter: Writer, | ||
context: LambdaContext | ||
|
@@ -136,7 +137,7 @@ package struct LambdaCodableAdapter< | |
} | ||
|
||
/// A ``LambdaResponseStreamWriter`` wrapper that conforms to ``LambdaResponseWriter``. | ||
package struct LambdaCodableResponseWriter<Output, Encoder: LambdaOutputEncoder, Base: LambdaResponseStreamWriter>: | ||
public struct LambdaCodableResponseWriter<Output, Encoder: LambdaOutputEncoder, Base: LambdaResponseStreamWriter>: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we drop the |
||
LambdaResponseWriter | ||
where Output == Encoder.Output { | ||
@usableFromInline let underlyingStreamWriter: Base | ||
|
@@ -147,13 +148,13 @@ where Output == Encoder.Output { | |
/// - encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``, which will then be passed to `streamWriter`. | ||
/// - streamWriter: The underlying ``LambdaResponseStreamWriter`` that will be wrapped. | ||
@inlinable | ||
package init(encoder: Encoder, streamWriter: Base) { | ||
public init(encoder: Encoder, streamWriter: Base) { | ||
self.encoder = encoder | ||
self.underlyingStreamWriter = streamWriter | ||
} | ||
|
||
@inlinable | ||
package func write(_ output: Output) async throws { | ||
public func write(_ output: Output) async throws { | ||
var outputBuffer = ByteBuffer() | ||
try self.encoder.encode(output, into: &outputBuffer) | ||
try await self.underlyingStreamWriter.writeAndFinish(outputBuffer) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.