Implement a Java/Kotlin client.

This commit is contained in:
2023-04-22 23:24:36 -07:00
parent 0b5f5dae57
commit 9b0c174df4
10 changed files with 195 additions and 11 deletions

View File

@ -0,0 +1,30 @@
import Foundation
import GRPC
import NIO
import StableDiffusionCore
import StableDiffusionProtos
struct StableDiffusionClient {
let group: EventLoopGroup
let channel: GRPCChannel
let modelService: SdModelServiceAsyncClient
let imageGenerationService: SdImageGenerationServiceAsyncClient
init(connectionTarget: ConnectionTarget, transportSecurity: GRPCChannelPool.Configuration.TransportSecurity) throws {
group = PlatformSupport.makeEventLoopGroup(loopCount: 1)
channel = try GRPCChannelPool.with(
target: connectionTarget,
transportSecurity: transportSecurity,
eventLoopGroup: group
)
modelService = SdModelServiceAsyncClient(channel: channel)
imageGenerationService = SdImageGenerationServiceAsyncClient(channel: channel)
}
func close() async throws {
try await group.shutdownGracefully()
}
}