sse

package
v0.22.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishAuditLogsChanged

func PublishAuditLogsChanged()

PublishAuditLogsChanged notifies clients that audit logs have changed

func PublishGroupsChanged

func PublishGroupsChanged(groupId string)

PublishGroupsChanged notifies clients that a group has changed

func PublishGroupsDeleted

func PublishGroupsDeleted(groupId string)

PublishGroupsDeleted notifies clients that a group was deleted

func PublishRolesChanged

func PublishRolesChanged(roleId string)

PublishRolesChanged notifies clients that a role has changed

func PublishRolesDeleted

func PublishRolesDeleted(roleId string)

PublishRolesDeleted notifies clients that a role was deleted

func PublishSessionsChanged

func PublishSessionsChanged(sessionId string)

PublishSessionsChanged notifies clients that a session has changed

func PublishSessionsDeleted

func PublishSessionsDeleted(sessionId string)

PublishSessionsDeleted notifies clients that a session was deleted

func PublishSpaceChanged

func PublishSpaceChanged(spaceId, userId string, optionalIds ...string)

PublishSpaceChanged notifies clients that a space was created, updated, or state changed Parameters: spaceId, userId, optional sharedWithUserId, optional previousUserId

func PublishSpaceDeleted

func PublishSpaceDeleted(spaceId, userId string)

PublishSpaceDeleted notifies clients that a space was deleted

func PublishTemplateVarsChanged

func PublishTemplateVarsChanged(templateVarId string)

PublishTemplateVarsChanged notifies clients that a template variable has changed

func PublishTemplateVarsDeleted

func PublishTemplateVarsDeleted(templateVarId string)

PublishTemplateVarsDeleted notifies clients that a template variable was deleted

func PublishTemplatesChanged

func PublishTemplatesChanged(templateId string)

PublishTemplatesChanged notifies clients that a template has changed

func PublishTemplatesDeleted

func PublishTemplatesDeleted(templateId string)

PublishTemplatesDeleted notifies clients that a template was deleted

func PublishTokensChanged

func PublishTokensChanged(tokenId string)

PublishTokensChanged notifies clients that a token has changed

func PublishTokensDeleted

func PublishTokensDeleted(tokenId string)

PublishTokensDeleted notifies clients that a token was deleted

func PublishTunnelsChanged

func PublishTunnelsChanged(tunnelId string)

PublishTunnelsChanged notifies clients that a tunnel has changed

func PublishTunnelsDeleted

func PublishTunnelsDeleted(tunnelId string)

PublishTunnelsDeleted notifies clients that a tunnel was deleted

func PublishUsersChanged

func PublishUsersChanged(userId string)

PublishUsersChanged notifies clients that a user has changed

func PublishUsersDeleted

func PublishUsersDeleted(userId string)

PublishUsersDeleted notifies clients that a user was deleted

func PublishVolumesChanged

func PublishVolumesChanged(volumeId string)

PublishVolumesChanged notifies clients that a volume has changed

func PublishVolumesDeleted

func PublishVolumesDeleted(volumeId string)

PublishVolumesDeleted notifies clients that a volume was deleted

Types

type Client

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

Client represents a connected SSE client

func (*Client) Close

func (c *Client) Close()

Close unregisters a client from the hub

func (*Client) Send

func (c *Client) Send() <-chan []byte

Send returns the channel for receiving events

type Event

type Event struct {
	Type    EventType   `json:"type"`
	Payload interface{} `json:"payload,omitempty"`
}

Event represents an SSE event to be sent to clients

type EventType

type EventType string

EventType represents the type of SSE event

const (
	EventGroupsChanged       EventType = "groups:changed"
	EventGroupsDeleted       EventType = "groups:deleted"
	EventRolesChanged        EventType = "roles:changed"
	EventRolesDeleted        EventType = "roles:deleted"
	EventTemplatesChanged    EventType = "templates:changed"
	EventTemplatesDeleted    EventType = "templates:deleted"
	EventTemplateVarsChanged EventType = "templatevars:changed"
	EventTemplateVarsDeleted EventType = "templatevars:deleted"
	EventUsersChanged        EventType = "users:changed"
	EventUsersDeleted        EventType = "users:deleted"
	EventTokensChanged       EventType = "tokens:changed"
	EventTokensDeleted       EventType = "tokens:deleted"
	EventVolumesChanged      EventType = "volumes:changed"
	EventVolumesDeleted      EventType = "volumes:deleted"
	EventSessionsChanged     EventType = "sessions:changed"
	EventSessionsDeleted     EventType = "sessions:deleted"
	EventTunnelsChanged      EventType = "tunnels:changed"
	EventTunnelsDeleted      EventType = "tunnels:deleted"
	EventAuditLogsChanged    EventType = "auditlogs:changed"

	// Space events for frequently changing data
	EventSpaceChanged EventType = "space:changed"
	EventSpaceDeleted EventType = "space:deleted"

	// Authentication events
	EventAuthRequired EventType = "auth:required"
)

Resource change events - *:changed for creates/updates, *:deleted for deletions

type Hub

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

Hub manages all SSE client connections and event broadcasting

func GetHub

func GetHub() *Hub

GetHub returns the singleton SSE hub instance

func (*Hub) Broadcast

func (h *Hub) Broadcast(event *Event)

Broadcast sends an event to all connected clients

func (*Hub) BroadcastToUser

func (h *Hub) BroadcastToUser(userId string, event *Event)

BroadcastToUser sends an event to all clients for a specific user

func (*Hub) ClientCount

func (h *Hub) ClientCount() int

ClientCount returns the number of connected clients

func (*Hub) InvalidateSession

func (h *Hub) InvalidateSession(sessionId string)

InvalidateSession sends an auth required event to all clients with a specific session

func (*Hub) NewClient

func (h *Hub) NewClient(userId, sessionId string) *Client

NewClient creates a new SSE client and registers it with the hub

func (*Hub) Shutdown

func (h *Hub) Shutdown()

Shutdown closes all client connections and stops the hub

func (*Hub) Start

func (h *Hub) Start()

Start begins the hub's event processing loop

type ResourcePayload

type ResourcePayload struct {
	Id               string `json:"id"`
	UserId           string `json:"user_id,omitempty"`
	SharedWithUserId string `json:"shared_with_user_id,omitempty"`
	PreviousUserId   string `json:"previous_user_id,omitempty"`
}

ResourcePayload contains data for resource-specific events

Jump to

Keyboard shortcuts

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