refactor: phase 2 integrated new dialer into worker

This commit is contained in:
Jay
2026-06-06 17:32:03 -04:00
parent 7bc576ed98
commit a46e9f7ad8
13 changed files with 366 additions and 1026 deletions
+14 -9
View File
@@ -2,6 +2,7 @@ package transport
import (
"context"
"errors"
"log/slog"
"net"
"net/http"
@@ -12,6 +13,14 @@ import (
"github.com/gorilla/websocket"
)
// ----------------------------------------------------------------------------
// Errors
// ----------------------------------------------------------------------------
var (
ErrNilDialFunc = errors.New("dial func cannot be nil")
)
// ----------------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------------
@@ -51,11 +60,11 @@ func (d *GorillaDialer) DialContext(
// Retry Dialer
// ----------------------------------------------------------------------------
func AcquireSocket(
func DialWithRetry(
ctx context.Context,
mgr *RetryManager,
dialFn func(ctx context.Context) (types.Socket, error),
errCh chan<- error,
dialFn func(context.Context) (types.Socket, error),
onError func(error),
handler slog.Handler,
) (types.Socket, error) {
if component.FromContext(ctx) == nil {
@@ -88,12 +97,8 @@ func AcquireSocket(
return socket, nil
}
if errCh != nil {
select {
case <-ctx.Done():
return nil, ctx.Err()
case errCh <- err:
}
if onError != nil {
onError(err)
}
if mgr == nil {