Skip to content

Conversation

dboyliao
Copy link
Collaborator

@dboyliao dboyliao commented Mar 5, 2025

In this PR:

  1. Implement handlers to bridge Coinbase events to standard events
  2. Modify on-connection handler: publish balance snapshot event on connection.

@dboyliao dboyliao added the feature feature means adding new functionality for users from all perspective, e.g., web, cli, deployment label Mar 5, 2025
for _, subCmd := range subCmds {
err := s.Conn.WriteJSON(subCmd)
if err != nil {
log.WithError(err).Errorf("subscription error: %v", subCmd)
Copy link
Collaborator

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.

Copy link
Collaborator Author

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")
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@dboyliao dboyliao marked this pull request as draft March 6, 2025 08:32
@dboyliao dboyliao force-pushed the dboy/coinbase-stream-pr3 branch from 86bfeb2 to 1266af0 Compare March 6, 2025 09:41
Base automatically changed from dboy/coinbase-stream-pr2 to main March 6, 2025 09:54
@dboyliao dboyliao force-pushed the dboy/coinbase-stream-pr3 branch from 1266af0 to 1d69a90 Compare March 6, 2025 09:57
@dboyliao dboyliao requested a review from ycdesu March 7, 2025 01:02
@dboyliao dboyliao marked this pull request as ready for review March 7, 2025 01:07
@dboyliao dboyliao requested a review from c9s March 7, 2025 01:07
}

func (c channelType) String() string {
return fmt.Sprintf(`(Name: %s,
Copy link
Collaborator

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?
image

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.

Copy link
Collaborator Author

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.

Comment on lines 32 to 33
Key: ****,
Passphrase: ****,
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Comment on lines 44 to 42
func (msg subscribeMsgType1) String() string {
return fmt.Sprintf(`(Type: %s,
Channels: %s,
%s)`, msg.Type, msg.Channels, msg.authMsg.String())
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another tab
Uploading image.png…

@dboyliao dboyliao force-pushed the dboy/coinbase-stream-pr3 branch from f34d3cc to 63ba0bd Compare March 7, 2025 07:17
@dboyliao dboyliao force-pushed the dboy/coinbase-stream-pr3 branch from 63ba0bd to 92946f1 Compare March 7, 2025 07:21
@dboyliao dboyliao requested a review from ycdesu March 7, 2025 07:24
@dboyliao dboyliao changed the title FEAT: [exchange] (coinbase) implement stream message handlers FEAT: [coinbase] implement stream message handlers Mar 7, 2025
@dboyliao dboyliao merged commit 73beb00 into main Mar 7, 2025
3 checks passed
@dboyliao dboyliao deleted the dboy/coinbase-stream-pr3 branch March 7, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature feature means adding new functionality for users from all perspective, e.g., web, cli, deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants