Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor client construction #43

Merged
merged 5 commits into from
Oct 28, 2020
Merged

Refactor client construction #43

merged 5 commits into from
Oct 28, 2020

Conversation

sfackler
Copy link
Member

@sfackler sfackler commented Oct 20, 2020

Before this PR

Clients were constructed via a new function that took 5 arguments. Configuration updates were handled by creating a RefreshHandle from the client and calling a method on that.

After this PR

==COMMIT_MSG==
Client construction has been refactored to use the refreshables crate and builder-style types.
==COMMIT_MSG==

The new API more closely matches Dialogue, and should be significantly nicer to work with.

  • The serde-deserializable config types have had all of their "magic" removed, and map directly to the serialized representation.
  • Clients are now constructed via a Builder type to avoid having to pass tons of arguments into a function. The service name and user agent are required, but everything else, including metric registries, is optional, making tests a little bit easier to write.
  • There is a new ClientFactory which takes a Refreshable<ServicesConfig> and creates live-updating clients for the services within the configuration. While this is currently very simple and just creates a new client every time, it can be updated in the future to cache clients like Dialogue so that connection pools, node status, etc can be shared.
  • Server QoS, service error, and idempotency configuration has been moved out of the client itself and into the builders, and now use enums rather than booleans to allow us to provide more options in the future.

Possible downsides?

Not providing a user agent or service name to the builder results in a panic rather than compile-time error, but that should be something that's caught immediately and fixed if someone forgets.

@changelog-app
Copy link

changelog-app bot commented Oct 20, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Client construction has been refactored to use the refreshable crate and builder-style types.

Check the box to generate changelog(s)

  • Generate changelog entry

/// Sets the security configuration.
///
/// Defaults to an empty configuration.
pub fn security(&mut self, security: SecurityConfig) -> &mut Self {
Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit weird to use the conjure-runtime-config types for security and proxy, but unlike Java we don't really have "universal" trust store and proxy selector types to use instead.

Copy link
Contributor

@jonsyu1 jonsyu1 left a comment

Choose a reason for hiding this comment

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

Nice, this looks great!

@sfackler sfackler merged commit 8227632 into master Oct 28, 2020
@sfackler sfackler deleted the client-factory branch October 28, 2020 00:22
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.

2 participants