mirror of
https://github.com/wisplite/tether.git
synced 2026-05-01 06:22:41 -05:00
fixed an n+1 bug with the query engine, and made it significantly more efficient
This commit is contained in:
+13
-4
@@ -8,13 +8,22 @@ import (
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
ID string
|
||||
Conn *websocket.Conn
|
||||
Send chan []byte
|
||||
ID string
|
||||
Conn *websocket.Conn
|
||||
Send chan []byte
|
||||
AuthID string
|
||||
}
|
||||
|
||||
func NewClient(conn *websocket.Conn) *Client {
|
||||
return &Client{ID: uuid.NewString(), Conn: conn, Send: make(chan []byte, 256)}
|
||||
return &Client{ID: uuid.NewString(), Conn: conn, Send: make(chan []byte, 256), AuthID: ""}
|
||||
}
|
||||
|
||||
func (c *Client) SetAuthID(authID string) {
|
||||
c.AuthID = authID
|
||||
}
|
||||
|
||||
func (c *Client) GetAuthID() string {
|
||||
return c.AuthID
|
||||
}
|
||||
|
||||
func (c *Client) WritePump() {
|
||||
|
||||
@@ -32,6 +32,16 @@ func (t *Tracker) Untrack(c *Client) {
|
||||
delete(t.clients, c.ID)
|
||||
}
|
||||
|
||||
func (t *Tracker) SetAuthID(clientID string, authID string) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
t.clients[clientID].SetAuthID(authID)
|
||||
}
|
||||
|
||||
func (t *Tracker) GetAuthID(clientID string) string {
|
||||
return t.clients[clientID].GetAuthID()
|
||||
}
|
||||
|
||||
func (t *Tracker) SubscribeToQuery(clientID string, query string, params string) {
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user