redis

package
v0.0.0-...-5745a54 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: ISC Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const IntrusionChannel = iotPrefix + "camera"

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertEvent

type AlertEvent struct {
	ID          string    `json:"id"`
	Type        string    `json:"type"`
	Temperature *float32  `json:"temperature,omitempty"`
	Humidity    *float32  `json:"humidity,omitempty"`
	AirQuality  *float32  `json:"air quality,omitempty"`
	Timestamp   time.Time `json:"timestamp"`
	Criticity   int       `json:"criticity"`
}

type Base64String

type Base64String string

func (Base64String) MarshalJSON

func (b Base64String) MarshalJSON() ([]byte, error)

func (*Base64String) UnmarshalJSON

func (b *Base64String) UnmarshalJSON(data []byte) error

type EventHandler

type EventHandler interface {
	OnEvent(message rueidis.PubSubMessage)
}

type Intrusion

type Intrusion struct {
	IDIoT string `json:"id_iot"`
	Image string `json:"image"`
}

type MediaPublisher

type MediaPublisher struct {
	IoTID string `json:"iot_id"`
}

type SensorReading

type SensorReading struct {
	IoTID       string    `json:"id_iot"`
	Time        time.Time `json:"time"`
	Temperature *float32  `json:"temperature"`
	Humidity    *float32  `json:"humidity"`
	Iaq         *float32  `json:"iaq"`
	Battery     *float32  `json:"battery"`
}

type Store

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

func New

func New(address []string, user, pass string) (*Store, error)

func (*Store) AlertsPub

func (s *Store) AlertsPub(ctx context.Context, e AlertEvent) error

AlertsPub publishes an alert event.

func (*Store) AlertsSub

func (s *Store) AlertsSub(ctx context.Context, eh EventHandler) error

AlertsSub blocks and waits for messages on the alerts channel.

func (*Store) Close

func (s *Store) Close() error

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, id session.ID) error

func (*Store) GetSession

func (s *Store) GetSession(ctx context.Context, id session.ID) (session.Session, error)

func (*Store) IntrusionPub

func (s *Store) IntrusionPub(ctx context.Context, intrusion Intrusion) error

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context) ([]session.Session, error)

func (*Store) MediaPublisherPub

func (s *Store) MediaPublisherPub(ctx context.Context, e MediaPublisher) error

func (*Store) MediaPublisherSub

func (s *Store) MediaPublisherSub(ctx context.Context, eh EventHandler) error

func (*Store) NewSession

func (s *Store) NewSession(ctx context.Context, userID ulid.ULID, perms session.Permissions, TTL time.Duration) (session.ID, error)

func (*Store) ReadingsPub

func (s *Store) ReadingsPub(ctx context.Context, r SensorReading) error

func (*Store) ReadingsSub

func (s *Store) ReadingsSub(ctx context.Context, eh EventHandler) error

ReadingsSub blocks and waits for messages on the sensor channel.

type SubFanHandle

type SubFanHandle[T any] struct {
	// contains filtered or unexported fields
}

func NewFan

func NewFan[T any]() *SubFanHandle[T]

NewFan allows to fan out messages to all registered callbacks

func (*SubFanHandle[T]) OnEvent

func (sh *SubFanHandle[T]) OnEvent(message rueidis.PubSubMessage)

func (*SubFanHandle[T]) Subscribe

func (sh *SubFanHandle[T]) Subscribe(k string, ctx context.Context, sub func(ctx context.Context, message T))

func (*SubFanHandle[T]) Unsubscribe

func (sh *SubFanHandle[T]) Unsubscribe(k string)

Jump to

Keyboard shortcuts

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