// // DO NOT EDIT. // swift-format-ignore-file // // Generated by the protocol buffer compiler. // Source: jobs.proto // import GRPC import NIO import NIOConcurrencyHelpers import SwiftProtobuf ///* /// The job service, for inspecting and monitoring the state of jobs executing on the service. /// /// Usage: instantiate `SdJobServiceClient`, then call methods of this protocol to make API calls. public protocol SdJobServiceClientProtocol: GRPCClient { var serviceName: String { get } var interceptors: SdJobServiceClientInterceptorFactoryProtocol? { get } func getJob( _ request: SdGetJobRequest, callOptions: CallOptions? ) -> UnaryCall func cancelJob( _ request: SdCancelJobRequest, callOptions: CallOptions? ) -> UnaryCall func streamJobUpdates( _ request: SdStreamJobUpdatesRequest, callOptions: CallOptions?, handler: @escaping (SdJobUpdate) -> Void ) -> ServerStreamingCall } extension SdJobServiceClientProtocol { public var serviceName: String { return "gay.pizza.stable.diffusion.JobService" } /// Unary call to GetJob /// /// - Parameters: /// - request: Request to send to GetJob. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func getJob( _ request: SdGetJobRequest, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: SdJobServiceClientMetadata.Methods.getJob.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeGetJobInterceptors() ?? [] ) } /// Unary call to CancelJob /// /// - Parameters: /// - request: Request to send to CancelJob. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func cancelJob( _ request: SdCancelJobRequest, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: SdJobServiceClientMetadata.Methods.cancelJob.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeCancelJobInterceptors() ?? [] ) } /// Server streaming call to StreamJobUpdates /// /// - Parameters: /// - request: Request to send to StreamJobUpdates. /// - callOptions: Call options. /// - handler: A closure called when each response is received from the server. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status. public func streamJobUpdates( _ request: SdStreamJobUpdatesRequest, callOptions: CallOptions? = nil, handler: @escaping (SdJobUpdate) -> Void ) -> ServerStreamingCall { return self.makeServerStreamingCall( path: SdJobServiceClientMetadata.Methods.streamJobUpdates.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeStreamJobUpdatesInterceptors() ?? [], handler: handler ) } } @available(*, deprecated) extension SdJobServiceClient: @unchecked Sendable {} @available(*, deprecated, renamed: "SdJobServiceNIOClient") public final class SdJobServiceClient: SdJobServiceClientProtocol { private let lock = Lock() private var _defaultCallOptions: CallOptions private var _interceptors: SdJobServiceClientInterceptorFactoryProtocol? public let channel: GRPCChannel public var defaultCallOptions: CallOptions { get { self.lock.withLock { return self._defaultCallOptions } } set { self.lock.withLockVoid { self._defaultCallOptions = newValue } } } public var interceptors: SdJobServiceClientInterceptorFactoryProtocol? { get { self.lock.withLock { return self._interceptors } } set { self.lock.withLockVoid { self._interceptors = newValue } } } /// Creates a client for the gay.pizza.stable.diffusion.JobService service. /// /// - Parameters: /// - channel: `GRPCChannel` to the service host. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. /// - interceptors: A factory providing interceptors for each RPC. public init( channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions(), interceptors: SdJobServiceClientInterceptorFactoryProtocol? = nil ) { self.channel = channel self._defaultCallOptions = defaultCallOptions self._interceptors = interceptors } } public struct SdJobServiceNIOClient: SdJobServiceClientProtocol { public var channel: GRPCChannel public var defaultCallOptions: CallOptions public var interceptors: SdJobServiceClientInterceptorFactoryProtocol? /// Creates a client for the gay.pizza.stable.diffusion.JobService service. /// /// - Parameters: /// - channel: `GRPCChannel` to the service host. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. /// - interceptors: A factory providing interceptors for each RPC. public init( channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions(), interceptors: SdJobServiceClientInterceptorFactoryProtocol? = nil ) { self.channel = channel self.defaultCallOptions = defaultCallOptions self.interceptors = interceptors } } ///* /// The job service, for inspecting and monitoring the state of jobs executing on the service. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol SdJobServiceAsyncClientProtocol: GRPCClient { static var serviceDescriptor: GRPCServiceDescriptor { get } var interceptors: SdJobServiceClientInterceptorFactoryProtocol? { get } func makeGetJobCall( _ request: SdGetJobRequest, callOptions: CallOptions? ) -> GRPCAsyncUnaryCall func makeCancelJobCall( _ request: SdCancelJobRequest, callOptions: CallOptions? ) -> GRPCAsyncUnaryCall func makeStreamJobUpdatesCall( _ request: SdStreamJobUpdatesRequest, callOptions: CallOptions? ) -> GRPCAsyncServerStreamingCall } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension SdJobServiceAsyncClientProtocol { public static var serviceDescriptor: GRPCServiceDescriptor { return SdJobServiceClientMetadata.serviceDescriptor } public var interceptors: SdJobServiceClientInterceptorFactoryProtocol? { return nil } public func makeGetJobCall( _ request: SdGetJobRequest, callOptions: CallOptions? = nil ) -> GRPCAsyncUnaryCall { return self.makeAsyncUnaryCall( path: SdJobServiceClientMetadata.Methods.getJob.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeGetJobInterceptors() ?? [] ) } public func makeCancelJobCall( _ request: SdCancelJobRequest, callOptions: CallOptions? = nil ) -> GRPCAsyncUnaryCall { return self.makeAsyncUnaryCall( path: SdJobServiceClientMetadata.Methods.cancelJob.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeCancelJobInterceptors() ?? [] ) } public func makeStreamJobUpdatesCall( _ request: SdStreamJobUpdatesRequest, callOptions: CallOptions? = nil ) -> GRPCAsyncServerStreamingCall { return self.makeAsyncServerStreamingCall( path: SdJobServiceClientMetadata.Methods.streamJobUpdates.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeStreamJobUpdatesInterceptors() ?? [] ) } } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension SdJobServiceAsyncClientProtocol { public func getJob( _ request: SdGetJobRequest, callOptions: CallOptions? = nil ) async throws -> SdGetJobResponse { return try await self.performAsyncUnaryCall( path: SdJobServiceClientMetadata.Methods.getJob.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeGetJobInterceptors() ?? [] ) } public func cancelJob( _ request: SdCancelJobRequest, callOptions: CallOptions? = nil ) async throws -> SdCancelJobResponse { return try await self.performAsyncUnaryCall( path: SdJobServiceClientMetadata.Methods.cancelJob.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeCancelJobInterceptors() ?? [] ) } public func streamJobUpdates( _ request: SdStreamJobUpdatesRequest, callOptions: CallOptions? = nil ) -> GRPCAsyncResponseStream { return self.performAsyncServerStreamingCall( path: SdJobServiceClientMetadata.Methods.streamJobUpdates.path, request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeStreamJobUpdatesInterceptors() ?? [] ) } } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public struct SdJobServiceAsyncClient: SdJobServiceAsyncClientProtocol { public var channel: GRPCChannel public var defaultCallOptions: CallOptions public var interceptors: SdJobServiceClientInterceptorFactoryProtocol? public init( channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions(), interceptors: SdJobServiceClientInterceptorFactoryProtocol? = nil ) { self.channel = channel self.defaultCallOptions = defaultCallOptions self.interceptors = interceptors } } public protocol SdJobServiceClientInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when invoking 'getJob'. func makeGetJobInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'cancelJob'. func makeCancelJobInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'streamJobUpdates'. func makeStreamJobUpdatesInterceptors() -> [ClientInterceptor] } public enum SdJobServiceClientMetadata { public static let serviceDescriptor = GRPCServiceDescriptor( name: "JobService", fullName: "gay.pizza.stable.diffusion.JobService", methods: [ SdJobServiceClientMetadata.Methods.getJob, SdJobServiceClientMetadata.Methods.cancelJob, SdJobServiceClientMetadata.Methods.streamJobUpdates, ] ) public enum Methods { public static let getJob = GRPCMethodDescriptor( name: "GetJob", path: "/gay.pizza.stable.diffusion.JobService/GetJob", type: GRPCCallType.unary ) public static let cancelJob = GRPCMethodDescriptor( name: "CancelJob", path: "/gay.pizza.stable.diffusion.JobService/CancelJob", type: GRPCCallType.unary ) public static let streamJobUpdates = GRPCMethodDescriptor( name: "StreamJobUpdates", path: "/gay.pizza.stable.diffusion.JobService/StreamJobUpdates", type: GRPCCallType.serverStreaming ) } } ///* /// The job service, for inspecting and monitoring the state of jobs executing on the service. /// /// To build a server, implement a class that conforms to this protocol. public protocol SdJobServiceProvider: CallHandlerProvider { var interceptors: SdJobServiceServerInterceptorFactoryProtocol? { get } func getJob(request: SdGetJobRequest, context: StatusOnlyCallContext) -> EventLoopFuture func cancelJob(request: SdCancelJobRequest, context: StatusOnlyCallContext) -> EventLoopFuture func streamJobUpdates(request: SdStreamJobUpdatesRequest, context: StreamingResponseCallContext) -> EventLoopFuture } extension SdJobServiceProvider { public var serviceName: Substring { return SdJobServiceServerMetadata.serviceDescriptor.fullName[...] } /// Determines, calls and returns the appropriate request handler, depending on the request's method. /// Returns nil for methods not handled by this service. public func handle( method name: Substring, context: CallHandlerContext ) -> GRPCServerHandlerProtocol? { switch name { case "GetJob": return UnaryServerHandler( context: context, requestDeserializer: ProtobufDeserializer(), responseSerializer: ProtobufSerializer(), interceptors: self.interceptors?.makeGetJobInterceptors() ?? [], userFunction: self.getJob(request:context:) ) case "CancelJob": return UnaryServerHandler( context: context, requestDeserializer: ProtobufDeserializer(), responseSerializer: ProtobufSerializer(), interceptors: self.interceptors?.makeCancelJobInterceptors() ?? [], userFunction: self.cancelJob(request:context:) ) case "StreamJobUpdates": return ServerStreamingServerHandler( context: context, requestDeserializer: ProtobufDeserializer(), responseSerializer: ProtobufSerializer(), interceptors: self.interceptors?.makeStreamJobUpdatesInterceptors() ?? [], userFunction: self.streamJobUpdates(request:context:) ) default: return nil } } } ///* /// The job service, for inspecting and monitoring the state of jobs executing on the service. /// /// To implement a server, implement an object which conforms to this protocol. @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol SdJobServiceAsyncProvider: CallHandlerProvider, Sendable { static var serviceDescriptor: GRPCServiceDescriptor { get } var interceptors: SdJobServiceServerInterceptorFactoryProtocol? { get } func getJob( request: SdGetJobRequest, context: GRPCAsyncServerCallContext ) async throws -> SdGetJobResponse func cancelJob( request: SdCancelJobRequest, context: GRPCAsyncServerCallContext ) async throws -> SdCancelJobResponse func streamJobUpdates( request: SdStreamJobUpdatesRequest, responseStream: GRPCAsyncResponseStreamWriter, context: GRPCAsyncServerCallContext ) async throws } @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension SdJobServiceAsyncProvider { public static var serviceDescriptor: GRPCServiceDescriptor { return SdJobServiceServerMetadata.serviceDescriptor } public var serviceName: Substring { return SdJobServiceServerMetadata.serviceDescriptor.fullName[...] } public var interceptors: SdJobServiceServerInterceptorFactoryProtocol? { return nil } public func handle( method name: Substring, context: CallHandlerContext ) -> GRPCServerHandlerProtocol? { switch name { case "GetJob": return GRPCAsyncServerHandler( context: context, requestDeserializer: ProtobufDeserializer(), responseSerializer: ProtobufSerializer(), interceptors: self.interceptors?.makeGetJobInterceptors() ?? [], wrapping: { try await self.getJob(request: $0, context: $1) } ) case "CancelJob": return GRPCAsyncServerHandler( context: context, requestDeserializer: ProtobufDeserializer(), responseSerializer: ProtobufSerializer(), interceptors: self.interceptors?.makeCancelJobInterceptors() ?? [], wrapping: { try await self.cancelJob(request: $0, context: $1) } ) case "StreamJobUpdates": return GRPCAsyncServerHandler( context: context, requestDeserializer: ProtobufDeserializer(), responseSerializer: ProtobufSerializer(), interceptors: self.interceptors?.makeStreamJobUpdatesInterceptors() ?? [], wrapping: { try await self.streamJobUpdates(request: $0, responseStream: $1, context: $2) } ) default: return nil } } } public protocol SdJobServiceServerInterceptorFactoryProtocol: Sendable { /// - Returns: Interceptors to use when handling 'getJob'. /// Defaults to calling `self.makeInterceptors()`. func makeGetJobInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'cancelJob'. /// Defaults to calling `self.makeInterceptors()`. func makeCancelJobInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'streamJobUpdates'. /// Defaults to calling `self.makeInterceptors()`. func makeStreamJobUpdatesInterceptors() -> [ServerInterceptor] } public enum SdJobServiceServerMetadata { public static let serviceDescriptor = GRPCServiceDescriptor( name: "JobService", fullName: "gay.pizza.stable.diffusion.JobService", methods: [ SdJobServiceServerMetadata.Methods.getJob, SdJobServiceServerMetadata.Methods.cancelJob, SdJobServiceServerMetadata.Methods.streamJobUpdates, ] ) public enum Methods { public static let getJob = GRPCMethodDescriptor( name: "GetJob", path: "/gay.pizza.stable.diffusion.JobService/GetJob", type: GRPCCallType.unary ) public static let cancelJob = GRPCMethodDescriptor( name: "CancelJob", path: "/gay.pizza.stable.diffusion.JobService/CancelJob", type: GRPCCallType.unary ) public static let streamJobUpdates = GRPCMethodDescriptor( name: "StreamJobUpdates", path: "/gay.pizza.stable.diffusion.JobService/StreamJobUpdates", type: GRPCCallType.serverStreaming ) } }