CrossClj

0.5.6 docs

SourceDocs



RECENT
    VARS
    ->Channel
    ->SplicedChannel
    bridge
    bridge-join
    bridge-siphon
    cancel-callback
    channel
    channel*
    channel?
    close
    closed-channel
    closed-result
    closed?
    connect
    drained-result
    drained?
    emitter-node
    error-value
    filter*
    force-close
    fork
    ground
    grounded-channel
    join
    map*
    mimic
    on-closed
    on-drained
    on-error
    read-channel
    read-channel*
    receive
    receive-all
    receiver-node
    remove*
    sink
    siphon
    splice
    split
    split-receiver
    tap
    transactional?

    « Index of all namespaces of this project

    (->Channel receiver emitter metadata)
    Positional factory function for class lamina.core.channel.Channel.
    
    (->SplicedChannel receiver emitter metadata)
    Positional factory function for class lamina.core.channel.SplicedChannel.
    
    (bridge src dsts callback {:keys [description upstream? downstream?], :or {upstream? true, downstream? true}, :as options})
    A generalization of bridge-join and bridge-siphon.  Takes one src channel, and one or
    more downstream dsts channels.  All messages from src will be passed into callback, which
    may or may not forward it to the downstream channels.
    
    This represents a relationship between channels which may or may not always result in messages
    propagating downstream.  This can be useful when certain channels are only used for specific
    types of messages, or there is an accumulation of messages, or anything else that is more complex
    than receive -> emit.
    (bridge-join src dst description callback)
    A bridge between one src and one dst channel which is bidirectional.
    
    (bridge-siphon src dst description callback)
    A bridge between one src and one dst channel only propagates closing upstream.
    
    (cancel-callback channel callback)
    Cancels a callback registered with receive, receive-all, on-closed, on-drained, or on-error.
    
    (channel & messages)
    Returns a channel containing the given messages.
    
    macro
    (channel* & {:keys [grounded? permanent? transactional? messages description meta], :as options})
    A general-purpose channel creator.  Can be used to mix and match various properties, such as
    
    (channel* :grounded? true, :description "my very own grounded channel")
    
    :grounded?        - ensures that messages cannot accumulate in the queue
    :permanent?       - ensures that the channel cannot be closed or be put in an error state
    :transactional?   - determines whether the channel's queue is transactional
    :messages         - sequence of zero or more messages that will be in the channel's queue
    :description      - a string that will be diplayed in channel visualizations
    :meta             - initial metadata
    (channel? x)
    Returns true if x is a channel.  This does not encompass result-channels.
    
    (close channel)
    Closes the channel. Returns if successful, false if channel is permanent, already closed,
    or in an error state.
    (closed-channel & messages)
    Returns a closed channel containing the given messages.
    
    (closed-result channel)
    Returns a result-channel that will emit a result when channel is closed, or emit an error
    if channel goes into an error state.
    (closed? channel)
    Returns true if channel is closed, false otherwise. 
    
    (connect src dst upstream? downstream?)
    A generalization of siphon and join, making sure that all messages in src will be forwarded
    to dst.
    
    If upstream? is true, when dst is closed, src will be closed.  This is true for siphon and join.
    
    If downstream? is true, when src is closed, dst will be closed.  This is true for join.
    
    The same behavior is also used for propagating error states.
    (drained-result channel)
    Returns a result-channel that will emit a result when channel is drained, or emit an error
    if channel goes into an error state.
    (drained? channel)
    Returns true if channel is drained, false otherwise.
    
    (emitter-node _)
    Returns the emitter node for the channel.
    
    (error-value channel default-value)
    Returns the error value of channel, returning 'default-value' if it's not an error state.
    
    (filter* f channel)
    A dual to filter.
    
    (filter* odd? (channel 1 2 3)) => [1 3]
    (force-close channel)
    Closes channel, even if it is permanent. Returns if successful, false if channel is
    already closed or in an error state.
    (fork channel)
    Returns a channel which is an exact duplicate of the source channel, containing all messages
    in the source channel's queue, and emitting all messages emitted by the source channel.
    
    If the forked channel is closed, the source channel is unaffected.  However, if the source
    channel is closed all forked channels are closed.  Similar propagation rules apply to error
    states.
    (ground ch)
    Ensures that messages will not accumulate in the channel's queue.
    
    (grounded-channel)
    Returns a channel that cannot accumulate messages.
    
    (join src dst)
    (map* f channel)
    A dual to map.
    
    (map* inc (channel 1 2 3)) => [2 3 4]
    (mimic channel)
    (on-closed channel callback)
    Registers a callback that will be invoked with no arguments when channel is closed, or
    immediately if it has already been closed.  callback will only be invoked once, and can
    be cancelled using cancel-callback.
    (on-drained channel callback)
    Registers a callback that will be invoked with no arguments when channel is drained, or
    immediately if it has already been drained.  callback will only be invoked once, and can
    be cancelled using cancel-callback.
    (on-error channel callback)
    Registers a callback that will be called with the error when channel enters an error state,
    or immediately if it's already in an error state.  callback will only be invoked once,
    and can be cancelled using cancel-callback.
    (read-channel channel)
    Returns a result-channel representing the next message from the channel.  Only one
    result-channel can represent any given message; calling `(read-channel ...)` multiple times
    will always consume multiple messages.
    
    Enqueueing a value into the result-channel before it is realized will prevent the message
    from being consumed, effectively cancelling the read-channel call.
    macro
    (read-channel* ch & {:keys [timeout predicate result listener-result on-timeout on-error on-false task-queue], :as options})
    A variant of read-channel with more options.
    
    :timeout - the timeout, in milliseconds.  If this elapses, the next message will not be consumed.
    
    :predicate - a function that takes the message, and returns true if it should be consumed.  If the
                   predicate returns false, the returned result will realize as value defined by :on-false.
    
    :result - the result that the read message should be enqueued into.  If the same result is used for
                read-channel calls from multiple channels, this will have the effect of being realized
                as the first message from any of the channels, and not consuming any messages from the other
                channels.
    
     :listener-result - the result that will be returned to the emitter of the message, representing the
                          outcome of the consumption.  This should only be done if there is a clear single
                          outcome for this message (i.e. we're not just accumulating the entire stream.)
    
     :on-timeout - the result that will be realized if we timed out.  If not specified, the result will be
                     realized as a :lamina/timeout error.
    
      :on-error - the result that will be realized if the channel is in an error state.  If not specified,
                    the result will be realized as the channel's error.
    
      :on-false - the result that will be realized if the :predicate returns false.  Defaults to :lamina/false.
    (receive channel callback)
    Registers a callback that will be invoked with the next message enqueued into the channel, or
    the first message already in the queue.  Only one callback can consume any given message;
    registering multiple callbacks will consume multiple messages.
    
    This can be cancelled using cancel-callback.
    (receive-all channel callback)
    Registers a callback that will consume all messages currently in the queue, and all
    subsequent messages that are enqueued into channel.
    
    This can be cancelled using cancel-callback.
    (receiver-node _)
    Returns the receiver node for the channel.
    
    (remove* f channel)
    A dual to remove.
    
    (remove* even? (channel 2 3 4)) => [3]
    (sink callback)
    Creates a channel which will forward all messages to callback.
    
    (siphon src dst)
    (splice emitter receiver)
    Returns a channel where all messages are enqueud into receiver, and
    consumed from emitter.
    Private
    (split ch description sneaky?)
    (split-receiver _)
    Ensures the receiver and emitter are split, and returns the emitter.
    
    (tap channel)
    Behaves like fork, except that the source channel will not remain open if only the tap
    exists downstream.
    
    If the tap channel is closed, the source channel is unaffected.  However, if the source
    channel is closed all tap channels are closed.  Similar propagation rules apply to error
    states.
    (transactional? channel)
    Returns true if channel has a transactional queue, false otherwise.