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: EntityRegistryEntity 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
impl ServerHost
Sourcepub 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>
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 managementconfig- Merged configuration from all modulesentity_registry- Registry of all entity descriptorsfetchers- Map of entity type to fetcher implementationcreators- Map of entity type to creator implementation
§Returns
Returns a ServerHost ready to be used with any exposure (REST, GraphQL, gRPC, etc.)
Sourcepub fn entity_types(&self) -> Vec<&str>
pub fn entity_types(&self) -> Vec<&str>
Get entity types registered in the host
Sourcepub fn with_event_bus(self, event_bus: EventBus) -> Self
pub fn with_event_bus(self, event_bus: EventBus) -> Self
Set the event bus for real-time notifications
Sourcepub fn event_bus(&self) -> Option<&Arc<EventBus>>
pub fn event_bus(&self) -> Option<&Arc<EventBus>>
Get a reference to the event bus (if configured)
Sourcepub fn with_event_log(self, event_log: Arc<dyn EventLog>) -> Self
pub fn with_event_log(self, event_log: Arc<dyn EventLog>) -> Self
Set the persistent event log
Sourcepub fn event_log(&self) -> Option<&Arc<dyn EventLog>>
pub fn event_log(&self) -> Option<&Arc<dyn EventLog>>
Get a reference to the event log (if configured)
Sourcepub fn with_sink_registry(self, registry: SinkRegistry) -> Self
pub fn with_sink_registry(self, registry: SinkRegistry) -> Self
Set the sink registry
Sourcepub fn sink_registry(&self) -> Option<&Arc<SinkRegistry>>
pub fn sink_registry(&self) -> Option<&Arc<SinkRegistry>>
Get a reference to the sink registry (if configured)
Sourcepub fn with_notification_store(self, store: Arc<NotificationStore>) -> Self
pub fn with_notification_store(self, store: Arc<NotificationStore>) -> Self
Set the notification store
Sourcepub fn notification_store(&self) -> Option<&Arc<NotificationStore>>
pub fn notification_store(&self) -> Option<&Arc<NotificationStore>>
Get a reference to the notification store (if configured)
Sourcepub fn with_device_token_store(self, store: Arc<DeviceTokenStore>) -> Self
pub fn with_device_token_store(self, store: Arc<DeviceTokenStore>) -> Self
Set the device token store
Sourcepub fn device_token_store(&self) -> Option<&Arc<DeviceTokenStore>>
pub fn device_token_store(&self) -> Option<&Arc<DeviceTokenStore>>
Get a reference to the device token store (if configured)
Sourcepub fn with_preferences_store(
self,
store: Arc<NotificationPreferencesStore>,
) -> Self
pub fn with_preferences_store( self, store: Arc<NotificationPreferencesStore>, ) -> Self
Set the notification preferences store
Sourcepub fn preferences_store(&self) -> Option<&Arc<NotificationPreferencesStore>>
pub fn preferences_store(&self) -> Option<&Arc<NotificationPreferencesStore>>
Get a reference to the notification preferences store (if configured)