Struct cocaine::Service [] [src]

pub struct Service { /* fields omitted */ }

A low-level entry point to the Cocaine Cloud.

The Service provides an ability to work with Cocaine services in a thread-safe manner with automatic name resolution and reconnection before the next request after any unexpected I/O error.

Internally it has an asynchronous state machine, which runs in an event loop associated with the handle given at construction time.

Most time you find out that it's more practical to use convenient service wrappers, like Locator, Unicorn etc.

Methods

impl Service
[src]

[src]

Constructs a new Service with a given name.

This will not perform a connection attempt until required - both name resolution and connection will be performed on demand, but you can still call connect method to perform connection attempt.

For more fine-grained service configuration use ServiceBuilder instead.

Examples

use cocaine::{Core, Service};

let core = Core::new().unwrap();
let locator = Service::new("locator", &core.handle());

let name = "app".to_string();
let service = Service::new(name, &core.handle());

assert_eq!("app", service.name());
assert_eq!("locator", locator.name());

[src]

Returns service name.

[src]

Connects to the service, performing name resolution and TCP connection establishing.

Does nothing, if a service is already connected to some backend.

Usually a service connects automatically on demand, however it may be useful to optimize away a connection delay by doing pre-connection using this method.

[src]

Returns methods map if available.

The return value can be None if either the service is not connected or the Resolve has provided incomplete information. Note that this method aren't meant to be used to check whether the service is connected, because it can return valid methods map, while still connecting to real endpoint. To check the connection status use peer_addr method instead.

[src]

Disconnects from a remote service without discarding pending requests.

[src]

Returns the socket address of the remote peer of this TCP connection.

Returns an I/O error with ErrorKind::NotConnected if this Service is not currently connected.

[src]

Returns the socket address of the local half of this TCP connection.

Returns an I/O error with ErrorKind::NotConnected if this Service is not currently connected.

[src]

Performs an RPC with a specified type and arguments.

The result type is a future of Sender, because service requires TCP connection established before the request can be processed.

Warning

Calling a mute event using this method essentially leads to memory leak during this object's entire lifetime, since the specified Dispatch will be captured. For mute RPC use call_mute instead.

[src]

Performs a mute RPC with a specified type and arguments.

Mute calls have no responses, that's why this method does not require a dispatch.

Warning

Calling a service event, that actually does respond, leads to silent dropping all received response chunks.

Trait Implementations

impl Clone for Service
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Service
[src]

[src]

Formats the value using the given formatter.