wps

package
v0.8.3-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

wave pubsub system

Index

Constants

View Source
const (
	Event_BlockClose       = "blockclose"
	Event_ConnChange       = "connchange"
	Event_SysInfo          = "sysinfo"
	Event_ControllerStatus = "controllerstatus"
	Event_WaveObjUpdate    = "waveobj:update"
	Event_BlockFile        = "blockfile"
	Event_Config           = "config"
	Event_UserInput        = "userinput"
)
View Source
const (
	FileOp_Append     = "append"
	FileOp_Truncate   = "truncate"
	FileOp_Invalidate = "invalidate"
)
View Source
const MaxPersist = 4096
View Source
const ReMakeArrThreshold = 10 * 1024

Variables

View Source
var Broker = &BrokerType{
	Lock:       &sync.Mutex{},
	SubMap:     make(map[string]*BrokerSubscription),
	PersistMap: make(map[persistKey]*persistEventWrap),
}

Functions

This section is empty.

Types

type BrokerSubscription

type BrokerSubscription struct {
	AllSubs   []string            // routeids subscribed to "all" events
	ScopeSubs map[string][]string // routeids subscribed to specific scopes
	StarSubs  map[string][]string // routeids subscribed to star scope (scopes with "*" or "**" in them)
}

func (*BrokerSubscription) IsEmpty

func (bs *BrokerSubscription) IsEmpty() bool

type BrokerType

type BrokerType struct {
	Lock       *sync.Mutex
	Client     Client
	SubMap     map[string]*BrokerSubscription
	PersistMap map[persistKey]*persistEventWrap
}

func (*BrokerType) GetClient

func (b *BrokerType) GetClient() Client

func (*BrokerType) Publish

func (b *BrokerType) Publish(event WaveEvent)

func (*BrokerType) ReadEventHistory

func (b *BrokerType) ReadEventHistory(eventType string, scope string, maxItems int) []*WaveEvent

does not take wildcards, use "" for all

func (*BrokerType) SendUpdateEvents

func (b *BrokerType) SendUpdateEvents(updates waveobj.UpdatesRtnType)

func (*BrokerType) SetClient

func (b *BrokerType) SetClient(client Client)

func (*BrokerType) Subscribe

func (b *BrokerType) Subscribe(subRouteId string, sub SubscriptionRequest)

if already subscribed, this will *resubscribe* with the new subscription (remove the old one, and replace with this one)

func (*BrokerType) Unsubscribe

func (b *BrokerType) Unsubscribe(subRouteId string, eventName string)

func (*BrokerType) UnsubscribeAll

func (b *BrokerType) UnsubscribeAll(subRouteId string)

type Client

type Client interface {
	SendEvent(routeId string, event WaveEvent)
}

type SubscriptionRequest

type SubscriptionRequest struct {
	Event     string   `json:"event"`
	Scopes    []string `json:"scopes,omitempty"`
	AllScopes bool     `json:"allscopes,omitempty"`
}

type WSFileEventData

type WSFileEventData struct {
	ZoneId   string `json:"zoneid"`
	FileName string `json:"filename"`
	FileOp   string `json:"fileop"`
	Data64   string `json:"data64"`
}

type WaveEvent

type WaveEvent struct {
	Event   string   `json:"event"`
	Scopes  []string `json:"scopes,omitempty"`
	Sender  string   `json:"sender,omitempty"`
	Persist int      `json:"persist,omitempty"`
	Data    any      `json:"data,omitempty"`
}

func (WaveEvent) HasScope

func (e WaveEvent) HasScope(scope string) bool

Jump to

Keyboard shortcuts

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