Skip to main content

GCMessageBrokerBuilder

Struct GCMessageBrokerBuilder 

pub struct GCMessageBrokerBuilder {
    datapoint_mapping: DatapointMapping,
    queue_size: usize,
    concurrent_threads: u16,
    channel_is_blocking_mode_default: bool,
}
Expand description

Builder for the GCMessageBroker. This builder allows the user to configure the broker with the desired options. Every subscriber should be registered before building the broker, this ensures the list of subscribers is immutable providing higher performance and reducing asynchronous complexity.

Fields§

§datapoint_mapping: DatapointMapping§queue_size: usize§concurrent_threads: u16§channel_is_blocking_mode_default: bool

Implementations§

§

impl GCMessageBrokerBuilder

pub fn new() -> Self

pub fn set_concurrent_queue_size(&mut self, queue_size: usize) -> &mut Self

Sets the size of the channel queue that holds the messages to be sent to the concurrent subscribers.

pub fn set_concurrent_threads(&mut self, sub_thread_count: u16) -> &mut Self

Sets the number of threads that will be used to send the messages to the concurrent subscribers.

pub fn register_concurrent_broadcast( &mut self, subscriber: Arc<dyn GCDatapointSubscriber>, ) -> &mut Self

Register a subscriber that will be registered to all datapoints concurrently.

pub fn register_sequential_broadcast( &mut self, subscriber: Arc<dyn GCDatapointSubscriber>, ) -> &mut Self

Register a subscriber that will be registered to all datapoints sequentially.

pub fn set_concurrent_blocking(&mut self, is_blocking: bool) -> &mut Self

Set concurrent blocking mode If set to true, the publisher will block whenever the concurrent runtime channel is full, this ensures that messages are not lost, but it may slow down the publisher. By default is set to false (non-blocking) and whenever the channel is full, new messages will be dropped. TODO: Implement a way to drop the oldest messages instead of the newest.

pub fn register_concurrent_subscriber( &mut self, subscriber: Arc<dyn GCDatapointSubscriber>, datapoint_id: GCDatapointID, ) -> Result<(), GCMessageBrokerError>

TODO: Remove this method and use add_concurrent_subscriber from the broker

pub fn register_sequential_subscriber( &mut self, subscriber: Arc<dyn GCDatapointSubscriber>, datapoint_id: GCDatapointID, ) -> Result<(), GCMessageBrokerError>

TODO: Remove this method and use add_sequential_subscriber from the broker

pub fn build(self) -> GCMessageBroker

Builds the GCMessageBroker with the given configuration.

Trait Implementations§

§

impl Default for GCMessageBrokerBuilder

§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.