pub struct RoutingTable { /* private fields */ }hub only.Expand description
The hub’s map from party to platform.
A hub’s whole job is answering “who is NL/TNM, and can I reach them right now?”, and turning
a “no” into the right one of the four 4xxx codes:
| Code | Meaning |
|---|---|
4001 | Unknown receiver: the OCPI-to-* address is unknown |
4002 | Timeout on a forwarded request |
4003 | Connection problem: the receiving party is not connected |
4000 | Anything else |
Spec: 2.3.0 §status_codes_4xxx_hub_errors
Implementations§
Source§impl RoutingTable
impl RoutingTable
Sourcepub fn upsert(&self, platform: ConnectedPlatform)
pub fn upsert(&self, platform: ConnectedPlatform)
Adds or replaces a platform.
Sourcepub fn set_status(&self, platform_id: &str, status: ConnectionStatus) -> bool
pub fn set_status(&self, platform_id: &str, status: ConnectionStatus) -> bool
Records a platform’s connection status, which the hubclientinfo module publishes.
Sourcepub fn with_platform<T>(
&self,
party: &PartyRef,
f: impl FnOnce(&ConnectedPlatform) -> T,
) -> Result<T, OcpiError>
pub fn with_platform<T>( &self, party: &PartyRef, f: impl FnOnce(&ConnectedPlatform) -> T, ) -> Result<T, OcpiError>
Runs f over the platform hosting party.
§Errors
Returns 4001 Unknown receiver when no platform hosts the party, and 4003 Connection problem when the platform is known but not connected.
Sourcepub fn knows(&self, party: &PartyRef) -> bool
pub fn knows(&self, party: &PartyRef) -> bool
Whether the hub knows party at all, connected or not.
Sourcepub fn platform_of(&self, party: &PartyRef) -> Option<String>
pub fn platform_of(&self, party: &PartyRef) -> Option<String>
The platform id hosting party.
Sourcepub fn broadcast_targets(
&self,
sender: &PartyRef,
sender_role: Role,
module: &ModuleId,
) -> Vec<(String, PartyRef)>
pub fn broadcast_targets( &self, sender: &PartyRef, sender_role: Role, module: &ModuleId, ) -> Vec<(String, PartyRef)>
The parties a Broadcast Push from sender should reach for module.
For simplicity, connected clients might push (POST, PUT, PATCH) information to all connected clients with an “opposite role” … When using Broadcast Push, the Hub broadcasts received information to all connected clients … using its own party-id and country-code in the ‘OCPI-from-’ headers.
A party is a recipient when it is connected, fills a role that receives from the sender’s role, implements the module’s Receiver interface, and is not the sender itself.
Spec: 2.3.0 §transport_and_format_message_routing_broadcast_push
Sourcepub fn get_all_sources(
&self,
requester: &PartyRef,
module: &ModuleId,
) -> Vec<(String, PartyRef)>
pub fn get_all_sources( &self, requester: &PartyRef, module: &ModuleId, ) -> Vec<(String, PartyRef)>
Every party that implements a module’s Sender interface, for a GET All.
A client (Receiver) can request a GET on the Sender interface of a module implemented by a Hub. The Hub can then combine objects from different connected parties.
Spec: 2.3.0 §transport_and_format_get_all_via_hubs
Sourcepub fn platform_ids(&self) -> Vec<String>
pub fn platform_ids(&self) -> Vec<String>
Every platform the hub knows, connected or not.
Sourcepub fn client_info(&self) -> Vec<(PartyRef, Role, ConnectionStatus)>
pub fn client_info(&self) -> Vec<(PartyRef, Role, ConnectionStatus)>
Every party the hub knows, with its role and connection status.
This is what the hubclientinfo module publishes.