websocket

package
v0.5.0-preview2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType              `json:"type"`
	Payload   map[string]interface{} `json:"payload"`
	Timestamp time.Time              `json:"timestamp"`
}

Event represents a websocket event to broadcast

func (*Event) MarshalJSON

func (e *Event) MarshalJSON() ([]byte, error)

MarshalJSON marshals the event to JSON

type EventType

type EventType string

EventType represents the type of event being broadcast

const (
	EventJobRunCreated   EventType = "job_run_created"
	EventJobRunUpdated   EventType = "job_run_updated"
	EventJobRunClaimed   EventType = "job_run_claimed"
	EventJobRunStarted   EventType = "job_run_started"
	EventJobRunProgress  EventType = "job_run_progress"
	EventJobRunCompleted EventType = "job_run_completed"
	EventJobRunCancelled EventType = "job_run_cancelled"
)

type Handler

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

Handler handles websocket connections using Centrifuge

func NewHandler

func NewHandler(hub *Hub, userSvc user.Service, authSvc auth.Service, config *config.Config) *Handler

NewHandler creates a new websocket handler

func (*Handler) Routes

func (h *Handler) Routes() []common.Route

Routes returns the websocket routes

type Hub

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

Hub manages the centrifuge node and channels

func NewHub

func NewHub() *Hub

NewHub creates a new websocket hub using Centrifuge

func (*Hub) Broadcast

func (h *Hub) Broadcast(eventType EventType, payload map[string]interface{})

Broadcast sends an event to the job_runs channel

func (*Hub) ClientCount

func (h *Hub) ClientCount() int

ClientCount returns the number of connected clients

func (*Hub) Node

func (h *Hub) Node() *centrifuge.Node

Node returns the underlying centrifuge node

func (*Hub) Publish

func (h *Hub) Publish(channel string, data []byte) error

Publish publishes a message to a channel

func (*Hub) Start

func (h *Hub) Start(ctx context.Context)

Start starts the hub

func (*Hub) Stop

func (h *Hub) Stop()

Stop stops the hub

type JobRunBroadcaster

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

JobRunBroadcaster broadcasts job run events via websockets

func NewJobRunBroadcaster

func NewJobRunBroadcaster(hub *Hub) *JobRunBroadcaster

NewJobRunBroadcaster creates a new job run broadcaster

func (*JobRunBroadcaster) BroadcastJobRunCancelled

func (b *JobRunBroadcaster) BroadcastJobRunCancelled(run *runs.JobRun)

func (*JobRunBroadcaster) BroadcastJobRunClaimed

func (b *JobRunBroadcaster) BroadcastJobRunClaimed(run *runs.JobRun)

func (*JobRunBroadcaster) BroadcastJobRunCompleted

func (b *JobRunBroadcaster) BroadcastJobRunCompleted(run *runs.JobRun)

func (*JobRunBroadcaster) BroadcastJobRunCreated

func (b *JobRunBroadcaster) BroadcastJobRunCreated(run *runs.JobRun)

func (*JobRunBroadcaster) BroadcastJobRunProgress

func (b *JobRunBroadcaster) BroadcastJobRunProgress(run *runs.JobRun)

func (*JobRunBroadcaster) BroadcastJobRunStarted

func (b *JobRunBroadcaster) BroadcastJobRunStarted(run *runs.JobRun)

Jump to

Keyboard shortcuts

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