pub struct Service { /* private fields */ }
Available on crate feature
service
only.Expand description
Service instance.
§Examples
use async_nats::service::ServiceExt;
use futures::StreamExt;
let client = async_nats::connect("demo.nats.io").await?;
let mut service = client.service_builder().start("generator", "1.0.0").await?;
let mut endpoint = service.endpoint("get").await?;
if let Some(request) = endpoint.next().await {
request.respond(Ok("hello".into())).await?;
}
Implementations§
Source§impl Service
impl Service
Sourcepub fn group<S: ToString>(&self, prefix: S) -> Group
pub fn group<S: ToString>(&self, prefix: S) -> Group
Creates a group for endpoints under common prefix.
§Examples
use async_nats::service::ServiceExt;
let client = async_nats::connect("demo.nats.io").await?;
let mut service = client.service_builder().start("service", "1.0.0").await?;
let v1 = service.group("v1");
let products = v1.endpoint("products").await?;
Sourcepub fn group_with_queue_group<S: ToString, Z: ToString>(
&self,
prefix: S,
queue_group: Z,
) -> Group
pub fn group_with_queue_group<S: ToString, Z: ToString>( &self, prefix: S, queue_group: Z, ) -> Group
Creates a group for endpoints under common prefix with custom queue group.
§Examples
use async_nats::service::ServiceExt;
let client = async_nats::connect("demo.nats.io").await?;
let mut service = client.service_builder().start("service", "1.0.0").await?;
let v1 = service.group("v1");
let products = v1.endpoint("products").await?;
Sourcepub fn endpoint_builder(&self) -> EndpointBuilder
pub fn endpoint_builder(&self) -> EndpointBuilder
Builder for customized Endpoint creation.
§Examples
use async_nats::service::ServiceExt;
let client = async_nats::connect("demo.nats.io").await?;
let mut service = client.service_builder().start("service", "1.0.0").await?;
let products = service
.endpoint_builder()
.name("api")
.add("products")
.await?;
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Service
impl !RefUnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl !UnwindSafe for Service
Blanket Implementations§
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
Mutably borrows from an owned value. Read more