Struct cocaine::service::ServiceBuilder [] [src]

pub struct ServiceBuilder<T> { /* fields omitted */ }

Service configuration. Provides detailed control over the properties and behavior of new services.

Uses Locator as a service name resolver by default.

Examples

use cocaine::{Core, ServiceBuilder};

let core = Core::new().unwrap();

let service = ServiceBuilder::new("storage")
    .build(&core.handle());

assert_eq!("storage", service.name());

Methods

impl ServiceBuilder<ResolverBuilder>
[src]

Constructs a new service builder, which will build a Service with the given name.

Sets the Locator resolver endpoints.

By default [::]:10053 address is used to resolve the Locator service and it can be changed using this method. If multiple endpoints are specified the resolver will try to connect to each of them in a loop, breaking after the connection establishment.

Note

These endpoints are used only for Locator resolving. The Service resolution is done through the Locator unless FixedResolver specified using resolver method.

Examples

use std::net::{IpAddr, Ipv4Addr, SocketAddr};

use cocaine::{Core, ServiceBuilder};

let core = Core::new().unwrap();

let service = ServiceBuilder::new("storage")
    .locator_addrs(vec![SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 10071)])
    .build(&core.handle());

Sets the memory limit in bytes for internal buffers.

Normally cocaine-runtime must read all incoming events as fast as possible no matter what. However, especially for logging service, sometimes the client can overflow the TCP window, which leads to readable stream overload. As a result - we start to buffering incoming events more and more, and it may potentially lead to OOM killer coming.

By specifying this option we set the internal memory limit so every new either invocation or push event, that will overflow the specified limit, will be rejected with MemoryOverflow error code and this is guaranteed that those bytes won't be written into the socket until retried.

impl<T> ServiceBuilder<T>
[src]

Sets the resolver, that is used for name resolution.

By default name resolution via the Locator is used, but sometimes more detailed control is required.

Examples

This example demonstrates how to build a Service, which will always try to connect to a fixed endpoint at 127.0.0.1:32768.

use std::net::{IpAddr, Ipv4Addr, SocketAddr};

use cocaine::{ServiceBuilder, Core, FixedResolver};

let core = Core::new().unwrap();
let endpoints = vec![SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 32768)];

let service = ServiceBuilder::new("storage")
    .resolver(FixedResolver::new(endpoints))
    .build(&core.handle());

impl<T: ResolveBuilder + 'static> ServiceBuilder<T>
[src]

Consumes this ServiceBuilder yielding a Service.

This will not perform a connection attempt until required - both name resolution and connection will be performed on demand. You can call Service::connect() method for fine-grained control.

Trait Implementations

impl<T> Debug for ServiceBuilder<T>
[src]

Formats the value using the given formatter.