ETS record store of the tasks of one instance: the default store of
the option :task_store and it implements
OzMcp.Tasks.StoreBehaviour. One named table per instance (the
records table, table/1). The index of the records lives in
OzMcp.Tasks.Index: this store implements none of the optional
callbacks of the contract, so the facade OzMcp.Tasks.Records keeps
that index for it.
A separate owner process (OzMcp.Tasks.Table) calls init/1 and owns
the tables. The tables are :public: the process of a task writes its
own record and the request processes read the records. A crash of
the owner deletes the records of the instance.
Hazard: the record keeps a snapshot of the principal that created the
task (principal), because the runner runs after the request ends, so
the check of the token cannot be replayed. It never holds the raw
token.
Summary
Functions
The records with the status :working or :input_required.
Returns the deadline of the record in Unix milliseconds, or nil.
Removes the record.
Returns true when the record ttl (ms from creation) has elapsed.
Returns {:ok, record} or :not_found.
Creates the named ETS table of the records for the given instance.
Writes the record.
Returns the name of the records table for the given instance.
Types
@type status() :: OzMcp.Structs.Task.status()
@type t() :: %OzMcp.Tasks.EtsStore{ bytes: non_neg_integer(), client_capabilities: map(), created_at: DateTime.t(), expires_at_ms: integer() | nil, last_updated_at: DateTime.t(), owner_key: term(), pid: pid() | nil, poll_interval: non_neg_integer() | nil, principal: OzMcp.Auth.Principal.t() | nil, progress_token: String.t() | integer() | nil, required_scopes: [String.t()] | nil, result: result(), runner_pid: pid() | nil, seq: non_neg_integer(), session_id: String.t(), status: status(), status_message: String.t() | nil, task_id: String.t(), tool: {module(), String.t()}, ttl: non_neg_integer() | nil }
Functions
The records with the status :working or :input_required.
Returns the deadline of the record in Unix milliseconds, or nil.
Removes the record.
@spec expired?(t(), DateTime.t()) :: boolean()
Returns true when the record ttl (ms from creation) has elapsed.
Returns {:ok, record} or :not_found.
@spec init(atom()) :: :ok
Creates the named ETS table of the records for the given instance.
Writes the record.
Returns the name of the records table for the given instance.