bus

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TopicEntities ...
	TopicEntities = "entities"
	// TopicPlugins ...
	TopicPlugins = "plugins"
	// TopicAutomation ...
	TopicAutomation = "automation"
)

Variables

This section is empty.

Functions

func TopicMatch

func TopicMatch(topic []byte, topicFilter []byte) bool

TopicMatch 返回topic和topic filter是否

TopicMatch returns whether the topic and topic filter is matched.

Types

type Bus

type Bus interface {
	// Publish publishes arguments to the given topic subscribers
	// Publish block only when the buffer of one of the subscribers is full.
	Publish(topic string, args ...interface{})
	// Close unsubscribe all subscribers from given topic
	Close(topic string)
	// Subscribe subscribes to the given topic
	Subscribe(topic string, fn interface{}, options ...interface{}) error
	// Unsubscribe handler from the given topic
	Unsubscribe(topic string, fn interface{}) error
	// Stat ...
	Stat() (stats Stats, err error)
	// Purge ...
	Purge()
}

Bus implements publish/subscribe messaging paradigm

func NewBus

func NewBus() Bus

NewBus ...

type EntityState

type EntityState struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	ImageUrl    *string `json:"image_url"`
	Icon        *string `json:"icon"`
}

EntityState ...

type EventEntityState

type EventEntityState struct {
	EntityId    common.EntityId `json:"entity_id"`
	Value       interface{}     `json:"value"`
	State       *EntityState    `json:"state"`
	Attributes  m.Attributes    `json:"attributes"`
	Settings    m.Attributes    `json:"settings"`
	LastChanged *time.Time      `json:"last_changed"`
	LastUpdated *time.Time      `json:"last_updated"`
}

EventEntityState ...

func (EventEntityState) Compare

func (e1 EventEntityState) Compare(e2 EventEntityState) (ident bool)

Compare ...

type EventType

type EventType string

EventType ...

type Stat

type Stat struct {
	Topic       string
	Subscribers int
}

Stat ...

type Stats

type Stats []Stat

Stats ...

func (Stats) Len

func (s Stats) Len() int

Len ...

func (Stats) Less

func (s Stats) Less(i, j int) bool

Less ...

func (Stats) Swap

func (s Stats) Swap(i, j int)

Swap ...

Jump to

Keyboard shortcuts

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