-
-
Notifications
You must be signed in to change notification settings - Fork 345
FEAT: [coinbase] implement stream message handlers #1924
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
Conversation
for _, subCmd := range subCmds { | ||
err := s.Conn.WriteJSON(subCmd) | ||
if err != nil { | ||
log.WithError(err).Errorf("subscription error: %v", subCmd) |
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.
Long with %v prints all fields of the struct. The struct contains exchange credentials. We shouldn't log the credentials. Note that error logs may also be sent to 3 party systems such as rollbar or sentry. It leaks the credential.
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.
Fixed.
I also add a test on it.
// query account balances | ||
balances, err := s.exchange.QueryAccountBalances(ctx) | ||
if err != nil { | ||
log.WithError(err).Warn("failed to query account balances, the balance snapshot is initialized with empty balances") |
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.
Should we emit empty balance snapshot when an error is occurred?
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.
After consult with @c9s, we prefer to emit an empty balance.
Will fix it accordingly.
86bfeb2
to
1266af0
Compare
1266af0
to
1d69a90
Compare
} | ||
|
||
func (c channelType) String() string { | ||
return fmt.Sprintf(`(Name: %s, |
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.
Looks like you add a tab
before the value?
You can insert a tab using the \t
directive, but in this case, I guess it's either a typo or you intend to align each line manually. However, when reading logs on different platforms such as Kibana, they may parse the logs differently, which can affect the alignment and make it look different from what you intended.
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.
Got it.
I will simplify the format string.
Key: ****, | ||
Passphrase: ****, |
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 don't have to print all fields of the struct, so we could just ignore key and passphrase
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.
ok
func (msg subscribeMsgType1) String() string { | ||
return fmt.Sprintf(`(Type: %s, | ||
Channels: %s, | ||
%s)`, msg.Type, msg.Channels, msg.authMsg.String()) | ||
} |
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.
…s and enhance connection logic
…ging and prevent leaking the credentials
f34d3cc
to
63ba0bd
Compare
63ba0bd
to
92946f1
Compare
In this PR: