chat

package
v0.0.0-...-9d7609d Latest Latest
Warning

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

Go to latest
Published: Mar 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 Client

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

type ClosableStore

type ClosableStore interface {
	Store
	Close() error
}

type Hub

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

func NewHub

func NewHub(store Store) *Hub

func NewHubWithOptions

func NewHubWithOptions(store Store, options Options) *Hub

func (*Hub) Close

func (h *Hub) Close()

func (*Hub) HandleWS

func (h *Hub) HandleWS(w http.ResponseWriter, r *http.Request)

func (*Hub) Run

func (h *Hub) Run()

type Message

type Message struct {
	ID          string    `json:"id"`
	Type        string    `json:"type"`
	Room        string    `json:"room,omitempty"`
	UserID      string    `json:"user_id,omitempty"`
	DisplayName string    `json:"display_name,omitempty"`
	Doc         string    `json:"doc,omitempty"`
	Body        string    `json:"body,omitempty"`
	Rooms       []string  `json:"rooms,omitempty"`
	Users       []string  `json:"users,omitempty"`
	Items       []string  `json:"items,omitempty"`
	History     []Message `json:"history,omitempty"`
	Limit       int       `json:"limit,omitempty"`
	Timestamp   time.Time `json:"timestamp"`
}

type Options

type Options struct {
	AllowedOrigins  []string
	MaxMessageBytes int64
	MaxBodyLength   int
	MaxRoomLength   int
	MaxUserLength   int
	HistoryLimit    int
	SendBuffer      int
	SaveBuffer      int
	StoreTimeout    time.Duration
	WriteWait       time.Duration
	PongWait        time.Duration
	PingPeriod      time.Duration
	JWTSecret       string
	JWTIssuer       string
	JWTAudience     string
}

type PostgresStore

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

func NewPostgresStore

func NewPostgresStore(dsn string) (*PostgresStore, error)

func (*PostgresStore) Close

func (s *PostgresStore) Close() error

func (*PostgresStore) ListMessages

func (s *PostgresStore) ListMessages(ctx context.Context, room string, limit int) ([]Message, error)

func (*PostgresStore) SaveMessage

func (s *PostgresStore) SaveMessage(ctx context.Context, msg Message) error

type SQLiteStore

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

func NewSQLiteStore

func NewSQLiteStore(path string) (*SQLiteStore, error)

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) ListMessages

func (s *SQLiteStore) ListMessages(ctx context.Context, room string, limit int) ([]Message, error)

func (*SQLiteStore) SaveMessage

func (s *SQLiteStore) SaveMessage(ctx context.Context, msg Message) error

type Store

type Store interface {
	SaveMessage(ctx context.Context, msg Message) error
	ListMessages(ctx context.Context, room string, limit int) ([]Message, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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