pub struct Forwarder<'a> { /* private fields */ }hub only.Expand description
Relays requests to the platforms in a RoutingTable.
Implementations§
Source§impl<'a> Forwarder<'a>
impl<'a> Forwarder<'a>
Sourcepub fn new(
transport: &'a Transport,
table: &'a RoutingTable,
hub: PartyRef,
) -> Self
pub fn new( transport: &'a Transport, table: &'a RoutingTable, hub: PartyRef, ) -> Self
A forwarder for the hub party hub.
Sourcepub const fn on_unbridgeable(self, policy: Unbridgeable) -> Self
pub const fn on_unbridgeable(self, policy: Unbridgeable) -> Self
What to do with a message between two versions this build cannot translate.
Sourcepub const fn report_losses(self, report: bool) -> Self
pub const fn report_losses(self, report: bool) -> Self
Whether a translation’s losses are appended to the response’s status_message. On by
default; switch it off for a peer that treats status_message as machine-readable.
Sourcepub async fn relay(
&self,
request: &Forwardable,
to: &PartyRef,
routing: RoutingHeaders,
) -> Relayed
pub async fn relay( &self, request: &Forwardable, to: &PartyRef, routing: RoutingHeaders, ) -> Relayed
Relays one request to the party the OCPI-to-* headers name.
The forwarded request gets a new X-Request-ID and the same X-Correlation-ID:
When a Hub forwards a request to a party, the request to this party SHALL contain a new unique value in the X-Request-ID HTTP header, not a copy … the request SHALL contain the same X-Correlation-ID HTTP header.
§Errors
Returns the 4xxx code that fits: 4001 when the destination is unknown, 4003 when it
is not connected, 4002 on a timeout, 4000 otherwise.
Spec: 2.3.0 §transport_and_format_unique_messageg_ids, §status_codes_4xxx_hub_errors
Sourcepub async fn broadcast(
&self,
request: &Forwardable,
sender_role: Role,
) -> Vec<Relayed>
pub async fn broadcast( &self, request: &Forwardable, sender_role: Role, ) -> Vec<Relayed>
Fans a Broadcast Push out to every party with an opposite role.
When using Broadcast Push, the Hub broadcasts received information to all connected clients … This means only one request to the Hub will be necessary.
Every target is attempted; the results are returned in full so the caller decides what to
tell the sender. aggregate implements the usual policy.
Spec: 2.3.0 §transport_and_format_message_routing_broadcast_push
Sourcepub async fn open_route(
&self,
request: &Forwardable,
router: &dyn OpenRouter,
) -> Result<Relayed, OcpiError>
pub async fn open_route( &self, request: &Forwardable, router: &dyn OpenRouter, ) -> Result<Relayed, OcpiError>
Answers an Open Routing Request by asking the router to pick a destination.
When a Hub has the intelligence to route messages based on the content of the request … The Hub can then decide to which party a request needs to be routed, or that it needs to be broadcasted if the destination cannot be determined.
§Errors
Returns 4001 when the router cannot decide.
Spec: 2.3.0 §transport_and_format_message_routing_open_routing_request
Sourcepub async fn get_all(&self, request: &Forwardable) -> Vec<Relayed>
pub async fn get_all(&self, request: &Forwardable) -> Vec<Relayed>
Answers a GET All by asking every party that implements the Sender interface.
The Hub can then combine objects from different connected parties and return them to the client. The client can determine the owner of the objects by looking at the
country_codeandparty_idin the individual objects returned by the hub.
Because ownership is carried inside each object, merging is a concatenation; the hub does
not have to rewrite anything, and — importantly — “the last_updated fields SHALL NOT be
updated by the Hub”.
Spec: 2.3.0 §transport_and_format_get_all_via_hubs