-
Notifications
You must be signed in to change notification settings - Fork 297
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
chore: introduce encoding factory #3740
Conversation
f84572f
to
dc6bea1
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #3740 +/- ##
==========================================
- Coverage 68.78% 68.73% -0.06%
==========================================
Files 345 344 -1
Lines 51917 51936 +19
==========================================
- Hits 35711 35698 -13
- Misses 13907 13941 +34
+ Partials 2299 2297 -2
☔ View full report in Codecov by Sentry. |
54744d4
to
c7d6bf7
Compare
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.
Sorry for the partial review, I didn't have the time to complete it. Unfortunately I won't have the time to do so until Wednesday. In any case don't consider these comments as blockers, I just wanted to start a discussion.
warehouse/encoding/encoding.go
Outdated
type LoadFileWriter interface { | ||
type Writer interface { |
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 find the old name a bit more specific actually. Writer
is a very generic name but this interface has the GetLoadFile
for example that makes it really specific.
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.
Make sense. Reverted it.
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 was thinking in terms of the warehouse module only where:
- Readers -> Load file Readers.
- Writers -> Load file singular event writers.
- Loaders -> Load file singular event loaders.
warehouse/encoding/encoding.go
Outdated
} | ||
} | ||
|
||
type Loader interface { |
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 wonder if we could came up with a better name for this one. It lives in the warehouse/encoding
package so if we just call it Loader
it doesn't tell us much about what it is supposed to load and for sure it doesn't look like we can use it to load "everything", right?
As a sidenote, it doesn't look very SOLID. I'm not asking for changes in this regard but I think it's beneficial to mention as a part of a broader discussion to gather your feedback. For example in SOLID the S stands for "Single Responsibility". When looking at this interface though we see that whoever is going to implement this interface will have multiple responsibilities (e.g. parsing in order to understand if a column name is a load time column, ability to add columns, ability to write data somewhere, etc...).
An initial step towards a more SOLID approach, we could split this interface into multiple ones. Luckily with Go the same struct can implicitly implement multiple interfaces so we won't have to create more structs as a result, at least at the beginning. Still having more than one interface here can help grasp the code and can help with understanding the dependencies and responsibilities of these components. Usually this is going to help with tests and mocks as well. I hope it makes sense, feel free to share your thoughts.
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.
Yeah, I completely aggress with having a solid interface.
return []string{}, fmt.Errorf("scanner scan: %w", err) | ||
} | ||
return []string{}, io.EOF | ||
} | ||
|
||
lineBytes := js.scanner.Bytes() | ||
jsonData := make(map[string]string) | ||
jsonData := make(map[string]interface{}) |
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.
This came across while writing the tests. It's expecting only string which will not be the case.
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.
We are doing cast.ToStringE(jsonData[columnName])
to load into the record.
c7d6bf7
to
a187745
Compare
eef8f8a
to
6d3c84b
Compare
6d3c84b
to
b876871
Compare
9182d5d
to
9412809
Compare
9412809
to
e5c4032
Compare
Description
encoding.Init()
.Linear Ticket
Security