From 2ce4495084eeedcecc677ba7a40d4c81a577c26e Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Tue, 3 Dec 2024 18:46:43 +0100 Subject: [PATCH] Missing files --- .../wit/deps/golem-1.1/golem-host-1.1.wit | 260 +++++++++++++++++ .../wit/deps/golem-1.1/golem-oplog-1.1.wit | 267 ++++++++++++++++++ .../golem-1.1/golem-oplog-processor-1.1.wit | 32 +++ 3 files changed, 559 insertions(+) create mode 100644 golem-rust/wit/deps/golem-1.1/golem-host-1.1.wit create mode 100644 golem-rust/wit/deps/golem-1.1/golem-oplog-1.1.wit create mode 100644 golem-rust/wit/deps/golem-1.1/golem-oplog-processor-1.1.wit diff --git a/golem-rust/wit/deps/golem-1.1/golem-host-1.1.wit b/golem-rust/wit/deps/golem-1.1/golem-host-1.1.wit new file mode 100644 index 0000000..98d8a81 --- /dev/null +++ b/golem-rust/wit/deps/golem-1.1/golem-host-1.1.wit @@ -0,0 +1,260 @@ +package golem:api@1.1.0; + +/// The Golem host API provides low level access to Golem specific features such as promises and control over +/// the durability and transactional guarantees the executor provides. +interface host { + use golem:rpc/types@0.1.0.{uri}; + use wasi:clocks/monotonic-clock@0.2.0.{duration}; + + /// An index into the persistent log storing all performed operations of a worker + type oplog-index = u64; + + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + record promise-id { + worker-id: worker-id, + oplog-idx: oplog-index, + } + + /// Represents a Golem worker + record worker-id { + component-id: component-id, + worker-name: string + } + + /// Represents a Golem component + record component-id { + uuid: uuid, + } + + /// Represents a Golem component's version + type component-version = u64; + + /// UUID + record uuid { + high-bits: u64, + low-bits: u64 + } + + /// Represents a Golem Cloud account + record account-id { + value: string + } + + /// Configures how the executor retries failures + record retry-policy { + /// The maximum number of retries before the worker becomes permanently failed + max-attempts: u32, + /// The minimum delay between retries (applied to the first retry) + min-delay: duration, + /// The maximum delay between retries + max-delay: duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + multiplier: f64, + /// The maximum amount of jitter to add to the delay + max-jitter-factor: option + } + + /// Configurable persistence level for workers + variant persistence-level { + persist-nothing, + persist-remote-side-effects, + smart + } + + /// Describes how to update a worker to a different component version + enum update-mode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + automatic, + + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + snapshot-based + } + + enum filter-comparator { + equal, + not-equal, + greater-equal, + greater, + less-equal, + less + } + + enum string-filter-comparator { + equal, + not-equal, + like, + not-like + } + + enum worker-status { + /// The worker is running an invoked function + running, + /// The worker is ready to run an invoked function + idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + suspended, + /// The last invocation was interrupted but will be resumed + interrupted, + /// The last invocation failed and a retry was scheduled + retrying, + /// The last invocation failed and the worker can no longer be used + failed, + /// The worker exited after a successful invocation and can no longer be invoked + exited, + } + + record worker-name-filter { + comparator: string-filter-comparator, + value: string + } + + record worker-status-filter { + comparator: filter-comparator, + value: worker-status + } + + record worker-version-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-created-at-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-env-filter { + name: string, + comparator: string-filter-comparator, + value: string + } + + variant worker-property-filter { + name(worker-name-filter), + status(worker-status-filter), + version(worker-version-filter), + created-at(worker-created-at-filter), + env(worker-env-filter) + } + + record worker-all-filter { + filters: list + } + + record worker-any-filter { + filters: list + } + + record worker-metadata { + worker-id: worker-id, + args: list, + env: list>, + status: worker-status, + component-version: u64, + retry-count: u64 + } + + resource get-workers { + constructor(component-id: component-id, filter: option, precise: bool); + + get-next: func() -> option>; + } + + /// Create a new promise + create-promise: func() -> promise-id; + + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + await-promise: func(promise-id: promise-id) -> list; + + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + complete-promise: func(promise-id: promise-id, data: list) -> bool; + + /// Deletes the given promise + delete-promise: func(promise-id: promise-id) -> (); + + /// Returns the current position in the persistent op log + get-oplog-index: func() -> oplog-index; + + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + set-oplog-index: func(oplog-idx: oplog-index) -> (); + + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + oplog-commit: func(replicas: u8) -> (); + + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + mark-begin-operation: func() -> oplog-index; + + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + mark-end-operation: func(begin: oplog-index) -> (); + + /// Gets the current retry policy associated with the worker + get-retry-policy: func() -> retry-policy; + + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + set-retry-policy: func(new-retry-policy: retry-policy) -> (); + + /// Gets the worker's current persistence level. + get-oplog-persistence-level: func() -> persistence-level; + + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + set-oplog-persistence-level: func(new-persistence-level: persistence-level) -> (); + + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + get-idempotence-mode: func() -> bool; + + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + set-idempotence-mode: func(idempotent: bool) -> (); + + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + generate-idempotency-key: func() -> uuid; + + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + update-worker: func(worker-id: worker-id, target-version: component-version, mode: update-mode) -> (); + + /// Get current worker metadata + get-self-metadata: func() -> worker-metadata; + + /// Get worker metadata + get-worker-metadata: func(worker-id: worker-id) -> option; +} + +/// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers +/// when the new component incompatible with the old one. +interface save-snapshot { + /// Saves the component's state into a user-defined snapshot + save: func() -> list; +} + +/// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers +/// when the new component incompatible with the old one. +interface load-snapshot { + /// Tries to load a user-defined snapshot, setting up the worker's state based on it. + /// The function can return with a failure to indicate that the update is not possible. + load: func(bytes: list) -> result<_, string>; +} + +world golem-host { + import host; + import save-snapshot; + import load-snapshot; +} diff --git a/golem-rust/wit/deps/golem-1.1/golem-oplog-1.1.wit b/golem-rust/wit/deps/golem-1.1/golem-oplog-1.1.wit new file mode 100644 index 0000000..dbececf --- /dev/null +++ b/golem-rust/wit/deps/golem-1.1/golem-oplog-1.1.wit @@ -0,0 +1,267 @@ +package golem:api@1.1.0; + +/// Host interface for enumerating and searching for worker oplogs +interface oplog { + use wasi:clocks/wall-clock@0.2.0.{datetime}; + use golem:rpc/types@0.1.0.{wit-value}; + + use host.{account-id, component-version, oplog-index, retry-policy, uuid, worker-id}; + + variant wrapped-function-type { + /// The side-effect reads from the worker's local state (for example local file system, + /// random generator, etc.) + read-local, + /// The side-effect writes to the worker's local state (for example local file system) + write-local, + /// The side-effect reads from external state (for example a key-value store) + read-remote, + /// The side-effect manipulates external state (for example an RPC call) + write-remote, + /// The side-effect manipulates external state through multiple invoked functions (for example + /// a HTTP request where reading the response involves multiple host function calls) + /// + /// On the first invocation of the batch, the parameter should be `None` - this triggers + /// writing a `BeginRemoteWrite` entry in the oplog. Followup invocations should contain + /// this entry's index as the parameter. In batched remote writes it is the caller's responsibility + /// to manually write an `EndRemoteWrite` entry (using `end_function`) when the operation is completed. + write-remote-batched(option) + } + + record plugin-installation-description { + installation-id: uuid, + name: string, + version: string, + parameters: list> + } + + record create-parameters { + timestamp: datetime, + worker-id: worker-id, + component-version: component-version, + args: list, + env: list>, + account-id: account-id, + parent: option, + component-size: u64, + initial-total-linear-memory-size: u64, + initial-active-plugins: list + } + + record imported-function-invoked-parameters { + timestamp: datetime, + function-name: string, + request: wit-value, + response: wit-value, + wrapped-function-type: wrapped-function-type, + } + + record exported-function-invoked-parameters { + timestamp: datetime, + function-name: string, + request: list, + idempotency-key: string + } + + record exported-function-completed-parameters { + timestamp: datetime, + response: wit-value, + consumed-fuel: s64 + } + + record error-parameters { + timestamp: datetime, + error: string + } + + record jump-parameters { + timestamp: datetime, + start: oplog-index, + end: oplog-index + } + + record change-retry-policy-parameters { + timestamp: datetime, + retry-policy: retry-policy + } + + record end-atomic-region-parameters { + timestamp: datetime, + begin-index: oplog-index + } + + record end-remote-write-parameters { + timestamp: datetime, + begin-index: oplog-index + } + + record exported-function-invocation-parameters { + idempotency-key: string, + function-name: string, + input: option> + } + + variant worker-invocation { + exported-function(exported-function-invocation-parameters), + manual-update(component-version) + } + + record pending-worker-invocation-parameters { + timestamp: datetime, + invocation: worker-invocation + } + + variant update-description { + /// Automatic update by replaying the oplog on the new version + auto-update, + /// Custom update by loading a given snapshot on the new version + snapshot-based(list) + } + + record pending-update-parameters { + timestamp: datetime, + target-version: component-version, + update-description: update-description + } + + record successful-update-parameters { + timestamp: datetime, + target-version: component-version, + new-component-size: u64, + new-active-plugins: list + } + + record failed-update-parameters { + timestamp: datetime, + target-version: component-version, + details: option + } + + record grow-memory-parameters { + timestamp: datetime, + delta: u64 + } + + type worker-resource-id = u64; + + record create-resource-parameters { + timestamp: datetime, + resource-id: worker-resource-id + } + + record drop-resource-parameters { + timestamp: datetime, + resource-id: worker-resource-id + } + + record describe-resource-parameters { + timestamp: datetime, + resource-id: worker-resource-id, + resource-name: string, + resource-params: list + } + + enum log-level { + stdout, + stderr, + trace, + debug, + info, + warn, + error, + critical + } + + record log-parameters { + timestamp: datetime, + level: log-level, + context: string, + message: string + } + + record activate-plugin-parameters { + timestamp: datetime, + plugin: plugin-installation-description + } + + record deactivate-plugin-parameters { + timestamp: datetime, + plugin: plugin-installation-description + } + + variant oplog-entry { + /// The initial worker oplog entry + create(create-parameters), + /// The worker invoked a host function + imported-function-invoked(imported-function-invoked-parameters), + /// The worker has been invoked + exported-function-invoked(exported-function-invoked-parameters), + /// The worker has completed an invocation + exported-function-completed(exported-function-completed-parameters), + /// Worker suspended + suspend(datetime), + /// Worker failed + error(error-parameters), + /// Marker entry added when get-oplog-index is called from the worker, to make the jumping behavior + /// more predictable. + no-op(datetime), + /// The worker needs to recover up to the given target oplog index and continue running from + /// the source oplog index from there + /// `jump` is an oplog region representing that from the end of that region we want to go back to the start and + /// ignore all recorded operations in between. + jump(jump-parameters), + /// Indicates that the worker has been interrupted at this point. + /// Only used to recompute the worker's (cached) status, has no effect on execution. + interrupted(datetime), + /// Indicates that the worker has been exited using WASI's exit function. + exited(datetime), + /// Overrides the worker's retry policy + change-retry-policy(change-retry-policy-parameters), + /// Begins an atomic region. All oplog entries after `BeginAtomicRegion` are to be ignored during + /// recovery except if there is a corresponding `EndAtomicRegion` entry. + begin-atomic-region(datetime), + /// Ends an atomic region. All oplog entries between the corresponding `BeginAtomicRegion` and this + /// entry are to be considered during recovery, and the begin/end markers can be removed during oplog + /// compaction. + end-atomic-region(end-atomic-region-parameters), + /// Begins a remote write operation. Only used when idempotence mode is off. In this case each + /// remote write must be surrounded by a `BeginRemoteWrite` and `EndRemoteWrite` log pair and + /// unfinished remote writes cannot be recovered. + begin-remote-write(datetime), + /// Marks the end of a remote write operation. Only used when idempotence mode is off. + end-remote-write(end-remote-write-parameters), + /// An invocation request arrived while the worker was busy + pending-worker-invocation(pending-worker-invocation-parameters), + /// An update request arrived and will be applied as soon the worker restarts + pending-update(pending-update-parameters), + /// An update was successfully applied + successful-update(successful-update-parameters), + /// An update failed to be applied + failed-update(failed-update-parameters), + /// Increased total linear memory size + grow-memory(grow-memory-parameters), + /// Created a resource instance + create-resource(create-resource-parameters), + /// Dropped a resource instance + drop-resource(drop-resource-parameters), + /// Adds additional information for a created resource instance + describe-resource(describe-resource-parameters), + /// The worker emitted a log message + log(log-parameters), + /// The worker's has been restarted, forgetting all its history + restart(datetime), + /// Activates a plugin + activate-plugin(activate-plugin-parameters), + /// Deactivates a plugin + deactivate-plugin(deactivate-plugin-parameters) + } + + resource get-oplog { + constructor(worker-id: worker-id, start: oplog-index); + get-next: func() -> option>; + } + + resource search-oplog { + constructor(worker-id: worker-id, text: string); + get-next: func() -> option>>; + } +} diff --git a/golem-rust/wit/deps/golem-1.1/golem-oplog-processor-1.1.wit b/golem-rust/wit/deps/golem-1.1/golem-oplog-processor-1.1.wit new file mode 100644 index 0000000..cb5f9fb --- /dev/null +++ b/golem-rust/wit/deps/golem-1.1/golem-oplog-processor-1.1.wit @@ -0,0 +1,32 @@ +package golem:api@1.1.0; + +interface oplog-processor { + use wasi:clocks/wall-clock@0.2.0.{datetime}; + use golem:rpc/types@0.1.0.{wit-value}; + + use host.{account-id, component-id, oplog-index, worker-id, worker-metadata}; + use oplog.{oplog-entry}; + + record account-info { + account-id: account-id + } + + /// A processor resource is instantiated for each account having activated this oplog processor plugin. + /// There are no guarantees for the number of processors running at the same time, and different entries from the same worker + /// may be sent to different processor instances. + resource processor { + /// Initializes an oplog processor for a given component where the plugin was installed to. + /// The `account-info` parameters contains details of the account the installation belongs to. + /// The `component-id` parameter contains the identifier of the component the plugin was installed to. + /// The `config` parameter contains the configuration parameters for the plugin, as specified in the plugin installation + /// for the component. + constructor(account-info: account-info, component-id: component-id, config: list>); + + /// Called when one of the workers the plugin is activated on has written new entries to its oplog. + /// The `worker-id` parameter identifies the worker. + /// The `metadata` parameter contains the latest metadata of the worker. + /// The `first-entry-index` parameter contains the index of the first entry in the list of `entries`. + /// The `entries` parameteter always contains at least one element. + process: func(worker-id: worker-id, metadata: worker-metadata, first-entry-index: oplog-index, entries: list) -> result<_, string>; + } +}