ServiceDiscoveryBox
Generic wrapper for ServiceDiscovery
instance.
@preconcurrency class ServiceDiscoveryBox<Service, Instance> where Service : Hashable, Service : Sendable, Instance : Hashable, Instance : Sendable
Generic wrapper for ServiceDiscovery
instance.
@preconcurrency class ServiceDiscoveryBox<Service, Instance> where Service : Hashable, Service : Sendable, Instance : Hashable, Instance : Sendable
import ServiceDiscovery
A Service Discovery API for Swift.
@preconcurrency protocol ServiceDiscovery : AnyObject, Sendable
Provides service instances lookup.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Sendable
@preconcurrency init<ServiceDiscoveryImpl>(_ serviceDiscovery: ServiceDiscoveryImpl) where Service == ServiceDiscoveryImpl.Service, Instance == ServiceDiscoveryImpl.Instance, ServiceDiscoveryImpl : ServiceDiscovery
var defaultLookupTimeout: DispatchTimeInterval { get }
@preconcurrency func lookup(_ service: Service, deadline: DispatchTime? = nil, callback: @escaping (Result<[Instance], Error>) -> Void)
@discardableResult @preconcurrency func subscribe(to service: Service, onNext nextResultHandler: @escaping (Result<[Instance], Error>) -> Void, onComplete completionHandler: @escaping (CompletionReason) -> Void = { _ in }) -> CancellationToken
@discardableResult func unwrapAs<ServiceDiscoveryImpl>(_ serviceDiscoveryType: ServiceDiscoveryImpl.Type) throws -> ServiceDiscoveryImpl where ServiceDiscoveryImpl : ServiceDiscovery
Unwraps the underlying ServiceDiscovery
instance as ServiceDiscoveryImpl
type.
@preconcurrency func filterInstance(_ predicate: @escaping (Instance) throws -> Bool) -> FilterInstanceServiceDiscovery<Self>
Creates a new ServiceDiscovery
implementation based on this one, filtering instances with the given predicate.
func lookup(_ service: Service, deadline: DispatchTime? = nil) async throws -> [Instance]
Performs async lookup for the given service’s instances.
@preconcurrency func mapInstance<DerivedInstance>(_ transformer: @escaping (Instance) throws -> DerivedInstance) -> MapInstanceServiceDiscovery<Self, DerivedInstance> where DerivedInstance : Hashable, DerivedInstance : Sendable
Creates a new ServiceDiscovery
implementation based on this one, transforming the instances according to the derived function.
@preconcurrency func mapService<ComputedService>(serviceType: ComputedService.Type = ComputedService.self, _ transformer: @escaping (ComputedService) throws -> Service) -> MapServiceServiceDiscovery<Self, ComputedService> where ComputedService : Hashable, ComputedService : Sendable
Creates a new ServiceDiscovery
implementation based on this one, transforming the services according to the derived function.
func subscribe(to service: Service) -> ServiceSnapshots<Instance>
Returns a ServiceSnapshots
, which is an AsyncSequence
and each of its items is a snapshot listing of service instances.