Skip to content

Implement Channel builder#2675

Draft
nathanielford wants to merge 8 commits into
grpc:masterfrom
nathanielford:implement/channel-builder
Draft

Implement Channel builder#2675
nathanielford wants to merge 8 commits into
grpc:masterfrom
nathanielford:implement/channel-builder

Conversation

@nathanielford
Copy link
Copy Markdown
Contributor

Introduces a type-builder Channel builder for creating new Channels, using an idiomatic pattern for adding in configuration options.

Motivation

In order to flexibly and ergonomically provide for channel configuration on construction, the type builder is introduced. This allows users to construct channels in a manner similar to:

let channel = Channel::builder("https://api.darkcave.com:443")
    .credential(my_creds)
    .runtime(my_runtime)
    .override_authority("arrow.wumpus.api")
    // ... any other options.
    .build();  // No error is returned here

Solution

The solution uses a 'type builder' so that users can build up their channel configuration over various calls, and the compiler can catch type issues. This also allows us to encapsulate various ergonomics (such as default selection of runtime). This PR implements the critical values at this time and defers additional optional values not being used until a later point. It also leaves work around the internals of the PersistentChannel/ActiveChannel for a future PR.

Because the public API is being altered, this requires a version bump.

…tials.

To support creating channels with various credentials configurations, we need to accept different credential representations (such as concrete types or Arc-wrapped trait objects). This trait provides a common conversion interface to type-erase these representations internally. This refactoring is isolated to its own commit to keep subsequent feature commits focused and legible.
Make Channel::builder public and update ChannelBuilder::credentials to accept impl IntoDynChannelCredentials instead of Arc<dyn DynChannelCredentials>.
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.

1 participant