Documentation
¶
Overview ¶
Package ws implements the WebSocket client for Flashduty communication.
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) EnvironmentID() string
- func (c *Client) Labels() []string
- func (c *Client) Name() string
- func (c *Client) Run(ctx context.Context) error
- func (c *Client) RunWithReconnect(ctx context.Context) error
- func (c *Client) Send(msg *protocol.Message) error
- func (c *Client) SendPayload(msgType protocol.MessageType, payload any) error
- func (c *Client) SetOnConnected(f func())
- type Handler
- func (h *Handler) CancelAllTasks()
- func (h *Handler) Handle(ctx context.Context, msg *protocol.Message) error
- func (h *Handler) RunningTaskCount() int
- func (h *Handler) SetClient(client *Client)
- func (h *Handler) SetDisableAutoUpdate(disabled bool)
- func (h *Handler) WaitForTasks(timeout time.Duration) bool
- type MessageHandler
Constants ¶
const (
// DefaultMaxReconnectAttempts is the default max reconnect attempts (0 = unlimited).
DefaultMaxReconnectAttempts = 30
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the WebSocket client for Flashduty communication.
func NewClient ¶
func NewClient(token, apiURL, workspaceRoot string, handler MessageHandler, version string, maxAttempts int) *Client
NewClient creates a new WebSocket client. maxAttempts controls reconnection: 0 = unlimited, >0 = max attempts before giving up.
func (*Client) EnvironmentID ¶ added in v0.0.6
EnvironmentID returns the environment ID assigned by Flashduty.
func (*Client) RunWithReconnect ¶
RunWithReconnect runs the client with automatic reconnection.
func (*Client) SendPayload ¶
func (c *Client) SendPayload(msgType protocol.MessageType, payload any) error
SendPayload sends a message with the given type and payload.
func (*Client) SetOnConnected ¶ added in v0.0.14
func (c *Client) SetOnConnected(f func())
SetOnConnected registers a callback fired once after each successful welcome handshake.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles incoming WebSocket messages.
func NewHandler ¶
func NewHandler(ws *environment.Environment) *Handler
NewHandler creates a new message handler.
func (*Handler) CancelAllTasks ¶
func (h *Handler) CancelAllTasks()
CancelAllTasks cancels all running tasks.
func (*Handler) RunningTaskCount ¶
RunningTaskCount returns the number of running tasks.
func (*Handler) SetDisableAutoUpdate ¶ added in v0.0.14
SetDisableAutoUpdate makes the handler ignore all upgrade advertisements.