CrossClj

0.3.1 docs

SourceDocs



RECENT
    VARS
    ->Operation
    Control
    default-init-event-handler
    default-primitive-fsm
    delay-for
    do-nothing-event-handler
    dofsm
    eval-in-env-fn
    execute
    execute-after
    fail
    get-op-state
    kill-except
    locals-map
    map*
    merge-fsms
    next-step
    op-compute-service-key
    op-env-key
    op-fsm-machines-key
    op-overall-result-key
    op-promise-key
    op-result-fn-key
    op-state-stack-depth
    op-state-stack-key
    op-steps-key
    op-timeouts-key
    op-todo-steps-key
    operate
    operate-executor
    operate-machine-config
    operate-on-completed
    operate-on-failed
    pop-op-state
    push
    push-op-state
    reduce*
    report-exceptions
    report-operation
    report-operation-state
    result
    run-step
    sanitise-history
    scheduled-executor
    seq-fsm
    seq-init
    seq-on-step-completed
    seq-on-step-failed
    seq-running
    seq-step-completed
    seq-step-failed
    seq-steps
    set-in-env-fn
    step-fsm
    succeed
    symbols
    timeout
    update-state
    wire-step-fsm

    « Index of all namespaces of this project

    Operations
    
    Operate provides orchestration. It assumes that operations can succeed, fail,
    time-out or be aborted. It assumes some things happen in parallel, and that some
    things need to be sequenced.
    
    
    ## Operation primitive FSM contract
    
    An operation primitive must produce a FSM specification.
    
    The FSM must respond to the :start event in it's initial state. The event data
    sent with the :start event will be the current global state. The default initial
    state is :init. The default response for the :start event in the :init state is
    to set the primitive's :state-data to the global state, and to transition to
    the :running state.
    
    The FSM must have a :completed and a :failed state.
    
    It must respond to the :abort event, which is sent on a user initiated abort
    of an operation. The :abort event should cause the FSM to end in the :aborted
    state.
    
    The :init, :completed, :aborted and :failed states will be implicitly added if
    not declared.
    
    The result should be placed on the :result key of the state-data.
    
    A failure reason should be placed on the :fail-reason key of the state-data.
    
    State event functions (on-enter and on-exit) should return true if they do
    anything to change the state of the FSM, and further event functions should not
    be called for the transition.
    
    
    ## The operation FSM comprehension
    
    An expression under the operation FSM comprehension results in a compound
    FSM. It is returned as a function, that takes a state, and returns a map of
    functions to control the resulting FSM.
    (->Operation fsm completed-promise)
    Positional factory function for class pallet.algo.fsmop.Operation.
    
    protocol
    Operation control protocol.
    
    (abort _)
    Abort the operation.
    
    (complete? _)
    Predicate to test if operation is complete.  Returns false if
    the operation failed with an error, true if the operation succeeded, or nil
    otherwise
    (fail-reason _)
    Returns the reported failure reason.
    
    (failed? _)
    Predicate to test if operation is failed.  Returns false if the operation
    completed without error, true if the operation failed, or nil otherwise.
    (running? _)
    Predicate to test if the operation is running.
    
    (status _)
    Return the status of the operation.
    
    (wait-for _)(wait-for _ timeout-ms timeout-val)
    wait on the result of the completed operation
    
    (default-init-event-handler state event event-data)
    Default event handler for the :init state
    
    Private
    Base FSM for primitive FSM.
    
    (delay-for delay delay-units)
    An operation primitive that does nothing for the given delay. This uses the
    stateful-fsm's timeout mechanism. Not the timeout primitive. The primitive
    transitions to :completed after the given delay.
    (do-nothing-event-handler state _ _)
    macro
    (dofsm op-name steps result)
    A comprehension that results in a compound FSM specification.
    
    (eval-in-env-fn form syms)
    Give a form, return a function of a single env argument and that evaluates
    the form in the given environment.
    (execute f)
    Execute a function in the operate-executor thread pool.
    
    (execute-after f delay delay-units)
    Execute a function after a specified delay in the scheduled-executor thread
    pool. Returns a ScheduledFuture.
    (fail reason)(fail)
    An operation primitive that does nothing but fail immediately.
    
    (get-op-state state)
    Get the current op-state map off the ::opt-state key in the FSM's state
    map.
    (kill-except &env & locals)
    macro
    (locals-map)
    (map* fsm-configs)
    Execute a set of fsms
    
    (merge-fsms & fsm-configs)
    Merge operation primitve FSM's.
    
    Private
    (next-step state)
    Return the next primitive to be executed in the operation.
    
    (op-state-stack-depth state)
    op-state stack depth
    
    (operate operation)
    Start the specified operation on the given arguments. The call returns an
    object that implements the Control protocol.
    Private
    (operate-on-completed {:keys [state-kw], :as state})
    on-enter function for completed state.
    
    Private
    (operate-on-failed {:keys [state-kw], :as state})
    on-enter function for failed and aborted states.
    
    (pop-op-state state)
    Pop a op-state map off the ::opt-state key in the FSM's state map.
    
    (push stack v)
    Push a value onto a stack, using a vector if the stack is nil.
    
    (push-op-state state op-state)
    Push a new op-state map onto the ::opt-state key in the FSM's state map.
    
    (reduce* f init-value s)
    A reduce function where the passed reducing function f should return a FSM
    configuration, whose result when executed, will be passed to the next call of
    the reducing function.
    (report-exceptions f)
    (report-operation operation & {:keys [env steps history], :as options})
    Print a report on the status of an operation.
    
    Private
    (report-operation-state state op-state indent {:keys [env steps history history-results], :as options})
    (result value)
    An operation primitive that does nothing but succeed immediately with the
    specified result value.
    Private
    (run-step {:keys [state-data], :as state} {:keys [result-f], :as step})
    Run an operation step based on the operation primitive.
    
    (sanitise-history {:keys [env steps history history-results], :as options} h)
    (seq-fsm op-name {:keys [steps result-f]} initial-env)
    Private
    (seq-init state event event-data)
    Private
    (seq-on-step-completed state)
    Private
    (seq-on-step-failed state)
    Private
    (seq-running state event event-data)
    Private
    (seq-step-completed state event event-data)
    Private
    (seq-step-failed state event event-data)
    (seq-steps steps result &env)
    Takes FSM comprehension forms and translates them
    
    (set-in-env-fn expr &env)
    Give an expression that is a valid lhs in a binding, return a function of an
    env argument and a value that assigns the results of destructuring into
    env.
    Private
    (step-fsm environment {:keys [f], :as step})
    Generate a fsm for an operation step.
    
    (succeed flag fail-reason)(succeed flag)(succeed)
    An operation primitive that does nothing but succeed or fail immediately
    based on the passed flag. The default is to succeed.
    (symbols form)
    (timeout fsm-config delay delay-units)
    Execute an expression with a timeout. The timeout is applied to each
    state. Any transition out of a state will cancel the timeout.
    (update-state state state-kw f & args)
    Convenience update function.
    
    Private
    (wire-step-fsm {:keys [event], :as op-fsm} step-fsm)
    Wire a fsm configuration to the controlling fsm.