daemon

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hub

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

Hub manages connected WebSocket clients and broadcasts events.

func NewHub

func NewHub(bus domain.EventBus) *Hub

NewHub creates a new hub.

func (*Hub) BroadcastMessage

func (h *Hub) BroadcastMessage(channelID int64, channelName string, channelType string, msg domain.Message, mentions []string, threadID *int64, store domain.Store)

BroadcastMessage sends a message.new event to all connected members of a channel.

func (*Hub) BroadcastPresence

func (h *Hub) BroadcastPresence(username string, online bool, state string)

BroadcastPresence sends a presence event to all connected clients.

func (*Hub) BroadcastToRole added in v0.1.0

func (h *Hub) BroadcastToRole(role string, data []byte, store domain.Store)

BroadcastToRole sends a pre-encoded event to all connected clients whose identity has the given role.

func (*Hub) ClearState added in v0.1.0

func (h *Hub) ClearState(username string)

ClearState removes the state entry for a user.

func (*Hub) ClientCount

func (h *Hub) ClientCount() int

ClientCount returns the number of connected clients.

func (*Hub) GetState added in v0.1.0

func (h *Hub) GetState(username string) string

GetState returns the active/idle state for a user.

func (*Hub) Register

func (h *Hub) Register(client *WSClient)

Register adds a client to the hub.

func (*Hub) SetState added in v0.1.0

func (h *Hub) SetState(username, state string)

SetState sets the active/idle state for a user.

func (*Hub) Unregister

func (h *Hub) Unregister(client *WSClient)

Unregister removes a client from the hub.

type PresenceHandler

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

func NewPresenceHandler

func NewPresenceHandler(pongTimeout time.Duration) *PresenceHandler

func (*PresenceHandler) IsOnline added in v0.6.0

func (h *PresenceHandler) IsOnline(username string) bool

func (*PresenceHandler) SendNotification added in v0.6.0

func (h *PresenceHandler) SendNotification(username string, data []byte) error

func (*PresenceHandler) ServeHTTP

func (h *PresenceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type PresenceNotifier added in v0.4.0

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

func NewPresenceNotifier added in v0.4.0

func NewPresenceNotifier(bus domain.EventBus, presence *PresenceHandler, store domain.Store) *PresenceNotifier

func (*PresenceNotifier) Close added in v0.4.0

func (pn *PresenceNotifier) Close()

type RESTHandler added in v0.7.0

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

RESTHandler holds all REST endpoint handlers.

func NewRESTHandler added in v0.7.0

func NewRESTHandler(store domain.Store, hub *Hub, bus domain.EventBus) *RESTHandler

type Server

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

func NewServer

func NewServer(ctx context.Context, addr string, store domain.Store, pongTimeout time.Duration, webhookURL string, bus domain.EventBus, version string, passportURL string, uiDir string) (*Server, error)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (s *Server) Start() error

func (*Server) Store added in v0.2.0

func (s *Server) Store() domain.Store

type SharkfinMCP

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

SharkfinMCP wraps an mcp-go MCPServer with Sharkfin's business logic.

func NewSharkfinMCP

func NewSharkfinMCP(store domain.Store, hub *Hub, presence *PresenceHandler, version string) *SharkfinMCP

NewSharkfinMCP creates the MCP server and registers all tools.

func (*SharkfinMCP) Server

func (s *SharkfinMCP) Server() *server.MCPServer

Server returns the underlying mcp-go MCPServer.

type WSClient

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

WSClient represents a connected WebSocket client.

type WSHandler

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

WSHandler handles WebSocket connections for non-MCP clients.

func NewWSHandler

func NewWSHandler(store domain.Store, hub *Hub, presence *PresenceHandler, pongTimeout time.Duration, version string) *WSHandler

NewWSHandler creates a new WebSocket handler.

func (*WSHandler) ServeHTTP

func (h *WSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type WebhookEvent

type WebhookEvent struct {
	ChannelID   int64
	ChannelName string
	ChannelType string
	From        string
	FromType    string // identity type of sender
	Body        string
	Metadata    *string
	MessageID   int64
	SentAt      time.Time
	Recipients  []string // for legacy global webhook
}

WebhookEvent contains the data needed to fire webhooks for a message.

type WebhookPayload

type WebhookPayload struct {
	Event       string  `json:"event"`
	ChannelID   int64   `json:"channel_id"`
	ChannelName string  `json:"channel_name"`
	ChannelType string  `json:"channel_type"`
	From        string  `json:"from"`
	FromType    string  `json:"from_type"`
	MessageID   int64   `json:"message_id"`
	Body        string  `json:"body"`
	Metadata    *string `json:"metadata"`
	SentAt      string  `json:"sent_at"`

	// Legacy fields — kept for global webhook_url backwards compatibility.
	Recipient string `json:"recipient,omitempty"`
	Channel   string `json:"channel,omitempty"`
}

WebhookPayload is the JSON body POSTed to the webhook URL.

type WebhookSubscriber added in v0.4.0

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

WebhookSubscriber listens for message events and fires webhooks.

func NewWebhookSubscriber added in v0.4.0

func NewWebhookSubscriber(bus domain.EventBus, store domain.Store) *WebhookSubscriber

NewWebhookSubscriber creates a subscriber that fires webhooks on new messages.

func (*WebhookSubscriber) Close added in v0.4.0

func (ws *WebhookSubscriber) Close()

Close stops the webhook subscriber.

Jump to

Keyboard shortcuts

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