feat: adding channelSize to safe websocket client

This commit is contained in:
2025-09-27 05:27:57 +07:00
parent b96e574726
commit 4792d638c1

View File

@@ -101,7 +101,7 @@ func (b *SafeWebsocketClientBuilder) RawQuery(rawQuery string) *SafeWebsocketCli
return b
}
func (b *SafeWebsocketClientBuilder) Build() (*SafeWebsocketClient, error) {
func (b *SafeWebsocketClientBuilder) Build(channelSize int) (*SafeWebsocketClient, error) {
if err := internal.NilChecker(b); err != nil {
return nil, err
}
@@ -117,7 +117,7 @@ func (b *SafeWebsocketClientBuilder) Build() (*SafeWebsocketClient, error) {
useTLS: useTLS,
path: b.path,
rawQuery: b.rawQuery,
dataChannel: make(chan []byte, 1),
dataChannel: make(chan []byte, channelSize),
mu: custom_rwmutex.NewCustomRwMutex(),
reconnectCh: make(chan struct{}, 1),
isConnected: false,
@@ -275,6 +275,9 @@ func (wsClient *SafeWebsocketClient) reconnectHandler() {
backoff := 1 * time.Second
maxBackoff := 30 * time.Second
for {
if wsClient.ctx == nil {
continue
}
select {
case <-wsClient.reconnectCh:
log.Println("Reconnect triggered")