Service
ServiceDiscovery+TypeErased.swift:82typealias Service = AnyHashable
typealias Service = AnyHashable
import ServiceDiscovery
A Service Discovery API for Swift.
final class AnyServiceDiscovery
Type-erased wrapper for ServiceDiscovery
instance.
@frozen struct AnyHashable
A type-erased hashable value.
init<ServiceDiscoveryImpl>(_ serviceDiscovery: ServiceDiscoveryImpl) where ServiceDiscoveryImpl : ServiceDiscovery
var defaultLookupTimeout: DispatchTimeInterval { get }
func lookup(_ service: any Hashable & Sendable, deadline: DispatchTime? = nil, callback: @escaping (Result<[any Hashable & Sendable], Error>) -> Void)
See lookup(_:deadline:callback:)
.
@preconcurrency func lookupAndUnwrap<Service, Instance>(_ service: Service, deadline: DispatchTime? = nil) async throws -> [Instance] where Service : Hashable, Service : Sendable, Instance : Hashable, Instance : Sendable
See lookup(_:deadline:)
.
@preconcurrency func lookupAndUnwrap<Service, Instance>(_ service: Service, deadline: DispatchTime? = nil, callback: @escaping (Result<[Instance], Error>) -> Void) where Service : Hashable, Service : Sendable, Instance : Hashable, Instance : Sendable
See lookup(_:deadline:callback:)
.
@discardableResult func subscribe(to service: any Hashable & Sendable, onNext nextResultHandler: @escaping (Result<[any Hashable & Sendable], Error>) -> Void, onComplete completionHandler: @escaping (CompletionReason) -> Void = { _ in }) -> CancellationToken
See subscribe(to:onNext:onComplete:)
.
@preconcurrency func subscribeAndUnwrap<Service, Instance>(to service: Service) -> ServiceSnapshots<Instance> where Service : Hashable, Service : Sendable, Instance : Hashable, Instance : Sendable
See subscribe(to:)
.
@discardableResult @preconcurrency func subscribeAndUnwrap<Service, Instance>(to service: Service, onNext nextResultHandler: @escaping (Result<[Instance], Error>) -> Void, onComplete completionHandler: @escaping (CompletionReason) -> Void = { _ in }) -> CancellationToken where Service : Hashable, Service : Sendable, Instance : Hashable, Instance : Sendable
See subscribe(to:onNext:onComplete:)
.
func unwrapAs<ServiceDiscoveryImpl>(_ serviceDiscoveryType: ServiceDiscoveryImpl.Type) throws -> ServiceDiscoveryImpl where ServiceDiscoveryImpl : ServiceDiscovery
Unwraps the underlying ServiceDiscovery
instance as ServiceDiscoveryImpl
type.
typealias Instance = AnyHashable
@preconcurrency func lookup(_ service: AnyHashable, deadline: DispatchTime? = nil, callback: @escaping (Result<[AnyHashable], Error>) -> Void)
See lookup(_:deadline:callback:)
.
@discardableResult @preconcurrency func subscribe(to service: AnyHashable, onNext nextResultHandler: @escaping (Result<[AnyHashable], Error>) -> Void, onComplete completionHandler: @escaping (CompletionReason) -> Void = { _ in }) -> CancellationToken
See subscribe(to:onNext:onComplete:)
.
func lookup(_ service: Service, deadline: DispatchTime? = nil) async throws -> [Instance]
Performs async lookup for the given service’s instances.
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.
@preconcurrency protocol ServiceDiscovery : AnyObject, Sendable
Provides service instances lookup.