Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Examples/ElizaCocoaPodsApp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

This example app imports the `Connect` library using CocoaPods,
and provides an interface for
[chatting with Eliza](https://connect.build/demo).
[chatting with Eliza](https://connectrpc.com/demo).

The app has support for chatting using a variety of protocols supported by
the Connect library:

- [Connect](https://connect.build) + unary
- [Connect](https://connect.build) + streaming
- [Connect](https://connectrpc.com) + unary
- [Connect](https://connectrpc.com) + streaming
- [gRPC-Web](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md) + unary
- [gRPC-Web](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md) + streaming

Expand Down
6 changes: 3 additions & 3 deletions Examples/ElizaSharedSources/AppSources/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ extension MessagingConnectionType: Identifiable {

struct MenuView: View {
private func createClient(withProtocol networkProtocol: NetworkProtocol)
-> Buf_Connect_Demo_Eliza_V1_ElizaServiceClient
-> Connectrpc_Eliza_V1_ElizaServiceClient
{
let host = "https://demo.connect.build"
let host = "https://demo.connectrpc.com"
#if COCOAPODS
let protocolClient = ProtocolClient(
httpClient: URLSessionHTTPClient(),
Expand All @@ -61,7 +61,7 @@ struct MenuView: View {
)
)
#endif
return Buf_Connect_Demo_Eliza_V1_ElizaServiceClient(client: protocolClient)
return Connectrpc_Eliza_V1_ElizaServiceClient(client: protocolClient)
}

var body: some View {
Expand Down
16 changes: 8 additions & 8 deletions Examples/ElizaSharedSources/AppSources/MessagingViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import Connect
import Dispatch
import os.log

private typealias ConverseRequest = Buf_Connect_Demo_Eliza_V1_ConverseRequest
private typealias ConverseResponse = Buf_Connect_Demo_Eliza_V1_ConverseResponse
private typealias ConverseRequest = Connectrpc_Eliza_V1_ConverseRequest
private typealias ConverseResponse = Connectrpc_Eliza_V1_ConverseResponse

private typealias SayRequest = Buf_Connect_Demo_Eliza_V1_SayRequest
private typealias SayResponse = Buf_Connect_Demo_Eliza_V1_SayResponse
private typealias SayRequest = Connectrpc_Eliza_V1_SayRequest
private typealias SayResponse = Connectrpc_Eliza_V1_SayResponse

/// View model that can be injected into a `MessagingView`.
protocol MessagingViewModel: ObservableObject {
Expand All @@ -41,11 +41,11 @@ protocol MessagingViewModel: ObservableObject {
/// View model that uses unary requests for messaging.
@MainActor
final class UnaryMessagingViewModel: MessagingViewModel {
private let client: Buf_Connect_Demo_Eliza_V1_ElizaServiceClientInterface
private let client: Connectrpc_Eliza_V1_ElizaServiceClientInterface

@Published private(set) var messages = [Message]()

init(client: Buf_Connect_Demo_Eliza_V1_ElizaServiceClientInterface) {
init(client: Connectrpc_Eliza_V1_ElizaServiceClientInterface) {
self.client = client
}

Expand All @@ -70,12 +70,12 @@ final class UnaryMessagingViewModel: MessagingViewModel {
/// View model that uses bidirectional streaming for messaging.
@MainActor
final class BidirectionalStreamingMessagingViewModel: MessagingViewModel {
private let client: Buf_Connect_Demo_Eliza_V1_ElizaServiceClientInterface
private let client: Connectrpc_Eliza_V1_ElizaServiceClientInterface
private lazy var elizaStream = self.client.converse(headers: [:])

@Published private(set) var messages = [Message]()

init(client: Buf_Connect_Demo_Eliza_V1_ElizaServiceClientInterface) {
init(client: Connectrpc_Eliza_V1_ElizaServiceClientInterface) {
self.client = client
self.observeResponses()
}
Expand Down
50 changes: 25 additions & 25 deletions Examples/ElizaSharedSources/GeneratedSources/eliza.connect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,50 @@ import Connect
import Foundation
import SwiftProtobuf

/// ElizaService provides a way to talk to the ELIZA, which is a port of
/// the DOCTOR script for Joseph Weizenbaum's original ELIZA program.
/// Created in the mid-1960s at the MIT Artificial Intelligence Laboratory,
/// ELIZA demonstrates the superficiality of human-computer communication.
/// DOCTOR simulates a psychotherapist, and is commonly found as an Easter
/// egg in emacs distributions.
internal protocol Buf_Connect_Demo_Eliza_V1_ElizaServiceClientInterface {

/// Say is a unary request demo. This method should allow for a one sentence
/// response given a one sentence request.
/// ElizaService provides a way to talk to Eliza, a port of the DOCTOR script
/// for Joseph Weizenbaum's original ELIZA program. Created in the mid-1960s at
/// the MIT Artificial Intelligence Laboratory, ELIZA demonstrates the
/// superficiality of human-computer communication. DOCTOR simulates a
/// psychotherapist, and is commonly found as an Easter egg in emacs
/// distributions.
internal protocol Connectrpc_Eliza_V1_ElizaServiceClientInterface {

/// Say is a unary RPC. Eliza responds to the prompt with a single sentence.
@available(iOS 13, *)
func `say`(request: Buf_Connect_Demo_Eliza_V1_SayRequest, headers: Connect.Headers) async -> ResponseMessage<Buf_Connect_Demo_Eliza_V1_SayResponse>
func `say`(request: Connectrpc_Eliza_V1_SayRequest, headers: Connect.Headers) async -> ResponseMessage<Connectrpc_Eliza_V1_SayResponse>

/// Converse is a bi-directional streaming request demo. This method should allow for
/// many requests and many responses.
/// Converse is a bidirectional RPC. The caller may exchange multiple
/// back-and-forth messages with Eliza over a long-lived connection. Eliza
/// responds to each ConverseRequest with a ConverseResponse.
@available(iOS 13, *)
func `converse`(headers: Connect.Headers) -> any Connect.BidirectionalAsyncStreamInterface<Buf_Connect_Demo_Eliza_V1_ConverseRequest, Buf_Connect_Demo_Eliza_V1_ConverseResponse>
func `converse`(headers: Connect.Headers) -> any Connect.BidirectionalAsyncStreamInterface<Connectrpc_Eliza_V1_ConverseRequest, Connectrpc_Eliza_V1_ConverseResponse>

/// Introduce is a server-streaming request demo. This method allows for a single request that will return a series
/// of responses
/// Introduce is a server streaming RPC. Given the caller's name, Eliza
/// returns a stream of sentences to introduce itself.
@available(iOS 13, *)
func `introduce`(headers: Connect.Headers) -> any Connect.ServerOnlyAsyncStreamInterface<Buf_Connect_Demo_Eliza_V1_IntroduceRequest, Buf_Connect_Demo_Eliza_V1_IntroduceResponse>
func `introduce`(headers: Connect.Headers) -> any Connect.ServerOnlyAsyncStreamInterface<Connectrpc_Eliza_V1_IntroduceRequest, Connectrpc_Eliza_V1_IntroduceResponse>
}

/// Concrete implementation of `Buf_Connect_Demo_Eliza_V1_ElizaServiceClientInterface`.
internal final class Buf_Connect_Demo_Eliza_V1_ElizaServiceClient: Buf_Connect_Demo_Eliza_V1_ElizaServiceClientInterface {
/// Concrete implementation of `Connectrpc_Eliza_V1_ElizaServiceClientInterface`.
internal final class Connectrpc_Eliza_V1_ElizaServiceClient: Connectrpc_Eliza_V1_ElizaServiceClientInterface {
private let client: Connect.ProtocolClientInterface

internal init(client: Connect.ProtocolClientInterface) {
self.client = client
}

@available(iOS 13, *)
internal func `say`(request: Buf_Connect_Demo_Eliza_V1_SayRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<Buf_Connect_Demo_Eliza_V1_SayResponse> {
return await self.client.unary(path: "buf.connect.demo.eliza.v1.ElizaService/Say", request: request, headers: headers)
internal func `say`(request: Connectrpc_Eliza_V1_SayRequest, headers: Connect.Headers = [:]) async -> ResponseMessage<Connectrpc_Eliza_V1_SayResponse> {
return await self.client.unary(path: "connectrpc.eliza.v1.ElizaService/Say", request: request, headers: headers)
}

@available(iOS 13, *)
internal func `converse`(headers: Connect.Headers = [:]) -> any Connect.BidirectionalAsyncStreamInterface<Buf_Connect_Demo_Eliza_V1_ConverseRequest, Buf_Connect_Demo_Eliza_V1_ConverseResponse> {
return self.client.bidirectionalStream(path: "buf.connect.demo.eliza.v1.ElizaService/Converse", headers: headers)
internal func `converse`(headers: Connect.Headers = [:]) -> any Connect.BidirectionalAsyncStreamInterface<Connectrpc_Eliza_V1_ConverseRequest, Connectrpc_Eliza_V1_ConverseResponse> {
return self.client.bidirectionalStream(path: "connectrpc.eliza.v1.ElizaService/Converse", headers: headers)
}

@available(iOS 13, *)
internal func `introduce`(headers: Connect.Headers = [:]) -> any Connect.ServerOnlyAsyncStreamInterface<Buf_Connect_Demo_Eliza_V1_IntroduceRequest, Buf_Connect_Demo_Eliza_V1_IntroduceResponse> {
return self.client.serverOnlyStream(path: "buf.connect.demo.eliza.v1.ElizaService/Introduce", headers: headers)
internal func `introduce`(headers: Connect.Headers = [:]) -> any Connect.ServerOnlyAsyncStreamInterface<Connectrpc_Eliza_V1_IntroduceRequest, Connectrpc_Eliza_V1_IntroduceResponse> {
return self.client.serverOnlyStream(path: "connectrpc.eliza.v1.ElizaService/Introduce", headers: headers)
}
}
64 changes: 33 additions & 31 deletions Examples/ElizaSharedSources/GeneratedSources/eliza.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAP
typealias Version = _2
}

/// SayRequest describes the sentence said to the ELIZA program.
struct Buf_Connect_Demo_Eliza_V1_SayRequest {
/// SayRequest is a single-sentence request.
struct Connectrpc_Eliza_V1_SayRequest {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand All @@ -47,8 +47,8 @@ struct Buf_Connect_Demo_Eliza_V1_SayRequest {
init() {}
}

/// SayResponse describes the sentence responded by the ELIZA program.
struct Buf_Connect_Demo_Eliza_V1_SayResponse {
/// SayResponse is a single-sentence response.
struct Connectrpc_Eliza_V1_SayResponse {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand All @@ -60,8 +60,9 @@ struct Buf_Connect_Demo_Eliza_V1_SayResponse {
init() {}
}

/// ConverseRequest describes the sentence said to the ELIZA program.
struct Buf_Connect_Demo_Eliza_V1_ConverseRequest {
/// ConverseRequest is a single sentence request sent as part of a
/// back-and-forth conversation.
struct Connectrpc_Eliza_V1_ConverseRequest {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand All @@ -73,8 +74,9 @@ struct Buf_Connect_Demo_Eliza_V1_ConverseRequest {
init() {}
}

/// ConverseResponse describes the sentence responded by the ELIZA program.
struct Buf_Connect_Demo_Eliza_V1_ConverseResponse {
/// ConverseResponse is a single sentence response sent in answer to a
/// ConverseRequest.
struct Connectrpc_Eliza_V1_ConverseResponse {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand All @@ -86,8 +88,8 @@ struct Buf_Connect_Demo_Eliza_V1_ConverseResponse {
init() {}
}

/// IntroduceRequest describes a request for details from the ELIZA program.
struct Buf_Connect_Demo_Eliza_V1_IntroduceRequest {
/// IntroduceRequest asks Eliza to introduce itself to the named user.
struct Connectrpc_Eliza_V1_IntroduceRequest {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand All @@ -99,8 +101,8 @@ struct Buf_Connect_Demo_Eliza_V1_IntroduceRequest {
init() {}
}

/// IntroduceResponse describes the sentence responded by the ELIZA program.
struct Buf_Connect_Demo_Eliza_V1_IntroduceResponse {
/// IntroduceResponse is one sentence of Eliza's introductory monologue.
struct Connectrpc_Eliza_V1_IntroduceResponse {
// SwiftProtobuf.Message conformance is added in an extension below. See the
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
// methods supported on all messages.
Expand All @@ -113,19 +115,19 @@ struct Buf_Connect_Demo_Eliza_V1_IntroduceResponse {
}

#if swift(>=5.5) && canImport(_Concurrency)
extension Buf_Connect_Demo_Eliza_V1_SayRequest: @unchecked Sendable {}
extension Buf_Connect_Demo_Eliza_V1_SayResponse: @unchecked Sendable {}
extension Buf_Connect_Demo_Eliza_V1_ConverseRequest: @unchecked Sendable {}
extension Buf_Connect_Demo_Eliza_V1_ConverseResponse: @unchecked Sendable {}
extension Buf_Connect_Demo_Eliza_V1_IntroduceRequest: @unchecked Sendable {}
extension Buf_Connect_Demo_Eliza_V1_IntroduceResponse: @unchecked Sendable {}
extension Connectrpc_Eliza_V1_SayRequest: @unchecked Sendable {}
extension Connectrpc_Eliza_V1_SayResponse: @unchecked Sendable {}
extension Connectrpc_Eliza_V1_ConverseRequest: @unchecked Sendable {}
extension Connectrpc_Eliza_V1_ConverseResponse: @unchecked Sendable {}
extension Connectrpc_Eliza_V1_IntroduceRequest: @unchecked Sendable {}
extension Connectrpc_Eliza_V1_IntroduceResponse: @unchecked Sendable {}
#endif // swift(>=5.5) && canImport(_Concurrency)

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "buf.connect.demo.eliza.v1"
fileprivate let _protobuf_package = "connectrpc.eliza.v1"

extension Buf_Connect_Demo_Eliza_V1_SayRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Connectrpc_Eliza_V1_SayRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".SayRequest"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "sentence"),
Expand All @@ -150,14 +152,14 @@ extension Buf_Connect_Demo_Eliza_V1_SayRequest: SwiftProtobuf.Message, SwiftProt
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Buf_Connect_Demo_Eliza_V1_SayRequest, rhs: Buf_Connect_Demo_Eliza_V1_SayRequest) -> Bool {
static func ==(lhs: Connectrpc_Eliza_V1_SayRequest, rhs: Connectrpc_Eliza_V1_SayRequest) -> Bool {
if lhs.sentence != rhs.sentence {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Buf_Connect_Demo_Eliza_V1_SayResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Connectrpc_Eliza_V1_SayResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".SayResponse"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "sentence"),
Expand All @@ -182,14 +184,14 @@ extension Buf_Connect_Demo_Eliza_V1_SayResponse: SwiftProtobuf.Message, SwiftPro
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Buf_Connect_Demo_Eliza_V1_SayResponse, rhs: Buf_Connect_Demo_Eliza_V1_SayResponse) -> Bool {
static func ==(lhs: Connectrpc_Eliza_V1_SayResponse, rhs: Connectrpc_Eliza_V1_SayResponse) -> Bool {
if lhs.sentence != rhs.sentence {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Buf_Connect_Demo_Eliza_V1_ConverseRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Connectrpc_Eliza_V1_ConverseRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".ConverseRequest"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "sentence"),
Expand All @@ -214,14 +216,14 @@ extension Buf_Connect_Demo_Eliza_V1_ConverseRequest: SwiftProtobuf.Message, Swif
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Buf_Connect_Demo_Eliza_V1_ConverseRequest, rhs: Buf_Connect_Demo_Eliza_V1_ConverseRequest) -> Bool {
static func ==(lhs: Connectrpc_Eliza_V1_ConverseRequest, rhs: Connectrpc_Eliza_V1_ConverseRequest) -> Bool {
if lhs.sentence != rhs.sentence {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Buf_Connect_Demo_Eliza_V1_ConverseResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Connectrpc_Eliza_V1_ConverseResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".ConverseResponse"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "sentence"),
Expand All @@ -246,14 +248,14 @@ extension Buf_Connect_Demo_Eliza_V1_ConverseResponse: SwiftProtobuf.Message, Swi
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Buf_Connect_Demo_Eliza_V1_ConverseResponse, rhs: Buf_Connect_Demo_Eliza_V1_ConverseResponse) -> Bool {
static func ==(lhs: Connectrpc_Eliza_V1_ConverseResponse, rhs: Connectrpc_Eliza_V1_ConverseResponse) -> Bool {
if lhs.sentence != rhs.sentence {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Buf_Connect_Demo_Eliza_V1_IntroduceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Connectrpc_Eliza_V1_IntroduceRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".IntroduceRequest"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "name"),
Expand All @@ -278,14 +280,14 @@ extension Buf_Connect_Demo_Eliza_V1_IntroduceRequest: SwiftProtobuf.Message, Swi
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Buf_Connect_Demo_Eliza_V1_IntroduceRequest, rhs: Buf_Connect_Demo_Eliza_V1_IntroduceRequest) -> Bool {
static func ==(lhs: Connectrpc_Eliza_V1_IntroduceRequest, rhs: Connectrpc_Eliza_V1_IntroduceRequest) -> Bool {
if lhs.name != rhs.name {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}

extension Buf_Connect_Demo_Eliza_V1_IntroduceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
extension Connectrpc_Eliza_V1_IntroduceResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
static let protoMessageName: String = _protobuf_package + ".IntroduceResponse"
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "sentence"),
Expand All @@ -310,7 +312,7 @@ extension Buf_Connect_Demo_Eliza_V1_IntroduceResponse: SwiftProtobuf.Message, Sw
try unknownFields.traverse(visitor: &visitor)
}

static func ==(lhs: Buf_Connect_Demo_Eliza_V1_IntroduceResponse, rhs: Buf_Connect_Demo_Eliza_V1_IntroduceResponse) -> Bool {
static func ==(lhs: Connectrpc_Eliza_V1_IntroduceResponse, rhs: Connectrpc_Eliza_V1_IntroduceResponse) -> Bool {
if lhs.sentence != rhs.sentence {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
Expand Down
6 changes: 3 additions & 3 deletions Examples/ElizaSwiftPackageApp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

This example app imports the `Connect` library using Swift Package Manager,
and provides an interface for
[chatting with Eliza](https://buf.build/bufbuild/eliza).
[chatting with Eliza](https://buf.build/connectrpc/eliza).

The app has support for chatting using a variety of protocols supported by
the Connect library:

- [Connect](https://connect.build) + unary
- [Connect](https://connect.build) + streaming
- [Connect](https://connectrpc.com) + unary
- [Connect](https://connectrpc.com) + streaming
- [gRPC](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) + unary (using `ConnectGRPC` + `SwiftNIO`)
- [gRPC](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md) + streaming (using `ConnectGRPC` + `SwiftNIO`)
- [gRPC-Web](https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md) + unary
Expand Down
Loading