Skip to main content

ServerHost

Struct ServerHost 

Source
pub struct ServerHost {
    pub config: Arc<LinksConfig>,
    pub link_service: Arc<dyn LinkService>,
    pub registry: Arc<LinkRouteRegistry>,
    pub entity_registry: EntityRegistry,
    pub entity_fetchers: Arc<HashMap<String, Arc<dyn EntityFetcher>>>,
    pub entity_creators: Arc<HashMap<String, Arc<dyn EntityCreator>>>,
    pub event_bus: Option<Arc<EventBus>>,
    pub event_log: Option<Arc<dyn EventLog>>,
    pub sink_registry: Option<Arc<SinkRegistry>>,
    pub notification_store: Option<Arc<NotificationStore>>,
    pub device_token_store: Option<Arc<DeviceTokenStore>>,
    pub preferences_store: Option<Arc<NotificationPreferencesStore>>,
}
Expand description

Host context containing all framework state

This structure is transport-agnostic and contains all the information needed to expose the API via any protocol (REST, GraphQL, gRPC, etc.)

§Example

let host = ServerHost::from_builder_components(
    link_service,
    config,
    entity_registry,
    fetchers,
    creators,
)?;

// Use host with any exposure
let host_arc = Arc::new(host);
let rest_app = RestExposure::build_router(host_arc.clone())?;
let graphql_app = GraphQLExposure::build_router(host_arc)?;

Fields§

§config: Arc<LinksConfig>

Merged configuration from all modules

§link_service: Arc<dyn LinkService>

Link service for relationship management

§registry: Arc<LinkRouteRegistry>

Link route registry for semantic URL resolution

§entity_registry: EntityRegistry

Entity registry for CRUD routes

§entity_fetchers: Arc<HashMap<String, Arc<dyn EntityFetcher>>>

Entity fetchers map (for link enrichment)

§entity_creators: Arc<HashMap<String, Arc<dyn EntityCreator>>>

Entity creators map (for automatic entity + link creation)

§event_bus: Option<Arc<EventBus>>

Optional event bus for real-time notifications (WebSocket, SSE)

When present, REST/GraphQL handlers will publish events for mutations. WebSocket and other real-time exposures subscribe to this bus.

§event_log: Option<Arc<dyn EventLog>>

Optional persistent event log for durable event storage

When present, the EventBus bridges events to this log for replay, consumer groups, and FlowRuntime processing.

§sink_registry: Option<Arc<SinkRegistry>>

Optional sink registry for event delivery pipelines

Contains all registered sinks (in_app, push, webhook, websocket, counter). The FlowRuntime’s deliver operator uses this to dispatch payloads.

§notification_store: Option<Arc<NotificationStore>>

Optional in-app notification store

Provides list, mark_as_read, unread_count operations for notifications. Used by REST/GraphQL/gRPC notification endpoints.

§device_token_store: Option<Arc<DeviceTokenStore>>

Optional device token store for push notifications

Stores push notification tokens (Expo, APNs, FCM) per user. Used by the push notification sink and device token endpoints.

§preferences_store: Option<Arc<NotificationPreferencesStore>>

Optional notification preferences store

Stores per-user notification preferences (mute, disable types). Used by sinks to filter notifications and by preference endpoints.

Implementations§

Source§

impl ServerHost

Source

pub fn from_builder_components( link_service: Arc<dyn LinkService>, config: LinksConfig, entity_registry: EntityRegistry, fetchers: HashMap<String, Arc<dyn EntityFetcher>>, creators: HashMap<String, Arc<dyn EntityCreator>>, ) -> Result<Self>

Build the host from builder components

This method takes all the components that have been registered with the builder and constructs the host structure.

§Arguments
  • link_service - The link service for relationship management
  • config - Merged configuration from all modules
  • entity_registry - Registry of all entity descriptors
  • fetchers - Map of entity type to fetcher implementation
  • creators - Map of entity type to creator implementation
§Returns

Returns a ServerHost ready to be used with any exposure (REST, GraphQL, gRPC, etc.)

Source

pub fn entity_types(&self) -> Vec<&str>

Get entity types registered in the host

Source

pub fn is_ready(&self) -> bool

Check if host is properly initialized

Source

pub fn with_event_bus(self, event_bus: EventBus) -> Self

Set the event bus for real-time notifications

Source

pub fn event_bus(&self) -> Option<&Arc<EventBus>>

Get a reference to the event bus (if configured)

Source

pub fn with_event_log(self, event_log: Arc<dyn EventLog>) -> Self

Set the persistent event log

Source

pub fn event_log(&self) -> Option<&Arc<dyn EventLog>>

Get a reference to the event log (if configured)

Source

pub fn with_sink_registry(self, registry: SinkRegistry) -> Self

Set the sink registry

Source

pub fn sink_registry(&self) -> Option<&Arc<SinkRegistry>>

Get a reference to the sink registry (if configured)

Source

pub fn with_notification_store(self, store: Arc<NotificationStore>) -> Self

Set the notification store

Source

pub fn notification_store(&self) -> Option<&Arc<NotificationStore>>

Get a reference to the notification store (if configured)

Source

pub fn with_device_token_store(self, store: Arc<DeviceTokenStore>) -> Self

Set the device token store

Source

pub fn device_token_store(&self) -> Option<&Arc<DeviceTokenStore>>

Get a reference to the device token store (if configured)

Source

pub fn with_preferences_store( self, store: Arc<NotificationPreferencesStore>, ) -> Self

Set the notification preferences store

Source

pub fn preferences_store(&self) -> Option<&Arc<NotificationPreferencesStore>>

Get a reference to the notification preferences store (if configured)

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,