Documentation ¶
Index ¶
- func Clone() map[string]*Operation
- func ForwardedOperationResponse(project string, op *api.Operation) response.Response
- func ForwardedOperationWebSocket(req *http.Request, id string, source *websocket.Conn) response.Response
- func Init(d bool)
- func Lock()
- func OperationResponse(op *Operation) response.Response
- func OperationWebSocket(req *http.Request, op *Operation) response.Response
- func SetProgressMetadata(metadata map[string]any, stage, displayPrefix string, ...)
- func Unlock()
- type Operation
- func (op *Operation) Cancel() (chan error, error)
- func (op *Operation) Class() OperationClass
- func (op *Operation) Connect(r *http.Request, w http.ResponseWriter) (chan error, error)
- func (op *Operation) ExtendMetadata(metadata any) error
- func (op *Operation) ID() string
- func (op *Operation) Metadata() map[string]any
- func (op *Operation) Permission() (auth.ObjectType, auth.Entitlement)
- func (op *Operation) Project() string
- func (op *Operation) Render() (string, *api.Operation, error)
- func (op *Operation) Requestor() *api.EventLifecycleRequestor
- func (op *Operation) Resources() map[string][]api.URL
- func (op *Operation) SetCanceler(canceler *cancel.HTTPRequestCanceller)
- func (op *Operation) SetEventServer(events *events.Server)
- func (op *Operation) SetRequestor(r *http.Request)
- func (op *Operation) Start() error
- func (op *Operation) Status() api.StatusCode
- func (op *Operation) Type() operationtype.Type
- func (op *Operation) URL() string
- func (op *Operation) UpdateMetadata(opMetadata any) error
- func (op *Operation) UpdateResources(opResources map[string][]api.URL) error
- func (op *Operation) Wait(ctx context.Context) error
- type OperationClass
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
Clone returns a clone of the internal operations map containing references to the actual operations.
func ForwardedOperationResponse ¶
ForwardedOperationResponse creates a response that forwards the metadata of an operation created on another node.
func ForwardedOperationWebSocket ¶
func ForwardedOperationWebSocket(req *http.Request, id string, source *websocket.Conn) response.Response
ForwardedOperationWebSocket returns a new forwarted websocket operation.
func OperationResponse ¶
OperationResponse returns an operation response.
func OperationWebSocket ¶
OperationWebSocket returns a new websocket operation.
Types ¶
type Operation ¶
type Operation struct {
// contains filtered or unexported fields
}
Operation represents an operation.
func OperationCreate ¶
func OperationCreate(s *state.State, projectName string, opClass OperationClass, opType operationtype.Type, opResources map[string][]api.URL, opMetadata any, onRun func(*Operation) error, onCancel func(*Operation) error, onConnect func(*Operation, *http.Request, http.ResponseWriter) error, r *http.Request) (*Operation, error)
OperationCreate creates a new operation and returns it. If it cannot be created, it returns an error.
func OperationGetInternal ¶
OperationGetInternal returns the operation with the given id. It returns an error if it doesn't exist.
func (*Operation) Cancel ¶
Cancel cancels a running operation. If the operation cannot be cancelled, it returns an error.
func (*Operation) Class ¶
func (op *Operation) Class() OperationClass
Class returns the operation class.
func (*Operation) Connect ¶
Connect connects a websocket operation. If the operation is not a websocket operation or the operation is not running, it returns an error.
func (*Operation) ExtendMetadata ¶
ExtendMetadata updates the metadata of the operation with the additional data provided. It returns an error if the operation is not pending or running, or the operation is read-only.
func (*Operation) Permission ¶
func (op *Operation) Permission() (auth.ObjectType, auth.Entitlement)
Permission returns the operations auth.ObjectType and auth.Entitlement.
func (*Operation) Render ¶
Render renders the operation structure. Returns URL of operation and operation info.
func (*Operation) Requestor ¶
func (op *Operation) Requestor() *api.EventLifecycleRequestor
Requestor returns the initial requestor for this operation.
func (*Operation) SetCanceler ¶
func (op *Operation) SetCanceler(canceler *cancel.HTTPRequestCanceller)
SetCanceler sets a canceler.
func (*Operation) SetEventServer ¶
SetEventServer allows injection of event server.
func (*Operation) SetRequestor ¶
SetRequestor sets a requestor for this operation from an http.Request.
func (*Operation) Start ¶
Start a pending operation. It returns an error if the operation cannot be started.
func (*Operation) Status ¶
func (op *Operation) Status() api.StatusCode
Status returns the operation status.
func (*Operation) Type ¶
func (op *Operation) Type() operationtype.Type
Type returns the db operation type.
func (*Operation) UpdateMetadata ¶
UpdateMetadata updates the metadata of the operation. It returns an error if the operation is not pending or running, or the operation is read-only.
func (*Operation) UpdateResources ¶
UpdateResources updates the resources of the operation. It returns an error if the operation is not pending or running, or the operation is read-only.
type OperationClass ¶
type OperationClass int
OperationClass represents the OperationClass type.
const ( // OperationClassTask represents the Task OperationClass. OperationClassTask OperationClass = 1 // OperationClassWebsocket represents the Websocket OperationClass. OperationClassWebsocket OperationClass = 2 // OperationClassToken represents the Token OperationClass. OperationClassToken OperationClass = 3 )
func (OperationClass) String ¶
func (t OperationClass) String() string