pub struct DiscoveryServer<S: Component + ?Sized> { /* private fields */ }Expand description
Wraps a server component with service discovery auto-registration.
On start(), the inner server starts first, then the instance is registered. On stop(),
the instance is deregistered first, then the inner server stops.
Implementations§
Source§impl<S: Component + ?Sized> DiscoveryServer<S>
impl<S: Component + ?Sized> DiscoveryServer<S>
Sourcepub fn new(
name: String,
inner: Arc<S>,
registry: Arc<dyn Registry>,
instance: ServiceInstance,
) -> Self
pub fn new( name: String, inner: Arc<S>, registry: Arc<dyn Registry>, instance: ServiceInstance, ) -> Self
Create a new discovery-integrated server.
§Arguments
name- Component identifier (e.g., “discovery-grpc-server”)inner- The server component to wrapregistry- The service registry for registration/deregistrationinstance- The service instance configuration
Sourcepub fn instance(&self) -> &ServiceInstance
pub fn instance(&self) -> &ServiceInstance
Returns the service instance being registered.
Trait Implementations§
Source§impl<S: Component + ?Sized + 'static> Component for DiscoveryServer<S>
impl<S: Component + ?Sized + 'static> Component for DiscoveryServer<S>
Source§fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AppResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = AppResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start the component. Read more
Auto Trait Implementations§
impl<S> !RefUnwindSafe for DiscoveryServer<S>
impl<S> !UnwindSafe for DiscoveryServer<S>
impl<S> Freeze for DiscoveryServer<S>where
S: ?Sized,
impl<S> Send for DiscoveryServer<S>where
S: ?Sized,
impl<S> Sync for DiscoveryServer<S>where
S: ?Sized,
impl<S> Unpin for DiscoveryServer<S>where
S: ?Sized,
impl<S> UnsafeUnpin for DiscoveryServer<S>where
S: ?Sized,
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