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

Introduce rpc.Params #4517

Merged

Conversation

vytautas-karpavicius
Copy link
Contributor

@vytautas-karpavicius vytautas-karpavicius commented Sep 28, 2021

What changed?
Introduced rpc.Params structure that contains required parameters to initialize rpc.Factory.
This decouples Factory from using config directly. It is beneficial for 2 reasons:

  • Allows unit test config part easier
  • Allows reusing the same rpc.Factory in integration tests. Before we had a separate implementation there, with minor differences. Now we can pass those differences via Params.

Also refactored service config retrieval into a function. This is now used in couple of places.

Why?
To reduce code duplication and increase test coverage.

How did you test it?
Additional unit tests for refactored code.
Existing tests.
Starting server locally with removed config section.

Potential risks

Release notes

Documentation Changes

@@ -82,9 +82,6 @@ func startHandler(c *cli.Context) {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGTERM)
for _, svc := range services {
if _, ok := cfg.Services[svc]; !ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to check here. This is checked down the line in server.startService when config is actually needed.

@@ -70,9 +70,6 @@ func newServer(service string, cfg *config.Config) common.Daemon {

// Start starts the server
func (s *server) Start() {
if _, ok := s.cfg.Services[s.name]; !ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to check here. This is checked down the line in server.startService when config is actually needed.

@vytautas-karpavicius vytautas-karpavicius force-pushed the rpc-params branch 3 times, most recently from 8e5a011 to dbbe77f Compare September 28, 2021 12:36
@vytautas-karpavicius vytautas-karpavicius marked this pull request as ready for review September 28, 2021 13:29
@vytautas-karpavicius vytautas-karpavicius requested a review from a team September 28, 2021 13:31
@coveralls
Copy link

coveralls commented Sep 28, 2021

Pull Request Test Coverage Report for Build 7dbcf513-2eba-4372-b423-989aaa2fe515

  • 100 of 120 (83.33%) changed or added relevant lines in 5 files are covered.
  • 52 unchanged lines in 11 files lost coverage.
  • Overall coverage increased (+0.09%) to 56.569%

Changes Missing Coverage Covered Lines Changed/Added Lines %
host/onebox.go 23 24 95.83%
common/rpc/factory.go 40 48 83.33%
cmd/server/cadence/server.go 0 11 0.0%
Files with Coverage Reduction New Missed Lines %
cmd/server/cadence/cadence.go 1 7.53%
common/task/parallelTaskProcessor.go 2 92.48%
common/task/weightedRoundRobinTaskScheduler.go 2 89.64%
service/history/task/transfer_standby_task_executor.go 2 90.85%
service/matching/matcher.go 2 91.46%
service/matching/taskListManager.go 2 74.09%
common/persistence/nosql/nosqlplugin/cassandra/workflow.go 3 50.23%
service/history/queue/timer_gate.go 3 95.83%
common/task/fifoTaskScheduler.go 4 83.51%
common/persistence/nosql/nosqlplugin/cassandra/workflowUtils.go 11 77.83%
Totals Coverage Status
Change from base Build 5e5e395f-890d-4655-bd01-fc1a5370d479: 0.09%
Covered Lines: 80441
Relevant Lines: 142200

💛 - Coveralls

Copy link
Contributor

@mantas-sidlauskas mantas-sidlauskas left a comment

Choose a reason for hiding this comment

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

left one minor comment

Comment on lines 32 to 35
type (
GRPCPortResolver interface {
GetGRPCAddress(service, hostAddress string) (string, error)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this interface really needed?

If so, I would make it more general, as it does nothing specific to grpc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The interface is needed, as integration tests pass different implementation.
But I agree that the name could be more general. Updated it.

@vytautas-karpavicius vytautas-karpavicius merged commit 580c448 into cadence-workflow:master Sep 29, 2021
@vytautas-karpavicius vytautas-karpavicius deleted the rpc-params branch September 29, 2021 07:24
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.

3 participants