-
Notifications
You must be signed in to change notification settings - Fork 113
Feature/ff local server #70
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
Conversation
d67c801
to
f0f5e4b
Compare
private var processing = CircularBuffer<(head: HTTPRequestHead, body: ByteBuffer?)>() | ||
|
||
private static var queue = [Pending]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use CircularBuffer, and then you can pop as optional
} | ||
guard requestId == pending.requestId else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used a dictionary to make sure we bring the right pending request, this will make it order based in case you have some concurrency between the client submitting work (eg iOS app) and the lambda polling/processing work (lambda code)
@@ -88,13 +88,20 @@ private enum LocalLambda { | |||
} | |||
|
|||
final class HTTPHandler: ChannelInboundHandler { | |||
|
|||
enum InvocationState { | |||
case waitingForNextRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitingForLambdaRequest
|
||
enum InvocationState { | ||
case waitingForNextRequest | ||
case idle(EventLoopPromise<Pending>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitingForInvocation
enum InvocationState { | ||
case waitingForNextRequest | ||
case idle(EventLoopPromise<Pending>) | ||
case processing(Pending) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitingForLambdaResponse
@@ -137,43 +144,63 @@ private enum LocalLambda { | |||
self.writeResponse(context: context, response: .init(status: .internalServerError)) | |||
} | |||
} | |||
Self.queueLock.withLock { | |||
Self.queue[requestId] = Pending(requestId: requestId, request: work, responsePromise: promise) | |||
let pending = Pending(requestId: requestId, request: work, responsePromise: promise) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending -> Invocation
} | ||
|
||
// pop the first task from the queue | ||
switch !Self.queue.isEmpty ? Self.queue.removeFirst() : nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
circular buffer will make this easier
@fabianfett merged this and will continue to iterate on the original branch |
* Don’t exit immediately * Removed locks. Just running in one EL
* Don’t exit immediately * Removed locks. Just running in one EL
* Don’t exit immediately * Removed locks. Just running in one EL
* Don’t exit immediately * Removed locks. Just running in one EL
Implemented some of the comments.