Skip to content

Conversation

@antstorm
Copy link
Contributor

@antstorm antstorm commented Mar 7, 2021

I'm working on a bigger change that will turn Cadence into an initializable class rather than using a single global instance. This will allow connecting your app to multiple clusters (this is handy for easy migrating from one Cadence cluster to another or more exotic solutions such as client-side sharding).

This is the first step which makes configuration local, passed to all classes that are using it

Copy link

@drewhoskins-stripe drewhoskins-stripe left a comment

Choose a reason for hiding this comment

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

Bullish on the direction!
Looks good as far as I can tell, though could use some documentation.

attr_reader :name, :domain, :task_list, :retry_policy, :timeouts, :headers

def initialize(object, options = {})
def initialize(object, options, defaults = nil)

Choose a reason for hiding this comment

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

Can you add a comment as to what the shape of defaults is and what to pass in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an instance of Cadence::Configuration::Execution, but I see your point, this is immediately visible and can cause confusion. Agree that we need to address it

MAX_FAILED_ATTEMPTS = 50

def initialize(task, domain, workflow_lookup, client, middleware_chain)
def initialize(task, domain, workflow_lookup, connection, middleware_chain, config)

Choose a reason for hiding this comment

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

Would love to see some comments in at least some of these classes, like what's a connection, what's a config, or how do I get them to pass in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, point taken, will think of a solution 👍


def process(task)
client = Cadence::Client.generate
connection = Cadence::Connection.generate(config.for_connection)

Choose a reason for hiding this comment

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

could/should this be done inside of DecisionTaskProcessor.initialize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do this, yes. The benefit of this approach is dependency injection, but I think this one makes sense to move into the DecisionTaskProcessor. I'll fix it, thanks

host = configuration.host
port = configuration.port

hostname = `hostname`

Choose a reason for hiding this comment

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

Socket.gethostname avoids invoking another program

Copy link
Contributor Author

@antstorm antstorm Mar 9, 2021

Choose a reason for hiding this comment

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

Oh, nice, didn't know of this one. I'll add it as a follow-up PR (we had hostname for a while and I want to keep changes related to config in this PR)

).freeze
end

def for_execution

Choose a reason for hiding this comment

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

This seems to only be used for passing in defaults to ExecutionOptions.new. Should this be named default_execution_options instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does make sense, yes

@antstorm antstorm changed the title [WIP] Use local configuration instead of a global one [Refactor] Use local configuration instead of a global one Mar 9, 2021
@antstorm antstorm merged commit 38a081d into master Mar 10, 2021
@antstorm antstorm deleted the local-config branch March 10, 2021 22:10
@antstorm antstorm added the sync pending Marks PRs that are yet to be replayed on Temporal label Mar 15, 2021
@DeRauk DeRauk added synced Marks PRs that have been synchronised with Temporal and removed sync pending Marks PRs that are yet to be replayed on Temporal labels Sep 1, 2021
DeRauk pushed a commit to DeRauk/cadence-ruby that referenced this pull request Jan 19, 2022
* Rename Cadence::Client to Cadence::Connection

* Move away from global configuration

* Ensure correct configuration is passed when generating a poller connection

* Rename Configuration#for_execution to Configuration#default_execution_options

* Move Connection initialization inside the TaskProcessor classes
DeRauk pushed a commit to DeRauk/cadence-ruby that referenced this pull request Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

synced Marks PRs that have been synchronised with Temporal

Development

Successfully merging this pull request may close these issues.

5 participants