operations

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOperationsServer

func NewOperationsServer() longrunningpb.OperationsServer

Types

type OperationServer

type OperationServer struct {
	longrunningpb.UnimplementedOperationsServer
}

func (*OperationServer) CancelOperation

CancelOperation requests cancellation of a running operation.

AIP-151 contract:

  • Cancellation is best-effort: the operation may already be complete by the time this RPC is processed.
  • If the operation is already in a terminal state, the call succeeds without modifying anything.
  • On success the DB row is transitioned to CANCELLED and a cancel signal is published to NATS so the executor goroutine stops the MulVAL subprocess.

The two-step sequence (DB write → NATS publish) is intentional: the DB is the authoritative state. If NATS delivery fails the row is already marked CANCELLED and the executor will detect the state on its next check or at process restart.

func (*OperationServer) GetOperation

GetOperation returns the current state of an operation.

AIP-151: the operation name must be in the form "operations/{uuid}". The response is done=true once the operation reaches any terminal state.

func (*OperationServer) ListOperations

ListOperations returns a paginated list of operations.

AIP-151 defines a string filter field. This implementation supports a simple equality filter on the state field:

filter: "state=RUNNING"
filter: "state=SUCCEEDED"
filter: "state=FAILED"
filter: "state=CANCELLED"

An empty or unrecognised filter returns all operations. Results are ordered newest-first (create_time DESC), consistent with ListAnalyses. The same cursor-based page token is used.

func (*OperationServer) WaitOperation

WaitOperation blocks until the named operation reaches a terminal state or the timeout elapses, whichever comes first.

AIP-151 contract:

  • If the operation is already terminal, return it immediately.
  • If the timeout elapses before completion, return the current (not-done) operation without error.
  • The maximum server-side timeout is maxWaitTimeout; longer client timeouts are silently capped.

Implementation uses a JetStream ordered consumer on the per-operation subject so the handler wakes immediately when MulVAL finishes, without polling the database.

Race safety: the consumer is created *before* the second state check. This closes the window where completion fires between the first check and the subscribe call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL