ws

package
v0.0.0-...-311e34c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package ws implements the WebSocket client for Flashduty communication.

Index

Constants

This section is empty.

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) *Client

NewClient creates a new WebSocket client.

func (*Client) Close

func (c *Client) Close() error

Close closes the client connection.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

Connect establishes a WebSocket connection to Flashduty.

func (*Client) Labels

func (c *Client) Labels() []string

Labels returns the worknode labels from welcome message.

func (*Client) Name

func (c *Client) Name() string

Name returns the worknode name from welcome message.

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

Run starts the client's read/write loops.

func (*Client) RunWithReconnect

func (c *Client) RunWithReconnect(ctx context.Context) error

RunWithReconnect runs the client with automatic reconnection.

func (*Client) Send

func (c *Client) Send(msg *protocol.Message) error

Send sends a message to Flashduty.

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) WorknodeID

func (c *Client) WorknodeID() string

WorknodeID returns the worknode ID assigned by Flashduty.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler handles incoming WebSocket messages.

func NewHandler

func NewHandler(ws *workspace.Workspace) *Handler

NewHandler creates a new message handler.

func (*Handler) CancelAllTasks

func (h *Handler) CancelAllTasks()

CancelAllTasks cancels all running tasks.

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, msg *protocol.Message) error

Handle handles an incoming message.

func (*Handler) RunningTaskCount

func (h *Handler) RunningTaskCount() int

RunningTaskCount returns the number of running tasks.

func (*Handler) SetClient

func (h *Handler) SetClient(client *Client)

SetClient sets the WebSocket client for sending responses.

func (*Handler) WaitForTasks

func (h *Handler) WaitForTasks(timeout time.Duration) bool

WaitForTasks waits for all running tasks to complete with a timeout. Returns true if all tasks completed, false if timeout occurred.

type MessageHandler

type MessageHandler func(ctx context.Context, msg *protocol.Message) error

MessageHandler handles incoming messages from Flashduty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL