server

package
v0.0.0-...-7d7efa5 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidOptions = fmt.Errorf("invalid subscriber options")

ErrInvalidOptions is returned when the subscriber options are invalid

View Source
var SubMessageOptionsUpdate = "options_update"

Functions

func ParseMaxMessageSizeBytes

func ParseMaxMessageSizeBytes[V int | string](value V) uint32

ParseMaxMessageSizeBytes parses a max size value string or integer and returns a uint32. If the value is less than 0, it returns 0. If the value is not a valid integer, it returns 0.

Types

type Server

type Server struct {
	Subscribers map[int64]*Subscriber

	Consumer *consumer.Consumer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(maxSubRate float64) (*Server, error)

func (*Server) AddSubscriber

func (s *Server) AddSubscriber(ws *websocket.Conn, realIP string, opts *SubscriberOptions) (*Subscriber, error)

func (*Server) Emit

func (s *Server) Emit(ctx context.Context, e *models.Event, asJSON, compBytes []byte) error

func (*Server) GetSeq

func (s *Server) GetSeq() int64

func (*Server) HandleSubscribe

func (s *Server) HandleSubscribe(c echo.Context) error

func (*Server) RemoveSubscriber

func (s *Server) RemoveSubscriber(num int64)

func (*Server) SetSeq

func (s *Server) SetSeq(seq int64)

type Subscriber

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

func (*Subscriber) SetCursor

func (s *Subscriber) SetCursor(cursor *int64)

func (*Subscriber) Terminate

func (s *Subscriber) Terminate(reason string) error

Terminate sends a close message to the subscriber

func (*Subscriber) UpdateOptions

func (s *Subscriber) UpdateOptions(opts *SubscriberOptions)

func (*Subscriber) WantsCollection

func (sub *Subscriber) WantsCollection(collection string) bool

WantsCollection returns true if the subscriber wants the given collection

func (*Subscriber) WriteMessage

func (s *Subscriber) WriteMessage(msgType int, data []byte) error

type SubscriberOptions

type SubscriberOptions struct {
	WantedCollections   *WantedCollections
	WantedDIDs          map[string]struct{}
	MaxMessageSizeBytes uint32
	Compress            bool
	Cursor              *int64
}

type SubscriberOptionsUpdatePayload

type SubscriberOptionsUpdatePayload struct {
	WantedCollections   []string `json:"wantedCollections"`
	WantedDIDs          []string `json:"wantedDids"`
	MaxMessageSizeBytes int      `json:"maxMessageSizeBytes"`
}

type SubscriberSourcedMessage

type SubscriberSourcedMessage struct {
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

type WantedCollections

type WantedCollections struct {
	Prefixes  []string
	FullPaths map[string]struct{}
}

Jump to

Keyboard shortcuts

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