-
Notifications
You must be signed in to change notification settings - Fork 131
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
Improved Go version of Part 2 #106
Conversation
This is a complete transliteration of the Java code but more or less idiomatic Go and driver config to enable shard awareness.
Slightly modified and with an asciiart twist.
This version uses github.com/scylladb/gocqlx to make the code much more clean and readable.
@dahankzter who can help with a review? |
Any of the Go programmers but ideally Michal.
It's very simple though and much nicer than the raw examples in the earlier
versions.
…On Thu, 12 Dec 2019, 12:55 Tzach Livyatan, ***@***.***> wrote:
@dahankzter <https://github.com/dahankzter> who can help with a review?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#106?email_source=notifications&email_token=AABJYU5SQACFRBDWSTEZOALQYIRENA5CNFSM4JZ4I4Q2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGWNY4Q#issuecomment-564976754>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABJYU6RX77JLKDGILY3DF3QYIRENANCNFSM4JZ4I4QQ>
.
|
|
||
import ( | ||
"goapp/internal/log" | ||
"goapp/internal/scylla" |
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.
What's that?
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.
Internal packages for the module.
"github.com/scylladb/gocqlx" | ||
"github.com/scylladb/gocqlx/qb" | ||
"github.com/scylladb/gocqlx/table" | ||
"go.uber.org/zap" |
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.
Another logger?
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.
hmm... Let me check.
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.
Zap is the logger. The other import just defines a helper method to create the otherwise quite verbose setup of the zap logger.
Perhaps we should use golog?
mms/go/cmd/gocqlxapp/main.go
Outdated
"go.uber.org/zap" | ||
) | ||
|
||
var ( |
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'd suggest to delete this group and use :=
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.
They are contained in a separate little helper struct now.
mms/go/cmd/gocqlxapp/main.go
Outdated
PictureLocation string `db:"picture_location"` | ||
} | ||
|
||
func init() { |
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.
Init is a bad practice. Use struct instead
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.
Why is it bad for main apps?
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.
Removed init for specific global assignment.
} | ||
} | ||
|
||
func insertQuery(session *gocql.Session, firstName, lastName, address, pictureLocation string, logger *zap.Logger) { |
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.
Passing all those params and building the Record is strange
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.
Yes, I kept it for similarities with the other examples.
@tzach please merge |
This uses
github.com/scylladb/gocqlx
to create a much nicer developer experiencewith clear and safe code.