Documentation
¶
Overview ¶
Package conn is the worker WebSocket dialer, backoff, and frame IO.
Vendored from bot-agent internal/agent/conn (Apache-2.0, see ../NOTICE). DD changes: the read limit, envelope and version come from internal/workerproto; frames are encoded with encoding/json; DialStatus returns the HTTP status of a refused upgrade.
Index ¶
- Variables
- func Dial(ctx context.Context, rawURL, bearer string) (*websocket.Conn, error)
- func DialStatus(ctx context.Context, rawURL, bearer string) (*websocket.Conn, int, error)
- func ReadFrame(ctx context.Context, c *websocket.Conn) (string, []byte, error)
- func Safe(err error, secrets ...string) string
- func WriteJSON(ctx context.Context, c *websocket.Conn, v any) error
- func WriteRaw(ctx context.Context, c *websocket.Conn, b []byte) error
- type Backoff
Constants ¶
This section is empty.
Variables ¶
var ErrForbidden = errors.New("forbidden")
ErrForbidden stops reconnects until the process is restarted.
var ErrReconnect = errors.New("reconnect")
ErrReconnect means enrollment finished and the caller should dial again.
var ErrUnauthenticated = errors.New("unauthenticated")
ErrUnauthenticated asks the caller to back off to 30s and keep trying.
Functions ¶
func DialStatus ¶
DialStatus is Dial that also returns the HTTP status of a refused upgrade (0 when there was no response), so the caller can tell a revoked credential (401) from a network failure. DD addition.
Types ¶
type Backoff ¶
type Backoff struct {
// contains filtered or unexported fields
}
Backoff is 1s, doubling, capped at 30s. Take applies ±20% jitter.
func (*Backoff) Next ¶
Next is the delay that the following Take will jitter, before Take advances it.
func (*Backoff) Reset ¶
func (b *Backoff) Reset()
Reset runs after hello_ok so the next failure waits about 1s.