-
Notifications
You must be signed in to change notification settings - Fork 877
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
Move shard.Engine interface into history/interfaces package #7043
base: main
Are you sure you want to change the base?
Conversation
service/history/common/engine.go
Outdated
@@ -24,7 +24,7 @@ | |||
|
|||
//go:generate mockgen -copyright_file ../../../LICENSE -package $GOPACKAGE -source $GOFILE -destination engine_mock.go | |||
|
|||
package shard | |||
package common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: initially I want to move it to something like "internal/common" or "internal/interfaces". But we can't do this - this is used in functional tests, and we technically put functional tests into separate "package"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still unclear on the problem you're trying to solve with this refactoring. Let's discuss this offline.
I'd like to be part of the discussion as well.
Also want to understand what the structure will eventually look like, plans for other interfaces, MutableState, Context, ShardContext etc. To me, it feels like this is a big refactoring project and need some doc describing the overall plan. |
service/history/common/engine.go
Outdated
@@ -24,7 +24,7 @@ | |||
|
|||
//go:generate mockgen -copyright_file ../../../LICENSE -package $GOPACKAGE -source $GOFILE -destination engine_mock.go | |||
|
|||
package shard | |||
package common |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can call this historyinterfaces
to avoid the need to disambiguate the imports and have a name that better conveys the purpose of the package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think about that, but ultimately decide against it.
'interfaces` is better.
- it is/will be consistent.
- purpose is clear
- no redundant info (
history
is already part ofimport ".../history/..."
) - name is at least shorter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinion on the new structure, mostly the naming.
Agree with @yycptt that it'd be better to understand the end goal before going to the implementation.
I think our problem is that we're going against Go best practices and defining interfaces on the producer side instead of the consumer.
If we stop using mocks and the pattern of interface + Impl
, we wouldn't need to change the structure.
"one step at a time". I don't think we can avoid interfaces altogether (I also think we shoulnd't, but that is another story). |
Short term goal - better code structure, better ownership hierarchy, remove access to persistence layer, remove not needed dependencies. |
e1d36f1
to
a3ad883
Compare
After all back and forth and offline discussions, I am ready to approve this. |
What changed?
"Engine" interface was moved to "history/common" module
Why?
Part of bigger refactoring efforts.
Goal is to reduce code entanglement, by separating interfaces and implementation, for some major components.
Currently, in lots of cases, interface and implementation are in a single file. This bloats the dependency graph, and introduce bad practices when dealing with "module cyclic dependency" error.
How did you test it?
unit tests