Funcs
Funcs : Funcs
Lookup a task by id which is any value supported by toRecId()
List the current tasks as a grid
Is the current context running asynchrounsly inside a task
Return current task if running within the context of an asynchronous task
Run the given expression asynchronously in an ephemeral task
Restart a task
Set cancel flag for the given task
Update the current running task's progress data with given dict
Asynchronously send a message to the given task for processing
Schedule a message for delivery after the specified period of duration has elapsed
Schedule a message for delivery after the given future has completed
Get a task local variable by name or def if not defined
Set a task local variable
Remove a task local variable by name
Block current thread until a future's result is ready
Cancel a future
Return current state of a future as one of the following strings
Return if a future has completed or is still pending a result
Block until a future transitions to a completed state (ok, err, or canceled)
Block on a list of futures until they all transition to a completed state
Sleep for the given duration
Refresh the user account used for tasks
(id: Obj?, checked: Bool) => Dict? <admin>
Lookup a task by id which is any value supported by toRecId().
(opts: Dict?) => Grid <admin>
List the current tasks as a grid. The format of this grid is subject to change.
() => Bool <admin>
Is the current context running asynchrounsly inside a task
(checked: Bool) => Dict? <admin>
Return current task if running within the context of an asynchronous task. If context is not within a task, then return null or raise an exception based on checked flag.
(expr: Obj?, msg: Dict?) => Future <admin>
Run the given expression asynchronously in an ephemeral task. Return a future to track the asynchronous result. Note the expr passed cannot use any variables from the current scope. See hx.task.
(task: Obj) => Dict <admin>
Restart a task. This kills the tasks and discards any pending messages in its queue. See hx.task.
(task: Obj) => Obj? <admin>
Set cancel flag for the given task. Cancelling a task sets an internal flag which is checked by the context's heartbeat on every Axon call. On the next Axon call the current message context will raise a CancelledErr which will be raised by the respective future. Cancelling a task does not interrupt any current operations, so any blocking future or I/O calls should always use a timeout.
(progress: Obj?) => Obj? <admin>
Update the current running task's progress data with given dict. This is a silent no-op if the current context is not running in a task.
Example:
// report progress percentage processing a list of records
recs.each((rec, index)=>do
taskProgress({percent: round(100%*index/recs.size), cur:rec.dis})
processRec(rec)
end)
taskProgress({percent:100%})
(task: Obj, msg: Obj?) => Future <admin>
Asynchronously send a message to the given task for processing. Return a future to track the asynchronous result. See hx.task.
(task: Obj, dur: Number, msg: Obj?) => Future <admin>
Schedule a message for delivery after the specified period of duration has elapsed. Once the period has elapsed the message is appended to the end of the task's queue. Return a future to track the asynchronous result. See hx.task.
(task: Obj, future: Future, msg: Obj?) => Future <admin>
Schedule a message for delivery after the given future has completed. Completion may be due to the future returning a result, throwing an exception, or cancellation. Return a future to track the asynchronous result. See hx.task.
(name: Str, def: Obj?) => Obj? <admin>
Get a task local variable by name or def if not defined. Must be running in a task context. See hx.task.
(name: Str, val: Obj?) => Obj? <admin>
Set a task local variable. The name must be a valid tag name. Must be running in a task context. See hx.task.
(name: Str) => Obj? <admin>
Remove a task local variable by name. Must be running in a task context. See hx.task.
(future: Future, timeout: Number?) => Obj? <admin>
Block current thread until a future's result is ready. A null timeout will block forever. If an exception was raised by the asynchronous computation, then it is raised to the caller. See hx.task.
(future: Future) => Obj? <admin>
Cancel a future. If the message is still queued then its removed from the actor's queue and will not be processed. No guarantee is made that the message will not be processed. See hx.task.
(future: Future) => Str <admin>
Return current state of a future as one of the following strings:
pending: still queued or being processedok: completed with result valueerr: completed with an exceptioncancelled: future was cancelled before processing See hx.task.
(future: Future) => Bool <admin>
Return if a future has completed or is still pending a result. A future is completed by any of the following conditions:
- the task processes the message and returns a result
- the task processes the message and raises an exception
- the future is cancelled See hx.task.
(future: Future, timeout: Number?) => Future <admin>
Block until a future transitions to a completed state (ok, err, or canceled). If timeout is null then block forever, otherwise raise a TimeoutErr if timeout elapses. Return future. See hx.task.
(futures: List, timeout: Number?) => List <admin>
Block on a list of futures until they all transition to a completed state. If timeout is null block forever, otherwise raise TimeoutErr if any one of the futures does not complete before the timeout elapses. See hx.task.
(dur: Number) => Obj? <admin>
Sleep for the given duration. If not currently running in a task this is a no-op. This will block the current task's thread and prevent other tasks from using it until the sleep completes. So this function should be used sparingly and with care.
() => Obj? <admin>
Refresh the user account used for tasks