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

Trd 251 tradelogs allow register webhook on new trade #38

Merged

Conversation

ngocthanh1389
Copy link
Member

No description provided.

}

func (b *Broadcaster) addConn(event, maker string, conn *websocket.Conn) {
ID := xid.New().String()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ID := xid.New().String()
id := xid.New().String()

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +72 to +87
for {
b.mu.Lock()
for _, cons := range b.clients {
for id, c := range cons {
if _, _, err := c.ws.ReadMessage(); err != nil {
if websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseGoingAway, websocket.CloseNoStatusReceived) {
b.l.Infow("socket is closed", "id", id)
delete(cons, id)
}
}
}
}
b.mu.Unlock()
time.Sleep(time.Minute)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

❓ what will be returned if there is no message

Copy link
Member Author

Choose a reason for hiding this comment

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

no msg, read message will return nil

Comment on lines +13 to +19

type Con struct {
id string
ws *websocket.Conn
eventHash string
maker string
}
Copy link
Member

Choose a reason for hiding this comment

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

What if a connection want to subscribe to multiple eventHashes and makers?

Copy link
Member Author

Choose a reason for hiding this comment

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

we don't do that here

Copy link
Member

@Haiss2 Haiss2 left a comment

Choose a reason for hiding this comment

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

LGTM

@ngocthanh1389 ngocthanh1389 merged commit a80ec8c into main Apr 12, 2024
6 checks passed
@ngocthanh1389 ngocthanh1389 deleted the TRD-251-tradelogs-allow-register-webhook-on-new-trade branch April 12, 2024 07:46
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.

3 participants