Switch to gRPC client in Swift app
Some checks are pending
Build AppImage / Build AppImage (push) Waiting to run
Build Apple Apps / Build App (iOS) (push) Waiting to run
Build Apple Apps / Build App (iOS Simulator) (push) Waiting to run
Build Apple Apps / Build App (macOS) (push) Waiting to run
Build Docker / Build Docker Image (push) Waiting to run
Build Rust Crate / Build Crate (macOS (Intel)) (push) Waiting to run
Build Rust Crate / Build Crate (macOS) (push) Waiting to run
Build Rust Crate / Build Crate (Linux) (push) Waiting to run
Build Rust Crate / Build Crate (Windows) (push) Waiting to run
Some checks are pending
Build AppImage / Build AppImage (push) Waiting to run
Build Apple Apps / Build App (iOS) (push) Waiting to run
Build Apple Apps / Build App (iOS Simulator) (push) Waiting to run
Build Apple Apps / Build App (macOS) (push) Waiting to run
Build Docker / Build Docker Image (push) Waiting to run
Build Rust Crate / Build Crate (macOS (Intel)) (push) Waiting to run
Build Rust Crate / Build Crate (macOS) (push) Waiting to run
Build Rust Crate / Build Crate (Linux) (push) Waiting to run
Build Rust Crate / Build Crate (Windows) (push) Waiting to run
This commit is contained in:
parent
25a0f7c421
commit
85640ffce1
93 changed files with 1666 additions and 1327 deletions
32
Apple/Core/Client.swift
Normal file
32
Apple/Core/Client.swift
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import GRPC
|
||||
import NIOTransportServices
|
||||
|
||||
public typealias TunnelClient = Burrow_TunnelAsyncClient
|
||||
public typealias NetworksClient = Burrow_NetworksAsyncClient
|
||||
|
||||
public protocol Client {
|
||||
init(channel: GRPCChannel)
|
||||
}
|
||||
|
||||
extension Client {
|
||||
public static func unix(socketURL: URL) -> Self {
|
||||
let group = NIOTSEventLoopGroup()
|
||||
let configuration = ClientConnection.Configuration.default(
|
||||
target: .unixDomainSocket(socketURL.path),
|
||||
eventLoopGroup: group
|
||||
)
|
||||
return Self(channel: ClientConnection(configuration: configuration))
|
||||
}
|
||||
}
|
||||
|
||||
extension TunnelClient: Client {
|
||||
public init(channel: any GRPCChannel) {
|
||||
self.init(channel: channel, defaultCallOptions: .init(), interceptors: .none)
|
||||
}
|
||||
}
|
||||
|
||||
extension NetworksClient: Client {
|
||||
public init(channel: any GRPCChannel) {
|
||||
self.init(channel: channel, defaultCallOptions: .init(), interceptors: .none)
|
||||
}
|
||||
}
|
||||
1
Apple/Core/Client/burrow.proto
Symbolic link
1
Apple/Core/Client/burrow.proto
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../../../proto/burrow.proto
|
||||
11
Apple/Core/Client/grpc-swift-config.json
Normal file
11
Apple/Core/Client/grpc-swift-config.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"invocations": [
|
||||
{
|
||||
"protoFiles": [
|
||||
"burrow.proto",
|
||||
],
|
||||
"server": false,
|
||||
"visibility": "public"
|
||||
}
|
||||
]
|
||||
}
|
||||
10
Apple/Core/Client/swift-protobuf-config.json
Normal file
10
Apple/Core/Client/swift-protobuf-config.json
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"invocations": [
|
||||
{
|
||||
"protoFiles": [
|
||||
"burrow.proto",
|
||||
],
|
||||
"visibility": "public"
|
||||
}
|
||||
]
|
||||
}
|
||||
19
Apple/Core/Logging.swift
Normal file
19
Apple/Core/Logging.swift
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import os
|
||||
@_exported import OSLog
|
||||
|
||||
extension Logger {
|
||||
private static let loggers: OSAllocatedUnfairLock<[String: Logger]> = OSAllocatedUnfairLock(initialState: [:])
|
||||
|
||||
public dynamic static var subsystem: String { "com.hackclub.burrow" }
|
||||
|
||||
public static func logger(for type: Any.Type) -> Logger {
|
||||
let category = String(describing: type)
|
||||
let logger = loggers.withLock { loggers in
|
||||
if let logger = loggers[category] { return logger }
|
||||
let logger = Logger(subsystem: subsystem, category: category)
|
||||
loggers[category] = logger
|
||||
return logger
|
||||
}
|
||||
return logger
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue