UnresolvedAddress
- The type of address before resolution.ResolvedAddress
- The type of address after resolution.Event
- Type of ServiceDiscovererEvent
s published from ServiceDiscoverer.discover(Object)
.public class ServiceDiscovererFilter<UnresolvedAddress,ResolvedAddress,Event extends ServiceDiscovererEvent<ResolvedAddress>> extends java.lang.Object implements ServiceDiscoverer<UnresolvedAddress,ResolvedAddress,Event>
ServiceDiscoverer
that delegates all methods to a different ServiceDiscoverer
.Constructor and Description |
---|
ServiceDiscovererFilter(ServiceDiscoverer<UnresolvedAddress,ResolvedAddress,Event> delegate)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
Completable |
closeAsync()
Used to close/shutdown a resource.
|
Completable |
closeAsyncGracefully()
Used to close/shutdown a resource, similar to
AsyncCloseable.closeAsync() , but attempts to cleanup state before
abruptly closing. |
Publisher<Event> |
discover(UnresolvedAddress unresolvedAddress)
Subscribe to the service discovery system for changes in the available
ResolvedAddress associated with
address . |
Completable |
onClose()
Returns a
Completable that is notified once the ListenableAsyncCloseable was closed. |
public ServiceDiscovererFilter(ServiceDiscoverer<UnresolvedAddress,ResolvedAddress,Event> delegate)
delegate
- The ServiceDiscoverer
to delegate all calls to.public Publisher<Event> discover(UnresolvedAddress unresolvedAddress)
ServiceDiscoverer
ResolvedAddress
associated with
address
.
In general a call to this method will continue to discover changes related to address
until the
PublisherSource.Subscription
corresponding to the return value is cancelled via Cancellable.cancel()
or there are no more changes to
publish.
discover
in interface ServiceDiscoverer<UnresolvedAddress,ResolvedAddress,Event extends ServiceDiscovererEvent<ResolvedAddress>>
unresolvedAddress
- the service address to discover. Examples of what this address maybe are:
Publisher
that represents a stream of events from the service discovery system.public Completable onClose()
ListenableAsyncCloseable
Completable
that is notified once the ListenableAsyncCloseable
was closed.onClose
in interface ListenableAsyncCloseable
Completable
that is notified on close.public Completable closeAsync()
AsyncCloseable
closeAsync
in interface AsyncCloseable
CompletableSource
that is notified once the close is complete.public Completable closeAsyncGracefully()
AsyncCloseable
AsyncCloseable.closeAsync()
, but attempts to cleanup state before
abruptly closing. This provides a hint that implementations can use to stop accepting new work and finish in
flight work. This method is implemented on a "best effort" basis and may be equivalent to AsyncCloseable.closeAsync()
.
Note: Implementations may or may not apply a timeout for this operation to complete, if a caller does not
want to wait indefinitely, and are unsure if the implementation applies a timeout, it is advisable to apply a
timeout and force a call to AsyncCloseable.closeAsync()
.
closeAsyncGracefully
in interface AsyncCloseable
Completable
that is notified once the close is complete.