From 23c0efa1ff7ee33b3419f2c52fcb913ae8fa7b80 Mon Sep 17 00:00:00 2001 From: Samantha Small Date: Thu, 24 Aug 2023 12:08:41 -0400 Subject: [PATCH] Update Eliza and connectrpc references --- Examples/ElizaCocoaPodsApp/README.md | 6 +- .../AppSources/MenuView.swift | 6 +- .../AppSources/MessagingViewModel.swift | 16 ++--- .../GeneratedSources/eliza.connect.swift | 50 +++++++-------- .../GeneratedSources/eliza.pb.swift | 64 ++++++++++--------- Examples/ElizaSwiftPackageApp/README.md | 6 +- Examples/README.md | 2 +- Examples/proto/eliza.proto | 40 ++++++------ .../Implementation/Codecs/Envelope.swift | 6 +- .../Interceptors/ConnectInterceptor.swift | 4 +- Libraries/Connect/Interfaces/Code.swift | 2 +- .../Interfaces/ConnectEndStreamResponse.swift | 2 +- .../Connect/Interfaces/HTTPResponse.swift | 2 +- .../Connect/Interfaces/NetworkProtocol.swift | 2 +- .../Interfaces/ProtocolClientInterface.swift | 16 ++--- Libraries/Connect/README.md | 2 +- README.md | 18 +++--- .../ConnectTests/ConnectErrorTests.swift | 2 +- 18 files changed, 125 insertions(+), 121 deletions(-) diff --git a/Examples/ElizaCocoaPodsApp/README.md b/Examples/ElizaCocoaPodsApp/README.md index 3c2ceaf4..9d5bc789 100644 --- a/Examples/ElizaCocoaPodsApp/README.md +++ b/Examples/ElizaCocoaPodsApp/README.md @@ -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 diff --git a/Examples/ElizaSharedSources/AppSources/MenuView.swift b/Examples/ElizaSharedSources/AppSources/MenuView.swift index 72c7ced9..1c3e7527 100644 --- a/Examples/ElizaSharedSources/AppSources/MenuView.swift +++ b/Examples/ElizaSharedSources/AppSources/MenuView.swift @@ -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(), @@ -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 { diff --git a/Examples/ElizaSharedSources/AppSources/MessagingViewModel.swift b/Examples/ElizaSharedSources/AppSources/MessagingViewModel.swift index 480839f7..823302b5 100644 --- a/Examples/ElizaSharedSources/AppSources/MessagingViewModel.swift +++ b/Examples/ElizaSharedSources/AppSources/MessagingViewModel.swift @@ -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 { @@ -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 } @@ -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() } diff --git a/Examples/ElizaSharedSources/GeneratedSources/eliza.connect.swift b/Examples/ElizaSharedSources/GeneratedSources/eliza.connect.swift index 46a1893b..5addaace 100644 --- a/Examples/ElizaSharedSources/GeneratedSources/eliza.connect.swift +++ b/Examples/ElizaSharedSources/GeneratedSources/eliza.connect.swift @@ -7,32 +7,32 @@ 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 + func `say`(request: Connectrpc_Eliza_V1_SayRequest, headers: Connect.Headers) async -> ResponseMessage - /// 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 + func `converse`(headers: Connect.Headers) -> any Connect.BidirectionalAsyncStreamInterface - /// 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 + func `introduce`(headers: Connect.Headers) -> any Connect.ServerOnlyAsyncStreamInterface } -/// 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) { @@ -40,17 +40,17 @@ internal final class Buf_Connect_Demo_Eliza_V1_ElizaServiceClient: Buf_Connect_D } @available(iOS 13, *) - internal func `say`(request: Buf_Connect_Demo_Eliza_V1_SayRequest, headers: Connect.Headers = [:]) async -> ResponseMessage { - 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 { + 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 { - return self.client.bidirectionalStream(path: "buf.connect.demo.eliza.v1.ElizaService/Converse", headers: headers) + internal func `converse`(headers: Connect.Headers = [:]) -> any Connect.BidirectionalAsyncStreamInterface { + return self.client.bidirectionalStream(path: "connectrpc.eliza.v1.ElizaService/Converse", headers: headers) } @available(iOS 13, *) - internal func `introduce`(headers: Connect.Headers = [:]) -> any Connect.ServerOnlyAsyncStreamInterface { - return self.client.serverOnlyStream(path: "buf.connect.demo.eliza.v1.ElizaService/Introduce", headers: headers) + internal func `introduce`(headers: Connect.Headers = [:]) -> any Connect.ServerOnlyAsyncStreamInterface { + return self.client.serverOnlyStream(path: "connectrpc.eliza.v1.ElizaService/Introduce", headers: headers) } } diff --git a/Examples/ElizaSharedSources/GeneratedSources/eliza.pb.swift b/Examples/ElizaSharedSources/GeneratedSources/eliza.pb.swift index 7555796c..a3a58d97 100644 --- a/Examples/ElizaSharedSources/GeneratedSources/eliza.pb.swift +++ b/Examples/ElizaSharedSources/GeneratedSources/eliza.pb.swift @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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. @@ -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"), @@ -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"), @@ -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"), @@ -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"), @@ -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"), @@ -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"), @@ -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 diff --git a/Examples/ElizaSwiftPackageApp/README.md b/Examples/ElizaSwiftPackageApp/README.md index bd406722..e90c54c8 100644 --- a/Examples/ElizaSwiftPackageApp/README.md +++ b/Examples/ElizaSwiftPackageApp/README.md @@ -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 diff --git a/Examples/README.md b/Examples/README.md index 223dea99..70c9b585 100644 --- a/Examples/README.md +++ b/Examples/README.md @@ -8,4 +8,4 @@ each supported protocol using either unary or streaming APIs: **Swift Package Manager**. - [`ElizaCocoaPodsApp`](./ElizaCocoaPodsApp): Uses **CocoaPods**. -[eliza-demo]: https://connect.build/demo +[eliza-demo]: https://connectrpc.com/demo diff --git a/Examples/proto/eliza.proto b/Examples/proto/eliza.proto index 3ca7c3c5..b69e30df 100644 --- a/Examples/proto/eliza.proto +++ b/Examples/proto/eliza.proto @@ -14,52 +14,54 @@ syntax = "proto3"; -package buf.connect.demo.eliza.v1; +package connectrpc.eliza.v1; -// 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. +// 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. service ElizaService { - // Say is a unary request demo. This method should allow for a one sentence - // response given a one sentence request. + // Say is a unary RPC. Eliza responds to the prompt with a single sentence. rpc Say(SayRequest) returns (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. rpc Converse(stream ConverseRequest) returns (stream 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. rpc Introduce(IntroduceRequest) returns (stream IntroduceResponse) {} } -// SayRequest describes the sentence said to the ELIZA program. +// SayRequest is a single-sentence request. message SayRequest { string sentence = 1; } -// SayResponse describes the sentence responded by the ELIZA program. +// SayResponse is a single-sentence response. message SayResponse { string sentence = 1; } -// ConverseRequest describes the sentence said to the ELIZA program. +// ConverseRequest is a single sentence request sent as part of a +// back-and-forth conversation. message ConverseRequest { string sentence = 1; } -// ConverseResponse describes the sentence responded by the ELIZA program. +// ConverseResponse is a single sentence response sent in answer to a +// ConverseRequest. message ConverseResponse { string sentence = 1; } -// IntroduceRequest describes a request for details from the ELIZA program. +// IntroduceRequest asks Eliza to introduce itself to the named user. message IntroduceRequest { string name = 1; } -// IntroduceResponse describes the sentence responded by the ELIZA program. +// IntroduceResponse is one sentence of Eliza's introductory monologue. message IntroduceResponse { string sentence = 1; } diff --git a/Libraries/Connect/Implementation/Codecs/Envelope.swift b/Libraries/Connect/Implementation/Codecs/Envelope.swift index 5d581725..d84701ba 100644 --- a/Libraries/Connect/Implementation/Codecs/Envelope.swift +++ b/Libraries/Connect/Implementation/Codecs/Envelope.swift @@ -29,7 +29,7 @@ public enum Envelope { /// Computes the length of the message contained by a packed chunk of data. /// A packed chunk in this context refers to prefixed message data. /// - /// Compliant with Connect streams: https://connect.build/docs/protocol/#streaming-request + /// Compliant with Connect streams: https://connectrpc.com/docs/protocol/#streaming-request /// And gRPC: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#responses /// /// - parameter data: The packed data from which to determine the enveloped message's size. @@ -52,7 +52,7 @@ public enum Envelope { /// Packs a message into an "envelope", adding required header bytes and optionally /// applying compression. /// - /// Compliant with Connect streams: https://connect.build/docs/protocol/#streaming-request + /// Compliant with Connect streams: https://connectrpc.com/docs/protocol/#streaming-request /// And gRPC: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests /// /// - parameter source: The input message data. @@ -83,7 +83,7 @@ public enum Envelope { /// /// **Expects a fully framed envelope, not a partial message.** /// - /// Compliant with Connect streams: https://connect.build/docs/protocol/#streaming-response + /// Compliant with Connect streams: https://connectrpc.com/docs/protocol/#streaming-response /// And gRPC: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#responses /// /// - parameter source: The full envelope's data (header bytes + message bytes). diff --git a/Libraries/Connect/Implementation/Interceptors/ConnectInterceptor.swift b/Libraries/Connect/Implementation/Interceptors/ConnectInterceptor.swift index 062c948f..a965b395 100644 --- a/Libraries/Connect/Implementation/Interceptors/ConnectInterceptor.swift +++ b/Libraries/Connect/Implementation/Interceptors/ConnectInterceptor.swift @@ -15,7 +15,7 @@ import Foundation /// Implementation of the Connect protocol as an interceptor. -/// https://connect.build/docs/protocol +/// https://connectrpc.com/docs/protocol struct ConnectInterceptor { private let config: ProtocolClientConfig @@ -138,7 +138,7 @@ extension ConnectInterceptor: Interceptor { let isEndStream = 0b00000010 & headerByte != 0 if isEndStream { // Expect a valid Connect end stream response, which can simply be {}. - // https://connect.build/docs/protocol#error-end-stream + // https://connectrpc.com/docs/protocol#error-end-stream let response = try JSONDecoder().decode( ConnectEndStreamResponse.self, from: message ) diff --git a/Libraries/Connect/Interfaces/Code.swift b/Libraries/Connect/Interfaces/Code.swift index e411639c..2c88e3a8 100644 --- a/Libraries/Connect/Interfaces/Code.swift +++ b/Libraries/Connect/Interfaces/Code.swift @@ -73,7 +73,7 @@ public enum Code: Int, CaseIterable, Equatable, Sendable { } public static func fromHTTPStatus(_ status: Int) -> Self { - // https://connect.build/docs/protocol#http-to-error-code + // https://connectrpc.com/docs/protocol#http-to-error-code switch status { case 200: return .ok diff --git a/Libraries/Connect/Interfaces/ConnectEndStreamResponse.swift b/Libraries/Connect/Interfaces/ConnectEndStreamResponse.swift index e7ae883d..8c8642c9 100644 --- a/Libraries/Connect/Interfaces/ConnectEndStreamResponse.swift +++ b/Libraries/Connect/Interfaces/ConnectEndStreamResponse.swift @@ -13,7 +13,7 @@ // limitations under the License. /// Structure modeling the final JSON message that is returned by Connect streams: -/// https://connect.build/docs/protocol#error-end-stream +/// https://connectrpc.com/docs/protocol#error-end-stream struct ConnectEndStreamResponse: Sendable { /// Connect error that was returned with the response. let error: ConnectError? diff --git a/Libraries/Connect/Interfaces/HTTPResponse.swift b/Libraries/Connect/Interfaces/HTTPResponse.swift index a3ed4f29..6d42b4ce 100644 --- a/Libraries/Connect/Interfaces/HTTPResponse.swift +++ b/Libraries/Connect/Interfaces/HTTPResponse.swift @@ -17,7 +17,7 @@ import Foundation /// Unary HTTP response received from the server. public struct HTTPResponse: Sendable { /// The status code of the response. - /// See https://connect.build/docs/protocol/#error-codes for more info. + /// See https://connectrpc.com/docs/protocol/#error-codes for more info. public let code: Code /// Response headers specified by the server. public let headers: Headers diff --git a/Libraries/Connect/Interfaces/NetworkProtocol.swift b/Libraries/Connect/Interfaces/NetworkProtocol.swift index fbd7be3d..17063b06 100644 --- a/Libraries/Connect/Interfaces/NetworkProtocol.swift +++ b/Libraries/Connect/Interfaces/NetworkProtocol.swift @@ -15,7 +15,7 @@ /// Protocols that are supported by the library. public enum NetworkProtocol { /// The Connect protocol: - /// https://connect.build/docs/protocol + /// https://connectrpc.com/docs/protocol case connect /// The gRPC-Web protocol: /// https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md diff --git a/Libraries/Connect/Interfaces/ProtocolClientInterface.swift b/Libraries/Connect/Interfaces/ProtocolClientInterface.swift index e99ef77c..709a615e 100644 --- a/Libraries/Connect/Interfaces/ProtocolClientInterface.swift +++ b/Libraries/Connect/Interfaces/ProtocolClientInterface.swift @@ -23,7 +23,7 @@ public protocol ProtocolClientInterface { /// Perform a unary (non-streaming) request. /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Say". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Say". /// - parameter request: The outbound request message. /// - parameter headers: The outbound request headers to include. /// - parameter completion: Closure called when a response or error is received. @@ -47,7 +47,7 @@ public protocol ProtocolClientInterface { /// data indicates that the message is longer, the implementation must wait until the remaining /// bytes are received to pass the data down to its interceptors (and finally the caller). /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Converse". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Converse". /// - parameter headers: The outbound request headers to include. /// - parameter onResult: Closure called whenever new results are received on the stream /// (response headers, messages, trailers, etc.). @@ -69,7 +69,7 @@ public protocol ProtocolClientInterface { /// data indicates that the message is longer, the implementation must wait until the remaining /// bytes are received to pass the data down to its interceptors (and finally the caller). /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Converse". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Converse". /// - parameter headers: The outbound request headers to include. /// - parameter onResult: Closure called whenever new results are received on the stream /// (response headers, messages, trailers, etc.). @@ -91,7 +91,7 @@ public protocol ProtocolClientInterface { /// data indicates that the message is longer, the implementation must wait until the remaining /// bytes are received to pass the data down to its interceptors (and finally the caller). /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Introduce". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Introduce". /// - parameter headers: The outbound request headers to include. /// - parameter onResult: Closure called whenever new results are received on the stream /// (response headers, messages, trailers, etc.). @@ -109,7 +109,7 @@ public protocol ProtocolClientInterface { /// Perform a unary (non-streaming) request. /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Say". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Say". /// - parameter request: The outbound request message. /// - parameter headers: The outbound request headers to include. /// @@ -131,7 +131,7 @@ public protocol ProtocolClientInterface { /// data indicates that the message is longer, the implementation must wait until the remaining /// bytes are received to pass the data down to its interceptors (and finally the caller). /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Converse". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Converse". /// - parameter headers: The outbound request headers to include. /// /// - returns: An interface for sending and receiving data over the stream using async/await. @@ -151,7 +151,7 @@ public protocol ProtocolClientInterface { /// data indicates that the message is longer, the implementation must wait until the remaining /// bytes are received to pass the data down to its interceptors (and finally the caller). /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Converse". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Converse". /// - parameter headers: The outbound request headers to include. /// /// - returns: An interface for sending and receiving data over the stream using async/await. @@ -171,7 +171,7 @@ public protocol ProtocolClientInterface { /// data indicates that the message is longer, the implementation must wait until the remaining /// bytes are received to pass the data down to its interceptors (and finally the caller). /// - /// - parameter path: The RPC path, e.g., "buf.connect.demo.eliza.v1.ElizaService/Introduce". + /// - parameter path: The RPC path, e.g., "connectrpc.eliza.v1.ElizaService/Introduce". /// - parameter headers: The outbound request headers to include. /// /// - returns: An interface for sending and receiving data over the stream using async/await. diff --git a/Libraries/Connect/README.md b/Libraries/Connect/README.md index 0d0b3210..74b337be 100644 --- a/Libraries/Connect/README.md +++ b/Libraries/Connect/README.md @@ -4,4 +4,4 @@ This module contains support for the Connect and gRPC-Web protocols. For gRPC support, you must also include the `ConnectNIO` module. For additional details and tutorials, see the -[Connect-Swift documentation](https://connect.build/docs/swift/getting-started/). +[Connect-Swift documentation](https://connectrpc.com/docs/swift/getting-started/). diff --git a/README.md b/README.md index fdeccc2f..24c05433 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ public final class Eliza_V1_ChatServiceClient: Eliza_V1_ChatServiceClientInterfa public func say(request: Eliza_V1_SayRequest, headers: Headers = [:]) async -> ResponseMessage { - return await self.client.unary(path: "buf.connect.demo.eliza.v1.ElizaService/Say", request: request, headers: headers) + return await self.client.unary(path: "connectrpc.eliza.v1.ElizaService/Say", request: request, headers: headers) } } ``` @@ -128,7 +128,7 @@ a working SwiftUI chat app that uses Connect-Swift! Comprehensive documentation for everything, including [interceptors][interceptors], [mocking/testing][testing], [streaming][streaming], and [error handling][error-handling] -is available on the [connect.build website][getting-started]. +is available on the [connectrpc.com website][getting-started]. ## Example Apps @@ -174,15 +174,15 @@ Offered under the [Apache 2 license](./LICENSE). [connect-crosstest]: https://github.com/bufbuild/connect-crosstest [connect-go]: https://github.com/bufbuild/connect-go [connect-kotlin]: https://github.com/bufbuild/connect-kotlin -[connect-protocol]: https://connect.build/docs/protocol +[connect-protocol]: https://connectrpc.com/docs/protocol [connect-web]: https://www.npmjs.com/package/@bufbuild/connect-web -[error-handling]: https://connect.build/docs/swift/errors -[getting-started]: https://connect.build/docs/swift/getting-started +[error-handling]: https://connectrpc.com/docs/swift/errors +[getting-started]: https://connectrpc.com/docs/swift/getting-started [grpc-protocol]: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md [grpc-web-protocol]: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md -[interceptors]: https://connect.build/docs/swift/interceptors +[interceptors]: https://connectrpc.com/docs/swift/interceptors [protobuf]: https://developers.google.com/protocol-buffers [slack]: https://buf.build/links/slack -[streaming]: https://connect.build/docs/swift/using-clients#using-generated-clients -[swift-pm-integration]: https://connect.build/docs/swift/getting-started#add-the-connect-swift-package -[testing]: https://connect.build/docs/swift/testing +[streaming]: https://connectrpc.com/docs/swift/using-clients#using-generated-clients +[swift-pm-integration]: https://connectrpc.com/docs/swift/getting-started#add-the-connect-swift-package +[testing]: https://connectrpc.com/docs/swift/testing diff --git a/Tests/ConnectLibraryTests/ConnectTests/ConnectErrorTests.swift b/Tests/ConnectLibraryTests/ConnectTests/ConnectErrorTests.swift index 4744fb23..b9ac6f87 100644 --- a/Tests/ConnectLibraryTests/ConnectTests/ConnectErrorTests.swift +++ b/Tests/ConnectLibraryTests/ConnectTests/ConnectErrorTests.swift @@ -84,7 +84,7 @@ final class ConnectErrorTests: XCTestCase { // MARK: - Private private func errorData(expectedDetails: [SwiftProtobuf.Message]) throws -> Data { - // Example error from https://connect.build/docs/protocol/#error-end-stream + // Example error from https://connectrpc.com/docs/protocol/#error-end-stream let dictionary: [String: Any] = [ "code": "unavailable", "message": "overloaded: back off and retry",