v1

latestOpenAPI 3.0.1Apache License 2.02026-07-17231129.6 KB
promises

Make a promise to claim and execute a task regardless of its current state

put/topics/{topic}/promises/{id}

Path parameters

topicstring required

Name of the topic

idstring required

Unique ID of the target task

Request body

_idstring

Unique ID of the promise, which is the same as the target task ID. A promise with an empty ID is considered an "wildcard promise", and Ratus will assign an appropriate task based on the status of the queue. A task can only be owned by a single promise at a given time.

consumerstring

Identifier of the consumer instance who consumed the task.

deadlinestring

The deadline for the completion of execution promised by the consumer. Consumer code needs to commit the task before this deadline, otherwise the task is determined to have timed out and will be reset to the "pending" state, allowing other consumers to retry.

timeoutstring

Timeout duration for task execution promised by the consumer. When the absolute deadline time is specified, the deadline will take precedence. It is recommended to use relative durations whenever possible to avoid clock synchronization issues. The value must be a valid duration string parsable by time.ParseDuration. This field is only used when creating a promise and will be cleared after converting to an absolute deadline.

Response

OK

_idstring

User-defined unique ID of the task. Task IDs across all topics share the same namespace.

consumedstring

The time the task was claimed by a consumer. Not to confuse this with the time of commit, which is not recorded.

consumerstring

Identifier of the consumer instance who consumed the task.

deadlinestring

The deadline for the completion of execution promised by the consumer. Consumer code needs to commit the task before this deadline, otherwise the task is determined to have timed out and will be reset to the "pending" state, allowing other consumers to retry.

deferstring

A duration relative to the time the task is accepted, indicating that the task will be scheduled to execute after this duration. When the absolute scheduled time is specified, the scheduled time will take precedence. It is recommended to use relative durations whenever possible to avoid clock synchronization issues. The value must be a valid duration string parsable by time.ParseDuration. This field is only used when creating a task and will be cleared after converting to an absolute scheduled time.

noncestring

The nonce field stores a random string for implementing an optimistic concurrency control (OCC) layer outside of the storage engine. Ratus ensures consumers can only commit to tasks that have not changed since the promise was made by verifying the nonce field.

payloadobject

A minimal descriptor of the task to be executed. It is not recommended to rely on Ratus as the main storage of tasks. Instead, consider storing the complete task record in a database, and use a minimal descriptor as the payload to reference the task.

producedstring

The time the task was created. Timestamps are generated by the instance running Ratus, remember to perform clock synchronization before running multiple instances.

producerstring

Identifier of the producer instance who produced the task.

scheduledstring

The time the task is scheduled to be executed. Tasks will not be executed until the scheduled time arrives. After the scheduled time, excessive tasks will be executed in the order of the scheduled time.

state0 | 1 | 2 | 3
topicstring

Topic that the task currently belongs to. Tasks under the same topic will be executed according to the scheduled time.