Documentation
¶
Overview ¶
Package commandprocess handles manipulation of an actual in-process API call. It sets up defaults, stores basic performance info and current command state.
Index ¶
Constants ¶
const ( CallTypeWork = iota // Work is "fire and forget" with no way for the caller to get the result. CallTypeTask // Task is "fire and check" where the call returns the id immediately, the caller checks in later to get the result CallTypeRequest // Request is "fire and wait" where the caller won't receive a response until the command completes or times out. )
API call types.
const EmptyPayload = `` /* 141-byte string literal not displayed */
EmptyPayload stores the base JSON string for a worker payload
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandProcess ¶
type CommandProcess struct { ID string `json:"id"` //UUID for this request HMACGroup string `json:"group"` //The caller's API group name HMACToken string `json:"-"` //The caller's API HMAC token (not key) Payload *gabs.Container `json:"-"` //Payload sent/recv with workers. Contains json format from static/emptyPayload.json InitialInputString string `json:"-"` //Copy of initial input in json string form from the payload when the CommandProcess was initialized InitialCommand string `json:"apiCall"` //The first command to be run in this call APICall *config.APICall `json:"-"` CallType int `json:"callType"` //Value from one of the CallType constants ReqTime time.Time `json:"reqTime"` //The timestamp this request was first created PeekTime time.Time `json:"peekTime"` //PeekTime is updated whenever a client requests a peek into this calls status. It is used in the algo to detect hung calls PeekCount int `json:"peekCount"` //PeekCount is number of times the call has been Peek'ed Complete bool `json:"complete"` //True if all commands have completed. CompleteTime time.Time `json:"completeTime"` //Timestamp of when 'completed' was set true CommandTime time.Time `json:"lastCommandTime"` //The timestamp of the last command entered into MQ LastPrimaryCommand string `json:"lastCommand"` //The config-based subcommand called (doesnt update for 'nextCommand' overrides) CurrentCommand *config.CommandInfo `json:"-"` //Info struct for the currently executing command CurrentCommandIndex int `json:"-"` //Array index of current command NextCommand string `json:"nextCommand"` //If this is set by a worker in the payload, this command will be executed before executing the next config-based command TimeoutChannel chan bool `json:"-"` //When StartTimeout() is called, this is set to the timeout channel TimeoutStarted bool `json:"-"` //When StartTimeout() is called, this is set to true Mutex sync.RWMutex `json:"-"` }
CommandProcess stores in-process API call information
func NewCommandProcess ¶
func NewCommandProcess(calltype int, cmd string, apicall *config.APICall, payload *gabs.Container, appID string, requestKey string) *CommandProcess
NewCommandProcess creates a command process instance, sets defaults, etc, and generates a new uuid
func NewCommandProcessWithID ¶
func NewCommandProcessWithID(id string, calltype int, cmd string, apicall *config.APICall, payload *gabs.Container, hmacgroup, hmactoken string) *CommandProcess
NewCommandProcessWithID creates a command process instance, sets defaults, etc, and allows the caller to specify the uuid
func (*CommandProcess) AddTraceEntry ¶
func (cp *CommandProcess) AddTraceEntry()
AddTraceEntry copies a snapshot of relevant Payload fields into the Payload's trace array
func (*CommandProcess) SetComplete ¶
func (cp *CommandProcess) SetComplete()
SetComplete sets the Complete flag to true, CompleteTime
func (*CommandProcess) SetInitialInput ¶
func (cp *CommandProcess) SetInitialInput(input *gabs.Container)
SetInitialInput sets the intiial payload input and stores it in string form for future use in case of changes
func (*CommandProcess) StartTimeout ¶
func (cp *CommandProcess) StartTimeout() chan bool
StartTimeout creates a channel and starts the timeout goroutine for this process
func (*CommandProcess) UpdatePeekTime ¶
func (cp *CommandProcess) UpdatePeekTime()
UpdatePeekTime sets the requests peek time to Now