pub struct NetworkDispatcher { /* private fields */ }Expand description
A network-capable dispatcher for sending messages to remote actors
Construct this using NetworkConfig.
This dispatcher automatically creates channels to requested target systems on demand and maintains them while in use.
The current implementation only supports TCP as a transport protocol.
If possible, this implementation will “reflect” messages to local actors directly back up, instead of serialising them first.
Implementations§
Source§impl NetworkDispatcher
impl NetworkDispatcher
Sourcepub fn new(notify_ready: KPromise<()>) -> Self
pub fn new(notify_ready: KPromise<()>) -> Self
Create a new dispatcher with the default configuration
See also NetworkConfig.
§Example
This example binds to local host on a free port chosen by the operating system.
use kompact::prelude::*;
use kompact_net::NetworkDispatcher;
let mut conf = KompactConfig::default();
conf.system_components(DeadletterBox::new, NetworkDispatcher::new);
let system = conf.build().wait().expect("system");Sourcepub fn with_config(cfg: NetworkConfig, notify_ready: KPromise<()>) -> Self
pub fn with_config(cfg: NetworkConfig, notify_ready: KPromise<()>) -> Self
Create a new dispatcher with the given configuration
For better readability in combination with system_components, use NetworkConfig::build instead.
Sourcepub fn system_path_ref(&mut self) -> &SystemPath
pub fn system_path_ref(&mut self) -> &SystemPath
Return a reference to the cached system path
Mutable, since it will update the cached value, if necessary.
Source§impl NetworkDispatcher
impl NetworkDispatcher
Sourcepub fn network_status_port(&mut self) -> &mut ProvidedPort<NetworkStatusPort>
pub fn network_status_port(&mut self) -> &mut ProvidedPort<NetworkStatusPort>
Returns the provided network status port for this dispatcher.
Trait Implementations§
Source§impl Actor for NetworkDispatcher
impl Actor for NetworkDispatcher
Source§type Message = DispatchEnvelope
type Message = DispatchEnvelope
Source§fn receive_local(&mut self, msg: Self::Message) -> HandlerResult
fn receive_local(&mut self, msg: Self::Message) -> HandlerResult
Source§fn receive_network(&mut self, msg: NetMessage) -> HandlerResult
fn receive_network(&mut self, msg: NetMessage) -> HandlerResult
Source§impl ComponentDefinition for NetworkDispatcher
impl ComponentDefinition for NetworkDispatcher
Source§fn setup(&mut self, self_component: Arc<Component<Self>>)
fn setup(&mut self, self_component: Arc<Component<Self>>)
Source§fn execute(&mut self, max_events: usize, skip: usize) -> ExecuteResult
fn execute(&mut self, max_events: usize, skip: usize) -> ExecuteResult
Source§fn ctx_mut(&mut self) -> &mut ComponentContext<Self>
fn ctx_mut(&mut self) -> &mut ComponentContext<Self>
Source§fn ctx(&self) -> &ComponentContext<Self>
fn ctx(&self) -> &ComponentContext<Self>
Source§fn spawn_local<F>(
&mut self,
f: impl FnOnce(ComponentDefinitionAccess<Self>) -> F,
)
fn spawn_local<F>( &mut self, f: impl FnOnce(ComponentDefinitionAccess<Self>) -> F, )
Source§impl ComponentLifecycle for NetworkDispatcher
impl ComponentLifecycle for NetworkDispatcher
Source§fn on_start(&mut self) -> HandlerResult
fn on_start(&mut self) -> HandlerResult
Source§fn on_stop(&mut self) -> HandlerResult
fn on_stop(&mut self) -> HandlerResult
Source§fn on_kill(&mut self) -> HandlerResult
fn on_kill(&mut self) -> HandlerResult
Source§impl Dispatcher for NetworkDispatcher
impl Dispatcher for NetworkDispatcher
Source§fn system_path(&mut self) -> SystemPath
fn system_path(&mut self) -> SystemPath
Generates a SystemPath from this dispatcher’s configuration
This is only possible after the socket is bound and will panic if attempted earlier!
Source§impl DynamicPortAccess for NetworkDispatcher
impl DynamicPortAccess for NetworkDispatcher
Source§fn get_provided_port_as_any(&mut self, port_id: TypeId) -> Option<&mut dyn Any>
fn get_provided_port_as_any(&mut self, port_id: TypeId) -> Option<&mut dyn Any>
ProvidedPort if self
provides a port of the type indicated by the passed port_id. Read moreSource§fn get_required_port_as_any(&mut self, port_id: TypeId) -> Option<&mut dyn Any>
fn get_required_port_as_any(&mut self, port_id: TypeId) -> Option<&mut dyn Any>
RequiredPort if self
requires a port of the type indicated by the passed port_id. Read moreSource§impl Provide<NetworkStatusPort> for NetworkDispatcher
impl Provide<NetworkStatusPort> for NetworkDispatcher
Source§fn handle(
&mut self,
event: <NetworkStatusPort as Port>::Request,
) -> HandlerResult
fn handle( &mut self, event: <NetworkStatusPort as Port>::Request, ) -> HandlerResult
event Read moreSource§impl ProvideRef<NetworkStatusPort> for NetworkDispatcher
impl ProvideRef<NetworkStatusPort> for NetworkDispatcher
Source§fn provided_ref(&mut self) -> ProvidedRef<NetworkStatusPort>
fn provided_ref(&mut self) -> ProvidedRef<NetworkStatusPort>
PSource§fn connect_to_required(&mut self, req: RequiredRef<NetworkStatusPort>)
fn connect_to_required(&mut self, req: RequiredRef<NetworkStatusPort>)
P to reqSource§fn disconnect(&mut self, req: RequiredRef<NetworkStatusPort>)
fn disconnect(&mut self, req: RequiredRef<NetworkStatusPort>)
P from reqAuto Trait Implementations§
impl !Freeze for NetworkDispatcher
impl !RefUnwindSafe for NetworkDispatcher
impl Send for NetworkDispatcher
impl !Sync for NetworkDispatcher
impl Unpin for NetworkDispatcher
impl UnsafeUnpin for NetworkDispatcher
impl !UnwindSafe for NetworkDispatcher
Blanket Implementations§
Source§impl<CD> ActorPathFactory for CDwhere
CD: ComponentTraits,
impl<CD> ActorPathFactory for CDwhere
CD: ComponentTraits,
Source§fn actor_path(&self) -> ActorPath
fn actor_path(&self) -> ActorPath
Source§impl<A, M> ActorRaw for Awhere
M: MessageBounds,
A: Actor<Message = M>,
impl<A, M> ActorRaw for Awhere
M: MessageBounds,
A: Actor<Message = M>,
Source§impl<CD> ActorRefFactory for CDwhere
CD: ComponentDefinition,
impl<CD> ActorRefFactory for CDwhere
CD: ComponentDefinition,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<CD> ComponentLogging for CDwhere
CD: ComponentTraits + ComponentLifecycle,
impl<CD> ComponentLogging for CDwhere
CD: ComponentTraits + ComponentLifecycle,
Source§impl<CD> Dispatching for CDwhere
CD: ComponentTraits,
impl<CD> Dispatching for CDwhere
CD: ComponentTraits,
Source§fn dispatcher_ref(&self) -> ActorRefStrong<DispatchEnvelope>
fn dispatcher_ref(&self) -> ActorRefStrong<DispatchEnvelope>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<CD> Timer<CD> for CDwhere
CD: ComponentTraits,
impl<CD> Timer<CD> for CDwhere
CD: ComponentTraits,
Source§fn schedule_once<F>(&mut self, timeout: Duration, action: F) -> ScheduledTimer
fn schedule_once<F>(&mut self, timeout: Duration, action: F) -> ScheduledTimer
Source§fn schedule_periodic<F>(
&mut self,
delay: Duration,
period: Duration,
action: F,
) -> ScheduledTimer
fn schedule_periodic<F>( &mut self, delay: Duration, period: Duration, action: F, ) -> ScheduledTimer
Source§fn cancel_timer(&mut self, handle: ScheduledTimer)
fn cancel_timer(&mut self, handle: ScheduledTimer)
handle Read more