-
Notifications
You must be signed in to change notification settings - Fork 143
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
Update request processor #593
base: main
Are you sure you want to change the base?
Conversation
d7eb6c1
to
0b20ee3
Compare
CompletablePromise<String> promise = Workflow.newPromise(); | ||
QueuedCommand queuedCommand = new QueuedCommand(command, promise); | ||
this.commandQueue.add(queuedCommand); | ||
return queuedCommand.promise.get(); |
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.
@Quinn-With-Two-Ns Is there a way here to free up the update thread? e.g. could the update handler return the promise, rather than block on .get()
?
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.
Good point, I'd be interested to know this, but haven't looked into it yet.
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.
Yeah we can explore alternative approaches that use less threads. Given we only allow 10 concurrent updates it wasn't prioritized, virtual threads also make this not a big deal.
} | ||
} | ||
|
||
private ArrayList<QueuedCommand> commandQueue; |
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.
ArrayList
works in this case, but prefer WorkflowQueue
instead. It provides a more appropriate API, inspired from "Blocking Queue", but Workflow-safe (it internally use Workflow.await()
to implement blocking ops).
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.
Thanks! Yes @Quinn-With-Two-Ns pointed that out to me also.
[Draft]