Documentation
¶
Index ¶
- func NewOperationsServer() longrunningpb.OperationsServer
- type OperationServer
- func (s *OperationServer) CancelOperation(ctx context.Context, req *longrunningpb.CancelOperationRequest) (*emptypb.Empty, error)
- func (s *OperationServer) GetOperation(ctx context.Context, req *longrunningpb.GetOperationRequest) (*longrunningpb.Operation, error)
- func (s *OperationServer) ListOperations(ctx context.Context, req *longrunningpb.ListOperationsRequest) (*longrunningpb.ListOperationsResponse, error)
- func (s *OperationServer) WaitOperation(ctx context.Context, req *longrunningpb.WaitOperationRequest) (*longrunningpb.Operation, error)
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 ¶
func (s *OperationServer) CancelOperation( ctx context.Context, req *longrunningpb.CancelOperationRequest, ) (*emptypb.Empty, error)
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 ¶
func (s *OperationServer) GetOperation( ctx context.Context, req *longrunningpb.GetOperationRequest, ) (*longrunningpb.Operation, error)
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 ¶
func (s *OperationServer) ListOperations( ctx context.Context, req *longrunningpb.ListOperationsRequest, ) (*longrunningpb.ListOperationsResponse, error)
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 ¶
func (s *OperationServer) WaitOperation( ctx context.Context, req *longrunningpb.WaitOperationRequest, ) (*longrunningpb.Operation, error)
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.