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

Separate history engine factory from handler #2409

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

yycptt
Copy link
Member

@yycptt yycptt commented Jan 24, 2022

What changed?

  • Separate history engine factory implementation from history handler
  • Clean up some unnecessary parameters after the separation

Why?

  • Existing initialization logic contains a cycle: history handler depend on shard controller, but shard controller needs to use history hander as the engine factory. This is currently done via fx.Invoke and quite confusing when reading the code.
  • New dependency graph will look like the following: various resources -> host level components -> shard controller and engine factory -> history handler.

How did you test it?

  • Run sample locally

Potential risks

Is hotfix candidate?
no

@yycptt yycptt requested a review from a team January 24, 2022 18:10
Copy link
Contributor

@wxing1292 wxing1292 left a comment

Choose a reason for hiding this comment

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

can we get rid of the history engine factory?

@alexshtin
Copy link
Member

alexshtin commented Jan 24, 2022

CreateEngine is trivial. All fun stuff is in NewEngineWithShardContext which is actual factory. I would leave factory as its responsibility is clear: create engine per shard, which can't be done use fx during server start. But I would:

  1. Rename NewEngineWithShardContext to NewEngine and make it trivial constructor (assign fields with passed values),
  2. Move most of the code from NewEngineWithShardContext to CreateEngine. All New* calls should be either in factory or in provider.

You can do this in separate PR.

@yycptt
Copy link
Member Author

yycptt commented Jan 24, 2022

can we get rid of the history engine factory?

All fun stuff is in NewEngineWithShardContext which is actual factory.
All New* calls should be either in factory or in provider.

Looks like we have some quite different opinions around whether or not engine factory is needed or not and exactly what should be done there. It's probably a good idea to have some discussions and reach consensus before I making further, bigger changes.

@yycptt yycptt merged commit 410b593 into temporalio:master Jan 24, 2022
@yycptt yycptt deleted the history-engine-factory branch January 24, 2022 22:12
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.

4 participants