Skip to content

Conversation

fabianfett
Copy link
Contributor

Add a new ControlPlaneRequestEncoder that encodes all requests into an existing buffer.

Motivation:

We want to write our request to the ControlPlaneAPI into one buffer, that we can reuse over and over.

Modifications:

  • Add ControlPlaneRequestEncoder that writes ControlPlaneRequests into a buffer that is reused.

Result:

  • Fewer messages on the ChannelPipeline.

@fabianfett fabianfett requested a review from tomerd December 6, 2021 21:52
@fabianfett fabianfett added the 🔨 semver/patch No public API change. label Dec 6, 2021
self.byteBuffer.writeString(.userAgentHeader)
self.byteBuffer.writeContentLengthHeader(length: contentLength)
self.byteBuffer.writeString(.CRLF) // end of head
if contentLength > 0 {
Copy link
Contributor

@tomerd tomerd Dec 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if let payload = payload && contentLength > 0 could be nice so we can drop the force unwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


mutating func writerAdded(context: ChannelHandlerContext) {
self.byteBuffer = context.channel.allocator.buffer(capacity: 256)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

@fabianfett fabianfett merged commit 5d235c0 into awslabs:main Dec 11, 2021
@fabianfett fabianfett deleted the ff-request-encoder branch December 11, 2021 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants