Skip to main content

Module operation

Module operation 

Source
Expand description

The operation handle, and what its commands take and answer. The operation object, and the filters and parameters its commands take.

An operation used to be a String here, and every command took one. That is still true — Client carries the whole lifecycle over an id — but a string is a poor thing to hand to a function, and it is nothing to reattach to. Operation is the handle: a client and an id, with the same commands on it, obtained either from an id you just started or from one you persisted before the process died.

let id = client.start_vanilla(&spec)?;
std::fs::write("run.id", &id)?;          // survive a restart

// …later, in a process that did not start it:
let op = client.attach_operation(std::fs::read_to_string("run.id")?);
op.suspend(false)?;
op.resume()?;
op.wait()?;

§What the cluster says about the lifecycle

Measured on a local cluster, because none of it is obvious:

  • Suspension is not a state. A suspended operation still reports running; suspended is a separate attribute, which is what Operation::suspended reads — and Operation::status reads beside the state, in one request, because a poll loop needs both. Polling the state alone will never tell you an operation is paused.
  • Suspend is idempotent, resume is not. Suspending a suspended operation answers {}; resuming one that is not suspended fails with code 201, Operation is in "running" state.
  • Complete is not idempotent, and behaves like Client::abort_operation: the second one is answered No such operation.
  • Once the scheduler has let the operation go, every one of these answers No such operation — the rule is “the scheduler still has it”, not “it has not finished”.

Structs§

Operation
A running — or finished — operation, and the client that can ask about it.
OperationEvent
One entry of an operation’s event log, as list_operation_events reports it.
OperationFilter
Which operations Client::list_operations should return.
OperationInfo
One operation, as Client::list_operations reports it.
OperationList
The answer to Client::list_operations.
OperationParameters
What Client::update_operation_parameters should change.
OperationStatus
What an operation is doing, as Client::operation_status reports it.