Instance Methodpackage-distributed-system 28.0.1DistributedSystem
connectToServices(_:withFilter:clientFactory:serviceHandler:cancellationToken:)
To be used to connect to multiple services of the same type. Service will be discovered with using a discovery system (consul by default).
DistributedSystem.swift:479@discardableResult func connectToServices<S, C>(_ serviceEndpointType: S.Type, withFilter serviceFilter: @escaping ServiceFilter, clientFactory: ((DistributedSystem, ConsulServiceDiscovery.Instance) -> C)? = nil, serviceHandler: @escaping (S, ConsulServiceDiscovery.Instance) -> Void, cancellationToken: CancellationToken? = nil) -> Bool where S : ServiceEndpoint, S.ActorSystem == DistributedSystem
Parameters
- _
serviceEndpointType - type of the service endpoint
- serviceFilter
user can filter out services and create a distributed actors only to needed
- clientFactory
a closure creating a client side endpoint instance
- serviceHandler
a clusure getting an instance of the service endpoint and a service where the endpoint is connected to
Returns
false, if cancellation token was cancelled before the call
Other members in extension
Types
Typealiases
typealias ActorID
typealias InvocationDecoder
typealias InvocationEncoder
typealias ResultHandler
typealias SerializationRequirement
typealias ServiceFactory
typealias ServiceFilter
Type members
init(name: String, addressTag: String?, compressionMode: CompressionMode, logLevel: Logger.Level
) init(systemName: String, addressTag: String?, compressionMode: CompressionMode, logLevel: Logger.Level
)
Instance members
let consulServiceDiscovery: ConsulServiceDiscovery
var logger: Logger
var loggerBox: Box<Logger>
let systemName: String
func actorReady<Actor>(Actor
) func assignID<Actor>(Actor.Type
) -> EndpointIdentifier func connectToService<S, C>(S.Type, withFilter: @escaping ServiceFilter, clientFactory: ((DistributedSystem) -> C)?, serviceHandler: ((S, ConsulServiceDiscovery.Instance) -> Void)?, deadline: DispatchTime?
) async throws -> S To be used to connect to a single service of the particular type. Function returns the service endpoint instance after connection to service is established and service endpoint is ready for use.
func connectToService<S>(S.Type, withFilter: @escaping ServiceFilter, serviceHandler: ((S, ConsulServiceDiscovery.Instance) -> Void)?, deadline: DispatchTime?
) async throws -> S To be used to connect to a single service of the particular type. Function returns the service endpoint instance after connection to service is established and service endpoint is ready for use.
func getBytesSent(
) async throws -> UInt64 func makeCancellationToken(
) -> CancellationToken func makeInvocationEncoder(
) -> RemoteCallEncoder func remoteCall<Actor, Err, Res>(on: Actor, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type, returning: Res.Type
) async throws -> Res func remoteCallVoid<Actor, Err>(on: Actor, target: RemoteCallTarget, invocation: inout InvocationEncoder, throwing: Err.Type
) async throws func resignID(EndpointIdentifier
) func resolve<Actor>(id: EndpointIdentifier, as: Actor.Type
) throws -> Actor? func start(
) throws Service lifecycle start
func stop(
) Service lifecycle stop