ark::pipeline::Publisher

Defined in header “ark/pipeline/forward.hh”.


A publisher is a class that allows you to send an object through the pipeline, to all of the connected subscribers. It is the primary means of communication through a pipeline.

Different executors will handle message delivery in different ways. There are no guarantees made on if data will be delivered or not. There is no publisher-level buffering of data; each subscriber is responsible for its own buffers/queues.

Typedefs

  • using TypePtr = std::shared_ptr< const Type >
    The type of data being used.

Methods

  • Publisher(std::string channel_name)
    Constructor. Initializes a publisher with the given channel name.

  • Publisher(std::string channel_name, TimeProviderPtr time_provider, uint64_t publisher_identifier)
    Constructor. Initializes a publisher with the given channel name, time provider, and identifier. The identifier is expected to be unique and is used to disambiguate publishers with the same name but coming from different stages.

  • bool connect(EnvelopeCarrierPtr subscriber)
    Connects a subscriber to this publisher. Any message published through this publisher will be sent to this subscriber.

    Returns true if the subscriber was connected, false if it was already connected. Throws if there is a type or name mismatch.

  • std::string message_schema_protocol()
    Returns the message schema protocol (rbuf, proto, etc) of the object that flows over this subscriber.

  • const std::type_info & message_type()
    Returns type information about the messages that flow through this publisher.

  • std::string message_type_name()
    Returns the message type name of the object that flows over this publisher.

  • std::string message_schema_registry()
    Returns the schema for the object that flows over this publisher, if available.

  • bool message_is_serializable()
    Returns true if the message type for this subscriber is serializable.

  • void push(Type message)
    Pushes a message onto all of the current connected subscribers. This message must be movable; it will be moved into a shared_ptr and pushed through the rest of the stack.

    To avoid the move and shared_ptr, consider populating your message into a shared_ptr ahead of time.

  • void emplace(Type && message)
    Pushes a message onto the current connected subscribers. This will automatically move the message into a shared_ptr and can save a copy.

    Similar to push(), to avoid the move and shared_ptr allocation altogether, consider populating your message into a shared_ptr ahead of time.

  • void push(TypePtr message)
    Pushes a message onto all of the currently connected subscribers. How this is handled (if a subscriber immediately executes or delays) is determined by the executor you are running.

  • void shutdown()
    Shuts the publisher down, clearing all internal state and references to subscribers.

  • PublisherStatistics statistics()
    Returns statistics related to this publisher.