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

Create EquinoxCosmosClient abstraction and simplify Equinox.Cosmos usage #203

Merged
merged 17 commits into from
Mar 19, 2020

Conversation

ylibrach
Copy link

Previously, Equinox was creating its own CosmosClient instances, which prevented some testing scenarios as well as made it difficult for consumers to take actions and/or make decisions based on what Equinox was doing (eg, collecting metrics, wrapping calls in resilience policies, etc).

In addition, it was cumbersome for a consumer to get started with producing/consuming a stream - a combination of types needed to be initialized such as Connection, Gateway, Context, BatchingPolicy and Containers.

This PR aims to solve both of those concerns by abstracting Cosmos operations into a consumer-providable EquinoxCosmosClient, and consolidating all operations into just one type - the Context.

Abstracting away base Cosmos operations

  • Equinox will no longer create its own CosmosClient, and will instead have it be provided by consumers through an EquinoxCosmosClient abstraction
  • A default implementation of EquinoxCosmosClient is provided which can be used by consumers that don't wish to have their own explicit implementation. All of its members are virtual and can be overriden
  • Out of the box, Equinox ships with a EquinoxCosmosClientFactory which consumers can use to build multiple instances of the default EquinoxCosmosClient based on common options. In many ways, it can be considered similar to the previous Connector type, which no longer exists
  • EquinoxCosmosClientFactory is an optional type for consumers to use; consumers can choose not to use the factory pattern at all, create their own factory, or inherit from the Equinox-provided type and override its methods and/or create their own methods

Simplifying the consumer surface area

  • Connection, Gateway, BatchingPolicy and Containers types are no longer needed to be provided by the consumer; however, they are still available within the Equinox.Cosmos.Internal namespace for now if an unforeseen need arises
  • Context and EquinoxCosmosClient are the only two types that need to be created by a consumer when using Equinox.Cosmos

@ylibrach ylibrach requested a review from bartelink March 10, 2020 16:33
Copy link
Collaborator

@bartelink bartelink left a comment

Choose a reason for hiding this comment

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

On the whole, this feels very good
It does seem like some more juggling of names might be in order before it completely works
Stating the obvious, reformatting/moving of code in a PR like this makes it very hard to see the wood for the trees - I'll likely put some preparatory commits onto the base branch to reduce this a bit

@ylibrach ylibrach merged commit 5f7469f into cosmossdk4 Mar 19, 2020
@bartelink bartelink deleted the client-abstractions branch March 19, 2020 17:14
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