Documentation ¶
Index ¶
- Constants
- 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 Unlock()
- type Operation
- func (op *Operation) Cancel() (chan error, error)
- func (op *Operation) Connect(r *http.Request, w http.ResponseWriter) (chan error, error)
- func (op *Operation) ID() string
- func (op *Operation) Metadata() map[string]interface{}
- func (op *Operation) Permission() string
- func (op *Operation) Project() string
- func (op *Operation) Render() (string, *api.Operation, error)
- func (op *Operation) Resources() map[string][]string
- func (op *Operation) Run() (chan error, error)
- func (op *Operation) SetCanceler(canceler *cancel.Canceler)
- func (op *Operation) SetEventServer(events *events.Server)
- func (op *Operation) Status() api.StatusCode
- func (op *Operation) Type() db.OperationType
- func (op *Operation) URL() string
- func (op *Operation) UpdateMetadata(opMetadata interface{}) error
- func (op *Operation) UpdateResources(opResources map[string][]string) error
- func (op *Operation) WaitFinal(timeout int) (bool, error)
Constants ¶
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 )
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, project string, opClass operationClass, opType db.OperationType, opResources map[string][]string, opMetadata interface{}, onRun func(*Operation) error, onCancel func(*Operation) error, onConnect func(*Operation, *http.Request, http.ResponseWriter) error) (*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) 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) Permission ¶
Permission returns the operation permission.
func (*Operation) Run ¶
Run runs a pending operation. It returns an error if the operation cannot be started.
func (*Operation) SetCanceler ¶
SetCanceler sets a canceler.
func (*Operation) SetEventServer ¶
SetEventServer allows injection of event server.
func (*Operation) Status ¶
func (op *Operation) Status() api.StatusCode
Status returns the operation status.
func (*Operation) Type ¶
func (op *Operation) Type() db.OperationType
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.