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

Move shard.Engine interface into history/interfaces package #7043

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ychebotarev
Copy link
Contributor

@ychebotarev ychebotarev commented Jan 2, 2025

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

@@ -24,7 +24,7 @@

//go:generate mockgen -copyright_file ../../../LICENSE -package $GOPACKAGE -source $GOFILE -destination engine_mock.go

package shard
package common
Copy link
Contributor Author

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"

Copy link
Member

@bergundy bergundy left a 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.

@yycptt
Copy link
Member

yycptt commented Jan 7, 2025

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.

Part of bigger refactoring efforts.

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.

@ychebotarev ychebotarev requested a review from bergundy January 8, 2025 00:33
@@ -24,7 +24,7 @@

//go:generate mockgen -copyright_file ../../../LICENSE -package $GOPACKAGE -source $GOFILE -destination engine_mock.go

package shard
package common
Copy link
Member

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.

Copy link
Contributor Author

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 of import ".../history/...")
  • name is at least shorter

Copy link
Member

@bergundy bergundy left a 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.

https://go.dev/wiki/CodeReviewComments#interfaces

@ychebotarev
Copy link
Contributor Author

If we stop using mocks and the pattern of interface + Impl, we wouldn't need to change the structure.

https://go.dev/wiki/CodeReviewComments#interfaces

"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).
At least right now we can't avoid them, it will be too big of a change.
Thus separating interface and implementation is a good first step.

@ychebotarev
Copy link
Contributor Author

ychebotarev commented Jan 8, 2025

Agree with @yycptt that it'd be better to understand the end goal before going to the implementation.

Short term goal - better code structure, better ownership hierarchy, remove access to persistence layer, remove not needed dependencies.
Long term - better separation of concerts, better testing, make codebase cleaner and more maintainable, etc.
This sounds a bit abstract.

@ychebotarev ychebotarev force-pushed the y_ref2 branch 2 times, most recently from e1d36f1 to a3ad883 Compare January 9, 2025 20:03
@ychebotarev ychebotarev requested review from stephanos and alexshtin and removed request for bergundy and alexshtin January 9, 2025 23:51
@alexshtin alexshtin changed the title Move Engine interface into common history package Move shard.Engine interface into history/interfaces package Jan 10, 2025
@alexshtin
Copy link
Member

alexshtin commented Jan 10, 2025

After all back and forth and offline discussions, I am ready to approve this.

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