Skip to content

Conversation

@rebello95
Copy link
Collaborator

This PR replaces the ClientOption interface and all its conformers with a new struct-based configuration. This has several benefits:

  • Enforces that exactly one protocol implementation (Connect or gRPC-Web) is specified at compile-time. Prior, any number could be specified and would cause invalid requests to be serialized
  • Enforces that either both the minimum compression size threshold and compression pool are specified for requests, or neither
  • Clearer default values (defaults can be seen simply by looking at ProtocolClientConfig.init)
  • Removes the need for some types like IdentityCompressionPool

The original approach was taken to more clearly mirror Go, but this new implementation is better for Swift.

public let compressionPools: [String: CompressionPool]
/// Codec to use for serializing/deserializing requests/responses.
/// Protocol to use for requests and streams.
public let networkProtocol: NetworkProtocol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make this rename as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I couldn't use protocol since it's a reserved word in swift when lowercased and it'd make ergonomics worse by having to use code tags

@rebello95 rebello95 merged commit 6f5afc5 into main Jan 27, 2023
@rebello95 rebello95 deleted the config-changes branch January 27, 2023 14:01
nakajima added a commit to xmtp/xmtp-ios that referenced this pull request Jan 31, 2023
connectrpc/connect-swift#92 changed how client init worked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants