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

Orchestration: TimerService endowment for orchestrate async-flow #10018

Open
2 tasks
0xpatrickdev opened this issue Sep 3, 2024 · 0 comments
Open
2 tasks

Orchestration: TimerService endowment for orchestrate async-flow #10018

0xpatrickdev opened this issue Sep 3, 2024 · 0 comments
Labels
enhancement New feature or request needs-design

Comments

@0xpatrickdev
Copy link
Member

0xpatrickdev commented Sep 3, 2024

What is the Problem Being Solved?

As an orchestration developer, I would like to be able to use TimerService in an orchestrate async-flow. Since ChainTimerService is in a remote vat and we don't yet have E support in async-flows, interactions need to be written as resumable host code with vows.

Description of the Design

TBD, but the methods in the TimerServiceI interface should all be supported:

export interface TimerServiceI {
/**
* Retrieve the latest timestamp
*/
getCurrentTimestamp: () => TimestampRecord;
/**
* Return value is the time at which the call is scheduled to take place
*/
setWakeup: (
baseTime: Timestamp,
waker: ERef<TimerWaker>,
cancelToken?: CancelToken,
) => TimestampRecord;
/**
* Create and return a promise that will resolve after the absolute
* time has passed.
*/
wakeAt: (
baseTime: Timestamp,
cancelToken?: CancelToken,
) => Promise<TimestampRecord>;
/**
* Create and return a promise that will resolve after the relative time has
* passed.
*/
delay: (
delay: RelativeTime,
cancelToken?: CancelToken,
) => Promise<TimestampRecord>;
/**
* Create and return a repeater that will schedule `wake()` calls
* repeatedly at times that are a multiple of interval following delay.
* Interval is the difference between successive times at which wake will be
* called. When `schedule(w)` is called, `w.wake()` will be scheduled to be
* called after the next multiple of interval from the base. Since times can be
* coarse-grained, the actual call may occur later, but this won't change when
* the next event will be called.
*/
makeRepeater: (
delay: RelativeTime,
interval: RelativeTime,
cancelToken?: CancelToken,
) => TimerRepeater;
/**
* Create a repeater with a handler directly.
*/
repeatAfter: (
delay: RelativeTime,
interval: RelativeTime,
handler: TimerWaker,
cancelToken?: CancelToken,
) => void;
/**
* Create and return a Notifier that will deliver updates repeatedly at times
* that are a multiple of interval following delay.
*/
makeNotifier: (
delay: RelativeTime,
interval: RelativeTime,
cancelToken?: CancelToken,
) => import('@agoric/notifier').Notifier<TimestampRecord>;
/**
* Cancel a previously-established wakeup or repeater.
*/
cancel: (cancelToken: CancelToken) => void;
/**
* Retrieve the read-only Clock facet.
*/
getClock: () => Clock;
/**
* Retrieve the Brand for this timer service.
*/
getTimerBrand: () => TimerBrand;
}

We might want to break this down into separate subtasks -

  • retriable methods, like getCurrentTimestamp, getTimerBrand, getClock
  • methods that require a durable and potentially resumable handler, like wakeAt and makeRepeater
    • This might entail the following story: As a developer, I should be able to use an orchestrated async-flow function for a TimerWaker handler

Open Questions / Considerations:

  • Does the periodic continue if the previous run is an exception?
  • Does TimerService need to know about vows, if a handler is returning a vow?
  • What happens on upgrade? Both the time orchestrated contract using TimerService, and TimerService itself.

Security Considerations

Scaling Considerations

Test Plan

Upgrade Considerations

@0xpatrickdev 0xpatrickdev added enhancement New feature or request needs-design labels Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-design
Projects
None yet
Development

No branches or pull requests

1 participant