Skip to content

Implement schedule.get, schedule.list, and schedule.cancel #823

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zephraph
Copy link
Contributor

@zephraph zephraph commented Mar 31, 2025

Fixes #805

Adds a basic implementation of getAlarm and deleteAlarm to all the existing drivers. To schedule I've added get, cancel, and list methods as well as updating the return type of after and `at.

I've avoided doing anything exotic with the drivers. I've mainly just tried to keep it as simple as I can. I chose to keep the alarm state at the driver level because it does feel like it's a bit unique to the driver.

This could still use some tests overall. I'd like some feedback before going further.

Copy link

graphite-app bot commented Mar 31, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@NathanFlurry
Copy link
Member

Awesome, I'll check this out later today

Copy link

pkg-pr-new bot commented Mar 31, 2025

Open in Stackblitzchat-roomcounter

actor-core

yarn add https://pkg.pr.new/rivet-gg/[email protected]

@actor-core/cli

yarn add https://pkg.pr.new/rivet-gg/actor-core/@actor-core/[email protected]

create-actor

yarn add https://pkg.pr.new/rivet-gg/actor-core/[email protected]

@actor-core/framework-base

yarn add https://pkg.pr.new/rivet-gg/actor-core/@actor-core/[email protected]

@actor-core/react

yarn add https://pkg.pr.new/rivet-gg/actor-core/@actor-core/[email protected]

@actor-core/bun

yarn add https://pkg.pr.new/rivet-gg/actor-core/@actor-core/[email protected]

@actor-core/cloudflare-workers

yarn add https://pkg.pr.new/rivet-gg/actor-core/@actor-core/[email protected]

@actor-core/nodejs

yarn add https://pkg.pr.new/rivet-gg/actor-core/@actor-core/[email protected]

@actor-core/rivet

yarn add https://pkg.pr.new/rivet-gg/actor-core/@actor-core/[email protected]

commit: acb5b01

@zephraph zephraph force-pushed the list-delete-schedule branch 3 times, most recently from c3c3482 to acb5b01 Compare March 31, 2025 17:08
}
}

return Object.freeze(alarms);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Object.freeze here and above is just to ensure the alarm data structure can't be mutated. Probably should do the same for .get

@@ -7,6 +7,7 @@ export interface ActorDriverContext {

export class RivetActorDriver implements ActorDriver {
#ctx: ActorContext;
#alarm: { timeout: ReturnType<typeof setTimeout>; timestamp: number } | null = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not completely clear to me if the rivet driver is instantiated once per actor like the cloudflare driver is once per durable object. I've implemented this assuming that it is.

@zephraph zephraph force-pushed the list-delete-schedule branch 2 times, most recently from ce83f2e to 7d4142f Compare April 8, 2025 13:53
@zephraph
Copy link
Contributor Author

zephraph commented Apr 8, 2025

Given the recent updates to the internal API, I've gutted this PR and just left the interface and docs. I'll go back through and re-implement it.

@zephraph zephraph force-pushed the list-delete-schedule branch 2 times, most recently from c8d38ec to 7300819 Compare April 9, 2025 19:11
@zephraph zephraph force-pushed the list-delete-schedule branch from 7300819 to cf81243 Compare April 10, 2025 14:40
@zephraph zephraph force-pushed the list-delete-schedule branch 2 times, most recently from 98d74da to 640e24e Compare April 11, 2025 23:40
@zephraph zephraph force-pushed the list-delete-schedule branch from 640e24e to 1c3afbd Compare April 11, 2025 23:41
@zephraph zephraph marked this pull request as ready for review April 11, 2025 23:45
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.

[Proposal] Add ability to list and cancel scheduled actions
2 participants