{"modulePath":"github.com/wavetermdev/waveterm","version":"v0.14.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package wps\n\nwave pubsub system\n\n## Constants\n\n```go\nconst (\n\tEvent_BlockClose          = \"blockclose\"           // type: string\n\tEvent_ConnChange          = \"connchange\"           // type: wshrpc.ConnStatus\n\tEvent_SysInfo             = \"sysinfo\"              // type: wshrpc.TimeSeriesData\n\tEvent_ControllerStatus    = \"controllerstatus\"     // type: *blockcontroller.BlockControllerRuntimeStatus\n\tEvent_BuilderStatus       = \"builderstatus\"        // type: wshrpc.BuilderStatusData\n\tEvent_BuilderOutput       = \"builderoutput\"        // type: map[string]any\n\tEvent_WaveObjUpdate       = \"waveobj:update\"       // type: waveobj.WaveObjUpdate\n\tEvent_BlockFile           = \"blockfile\"            // type: *WSFileEventData\n\tEvent_Config              = \"config\"               // type: wconfig.WatcherUpdate\n\tEvent_UserInput           = \"userinput\"            // type: *userinput.UserInputRequest\n\tEvent_RouteDown           = \"route:down\"           // type: none\n\tEvent_RouteUp             = \"route:up\"             // type: none\n\tEvent_WorkspaceUpdate     = \"workspace:update\"     // type: none\n\tEvent_WaveAIRateLimit     = \"waveai:ratelimit\"     // type: *uctypes.RateLimitInfo\n\tEvent_WaveAppAppGoUpdated = \"waveapp:appgoupdated\" // type: none\n\tEvent_TsunamiUpdateMeta   = \"tsunami:updatemeta\"   // type: wshrpc.AppMeta\n\tEvent_AIModeConfig        = \"waveai:modeconfig\"    // type: wconfig.AIModeConfigUpdate\n\tEvent_BlockJobStatus      = \"block:jobstatus\"      // type: wshrpc.BlockJobStatusData\n\tEvent_Badge               = \"badge\"                // type: baseds.BadgeEvent\n)\n```\nIMPORTANT: When adding a new event constant, you MUST also:\n\n 1. Add a \"// type: \\\u003cTypeName\u003e\" comment (use \"none\" if no data is sent)\n 2. Add the constant to AllEvents below\n 3. Add an entry to WaveEventDataTypes in pkg/tsgen/tsgenevent.go - Use reflect.TypeOf(YourType{}) for value types - Use reflect.TypeOf((\\*YourType)(nil)) for pointer types - Use nil if no data is sent for the event\n\n```go\nconst (\n\tFileOp_Create     = \"create\"\n\tFileOp_Delete     = \"delete\"\n\tFileOp_Append     = \"append\"\n\tFileOp_Truncate   = \"truncate\"\n\tFileOp_Invalidate = \"invalidate\"\n)\n```\n\n```go\nconst MaxPersist = 4096\n```\n\n## Variables\n\n```go\nvar AllEvents []string = []string{\n\tEvent_BlockClose,\n\tEvent_ConnChange,\n\tEvent_SysInfo,\n\tEvent_ControllerStatus,\n\tEvent_BuilderStatus,\n\tEvent_BuilderOutput,\n\tEvent_WaveObjUpdate,\n\tEvent_BlockFile,\n\tEvent_Config,\n\tEvent_UserInput,\n\tEvent_RouteDown,\n\tEvent_RouteUp,\n\tEvent_WorkspaceUpdate,\n\tEvent_WaveAIRateLimit,\n\tEvent_WaveAppAppGoUpdated,\n\tEvent_TsunamiUpdateMeta,\n\tEvent_AIModeConfig,\n\tEvent_BlockJobStatus,\n\tEvent_Badge,\n}\n```\n\n```go\nvar Broker = \u0026BrokerType{\n\tLock:       \u0026sync.Mutex{},\n\tSubMap:     make(map[string]*BrokerSubscription),\n\tPersistMap: make(map[persistKey]*persistEventWrap),\n}\n```\n\n## Types\n\n```go\ntype BrokerSubscription struct {\n\tAllSubs   []string            // routeids subscribed to \"all\" events\n\tScopeSubs map[string][]string // routeids subscribed to specific scopes\n\tStarSubs  map[string][]string // routeids subscribed to star scope (scopes with \"*\" or \"**\" in them)\n}\n```\n\n```go\nfunc (bs *BrokerSubscription) IsEmpty() bool\n```\n\n```go\ntype BrokerType struct {\n\tLock       *sync.Mutex\n\tClient     Client\n\tSubMap     map[string]*BrokerSubscription\n\tPersistMap map[persistKey]*persistEventWrap\n}\n```\n\n```go\nfunc (b *BrokerType) GetClient() Client\n```\n\n```go\nfunc (b *BrokerType) Publish(event WaveEvent)\n```\n\n```go\nfunc (b *BrokerType) ReadEventHistory(eventType string, scope string, maxItems int) []*WaveEvent\n```\ndoes not take wildcards, use \"\" for all\n\n```go\nfunc (b *BrokerType) SendUpdateEvents(updates waveobj.UpdatesRtnType)\n```\n\n```go\nfunc (b *BrokerType) SetClient(client Client)\n```\n\n```go\nfunc (b *BrokerType) Subscribe(subRouteId string, sub SubscriptionRequest)\n```\nif already subscribed, this will \\*resubscribe\\* with the new subscription (remove the old one, and replace with this one)\n\n```go\nfunc (b *BrokerType) Unsubscribe(subRouteId string, eventName string)\n```\n\n```go\nfunc (b *BrokerType) UnsubscribeAll(subRouteId string)\n```\n\n```go\ntype Client interface {\n\tSendEvent(routeId string, event WaveEvent)\n}\n```\n\n```go\ntype SubscriptionRequest struct {\n\tEvent     string   `json:\"event\"`\n\tScopes    []string `json:\"scopes,omitempty\"`\n\tAllScopes bool     `json:\"allscopes,omitempty\"`\n}\n```\n\n```go\ntype WSFileEventData struct {\n\tZoneId   string `json:\"zoneid\"`\n\tFileName string `json:\"filename\"`\n\tFileOp   string `json:\"fileop\"`\n\tData64   string `json:\"data64\"`\n}\n```\n\n```go\ntype WaveEvent struct {\n\tEvent   string   `json:\"event\"`\n\tScopes  []string `json:\"scopes,omitempty\"`\n\tSender  string   `json:\"sender,omitempty\"`\n\tPersist int      `json:\"persist,omitempty\"`\n\tData    any      `json:\"data,omitempty\"`\n}\n```\n\n```go\nfunc (e WaveEvent) HasScope(scope string) bool\n```\n\n","path":"github.com/wavetermdev/waveterm/pkg/wps","name":"wps","synopsis":"wave pubsub system","isRedistributable":true}
