Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dandavison
Copy link
Contributor

[Draft]

CompletablePromise<String> promise = Workflow.newPromise();
QueuedCommand queuedCommand = new QueuedCommand(command, promise);
this.commandQueue.add(queuedCommand);
return queuedCommand.promise.get();

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()?

Copy link
Contributor Author

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.

Copy link
Contributor

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;

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).

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants