Skip to main content

GCGatewayController

Struct GCGatewayController 

pub struct GCGatewayController {
    realtime_db: GCArcRealtimeDatabase,
    message_broker: RwLock<GCMessageBroker>,
    plugin_manager: RwLock<GCPluginManager<PluginInstanceHandler>>,
    config_db: RwLock<GCConfigDatabase>,
    device_config_manager: DeviceConfigManager,
    broker_publisher: GCMessagePublisher,
    timeseries: Mutex<GCTimeseriesConnection>,
}
Expand description

The gateway controller manages the entire gateway and can be used to interact with the different components Any changes to the system should be done through this interface.

It is important to note that the concurrent message is not automatically started, the user must call the GCGatewayController::start_async_broker method

TODO: Make negations tests

Fields§

§realtime_db: GCArcRealtimeDatabase§message_broker: RwLock<GCMessageBroker>§plugin_manager: RwLock<GCPluginManager<PluginInstanceHandler>>§config_db: RwLock<GCConfigDatabase>§device_config_manager: DeviceConfigManager§broker_publisher: GCMessagePublisher§timeseries: Mutex<GCTimeseriesConnection>

Implementations§

§

impl GCGatewayController

pub(crate) fn new( realtime_db: GCArcRealtimeDatabase, message_broker: GCMessageBroker, plugin_manager: GCPluginManager<PluginInstanceHandler>, config_db: GCConfigDatabase, timeseries: GCTimeseriesConnection, ) -> Self

Creates a new instance of the gateway controller

The caller is responsible for ensuring the different components are synced between each other, if this is not true may lead to inconsistences (eg: a plugin instance being loaded with a wrong configuration)

pub fn timeseries_ref(&self) -> MutexGuard<'_, GCTimeseriesConnection>

pub fn get_config_db(&self) -> RwLockReadGuard<'_, GCConfigDatabase>

Retrieve the config database, responsible for storing plugins config and datapoint information

pub fn get_message_broker(&self) -> RwLockReadGuard<'_, GCMessageBroker>

Retrieve the message broker, responsible for managing the messaging pipelines

pub fn get_plugin_manager( &self, ) -> RwLockReadGuard<'_, GCPluginManager<PluginInstanceHandler>>

Retrieve plugin manager, responsible for managing the plugin system

pub fn poll_timeseries(&self)

Flushes the buffered datapoint values to the timeseries database

Trait Implementations§

§

impl GCGatewayInterface for GCGatewayController

§

fn add_plugin_instance( &self, instance_name: &str, plugin_path: &str, instance_config: GCControllerPluginInstanceConfig, ) -> Result<(), GCGatewayError>

TODO: This function will load any DLL specified in the plugin_path, this is a security risk and should be changed

§

fn get_buffered_values<T: for<'a> TryFrom<&'a GCDatapointValue>>( &self, dp_names: impl Iterator<Item = GCDatapointID>, ) -> HashMap<String, Vec<T>>

The intermediate copy is not needed.

§

fn start_async_broker(&self)

Starts the concurrent message broker.
§

fn start_plugin(&self, plugin_instance_name: &str) -> Result<(), GCGatewayError>

Starts a plugin instance that is not yet running. Read more
§

fn start_all_plugins(&self) -> Vec<String>

Starts all plugin instances that are not yet running. Returns a list of all plugins that were started successfully. If a plugin fails to start, it will not prevent other plugins from starting.
§

fn register_plugin_publisher( &self, plugin_instance_name: &str, datapoint_id: GCDatapointID, ) -> Result<(), GCGatewayError>

Registers a plugin instance as a publisher to a datapoint. This will only be visible to the plugin after it is restarted.
§

fn register_plugin_subscriber( &self, plugin_instance_name: &str, datapoint_id: GCDatapointID, concurrent: bool, ) -> Result<(), GCGatewayError>

Registers a plugin instance as a subscriber to a datapoint. The plugin may start receiving new datapoint values immediately but will not be able to see the datapoint in the interface once it is restarted. If concurrent is set to true, the plugin will be registered as a concurrent aka async subscriber.
§

fn update_datapoint( &self, datapoint_id: GCDatapointID, metadata: GCDatapointMetadata, ) -> Result<Vec<String>, GCGatewayError>

Updates the metadata of a datapoint that already exists. Plugins that are subscribed or published to this datapoint will be returned. The plugins will only be able to see the new metadata after they are restarted. Read more
§

fn add_datapoint( &self, datapoint_id: GCDatapointID, metadata: GCDatapointMetadata, ) -> Result<(), GCGatewayError>

Adds a new datapoint. If the datapoint already exists, returns an error.
§

fn remove_datapoint( &self, datapoint_id: GCDatapointID, ) -> Result<(), GCGatewayError>

Removes a datapoint. If the datapoint does not exist, an error will NOT be returned. This will have the following effects: Read more
§

fn remove_plugin_instance( &self, plugin_instance_name: &str, ) -> Result<(), GCGatewayError>

Remove a plugin instance. If the plugin instance is running, it will be stopped before being deleted.
§

fn publish_datapoint(&self, dpv: GCDatapointValue) -> Result<(), GCGatewayError>

Publishes a value to a datapoint. Prefer using get_broker_publisher for frequent datapoint values.
§

fn get_datapoints_info<T: Iterator<Item = GCDatapointID>>( &self, datapoint_ids: Option<T>, ) -> Vec<(GCDatapointID, GCDatapointConfig)>

Gets the list of datapoints that exist in the database.
§

fn get_plugins_info(&self) -> Vec<GCPluginInstanceInfo>

Gets the list of plugin instances that exist in the database.
§

fn stop_plugin_instance( &self, plugin_instance_name: &str, ) -> Result<(), GCGatewayError>

Stops a plugin instance that is running.
§

fn update_plugin_instance( &self, plugin_instance_name: &str, config: GCControllerPluginInstanceConfig, ) -> Result<(), GCGatewayError>

Updates a plugin instance’s configuration. Read more
§

fn unregister_publisher( &self, plugin_instance_name: &str, datapoint_id: GCDatapointID, ) -> bool

Unregister a plugin instance as a publisher to a datapoint. If the plugin is not registered as a publisher, this method returns false
§

fn unregister_subscriber( &self, plugin_instance_name: &GCSubscriberIdentifier, datapoint_id: GCDatapointID, ) -> bool

Unregister a plugin instance as a subscriber to a datapoint. If the plugin is not registered as a subscriber, this method returns false
§

fn get_latest_values<T: for<'a> TryFrom<(String, &'a GCDatapointValue)>>( &self, dp_ids: impl Iterator<Item = GCDatapointID>, ) -> Vec<T>

Get latest datapoint values
§

fn upsert_runtime_subscription<T: Iterator<Item = GCDatapointID>>( &self, subscriber: Arc<dyn GCDatapointSubscriber>, datapoint_ids: T, )

Adds a new subscription, subscriptions added through this method are not registered in the configuration metadata. Thus, are not returned by the get_datapoints_info method. Read more
§

fn remove_runtime_subscription( &self, subscriber_id: GCSubscriberIdentifier, datapoint_ids: &[GCDatapointID], )

Removes a subscription by id Read more
§

fn get_broker_publisher(&self) -> GCMessagePublisher

Returns the message broker publisher used by the controller.
§

fn set_device_config(&self, config: DeviceConfig) -> Result<(), GCGatewayError>

Sets the device configuration for the runtime. This configuration will be stored and applied to the OS.
§

impl Send for GCGatewayController

§

impl Sync for GCGatewayController

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V