scylla

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: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ReadingTTL = time.Hour * 24 * 30 * 12 // 1 year~

Variables

This section is empty.

Functions

func Migrate

func Migrate(ctx context.Context, conn gocqlx.Session) error

func SendWebpush

func SendWebpush(ctx context.Context, keypair KeyPair, wws WebpushSubscription, payload []byte) error

Types

type Alert

type Alert struct {
	ID       ulid.ULID `db:"id"`
	DeviceID string    `db:"device_id"`
	Kind     string    `db:"alert_type"`
	Value    string    `db:"alert_value"`
	Status   string    `db:"alert_status"`
	Time     time.Time `db:"time"`
}

type KeyPair

type KeyPair struct {
	ID         string `db:"id"`
	PublicKey  string `db:"public_key"`
	PrivateKey string `db:"private_key"`
}

type SensorInfoWithLastReading

type SensorInfoWithLastReading struct {
	IoTID    string
	Name     string
	URL      string
	Readings []redis.SensorReading // readings for each kind
}

type Store

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

func New

func New(ctx context.Context, clusterAddr ...string) *Store

func (*Store) AlertsSubscriber

func (s *Store) AlertsSubscriber(ctx context.Context, data redis.AlertEvent)

func (*Store) Close

func (s *Store) Close()

func (*Store) CreateUser

func (s *Store) CreateUser(ctx context.Context, user User) error

func (*Store) DeleteUser

func (s *Store) DeleteUser(ctx context.Context, id ulid.ULID) error

func (*Store) GetAlerts

func (s *Store) GetAlerts(ctx context.Context) ([]Alert, error)

func (*Store) GetAllWebpushSubs

func (s *Store) GetAllWebpushSubs(ctx context.Context) ([]WebpushSubscription, error)

func (*Store) GetMigrations

func (s *Store) GetMigrations(ctx context.Context) ([]models.MigrationsStruct, error)

func (*Store) GetSensor

func (s *Store) GetSensor(ctx context.Context, id string) (SensorInfoWithLastReading, error)

func (*Store) GetSensors

func (s *Store) GetSensors(ctx context.Context) ([]SensorInfoWithLastReading, error)

func (*Store) GetUser

func (s *Store) GetUser(ctx context.Context, id ulid.ULID) (User, error)

func (*Store) GetUserByEmail

func (s *Store) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*Store) GetUsers

func (s *Store) GetUsers(ctx context.Context) ([]User, error)

func (*Store) GetWebpushKey

func (s *Store) GetWebpushKey(ctx context.Context) (KeyPair, error)

func (*Store) GetWebpushSubscriptions

func (s *Store) GetWebpushSubscriptions(ctx context.Context, userID ulid.ULID) (UserWebpushSubscriptions, error)

func (*Store) MediaPublisherSubscriber

func (s *Store) MediaPublisherSubscriber(ctx context.Context, data redis.MediaPublisher)

func (*Store) ReadingsSubscriber

func (s *Store) ReadingsSubscriber(ctx context.Context, data redis.SensorReading)

func (*Store) RegisterWebpush

func (s *Store) RegisterWebpush(ctx context.Context, userID ulid.ULID, endpoint, auth, p256dh string) error

func (*Store) RenameSensor

func (s *Store) RenameSensor(ctx context.Context, id string, name string) error

func (*Store) RotateWebpushKey

func (s *Store) RotateWebpushKey(ctx context.Context) (KeyPair, error)

func (*Store) UpdateUser

func (s *Store) UpdateUser(ctx context.Context, user User) error

type User

type User struct {
	ID          string              `db:"id"`
	Email       string              `db:"email"`
	Name        string              `db:"name"`
	Password    string              `db:"password"`
	Permissions session.Permissions `db:"permissions"`
}

type UserWebpushSubscriptions

type UserWebpushSubscriptions struct {
	UserID ulid.ULID             `db:"user_id"`
	Subs   []WebpushSubscription `db:"subscription"`
}

type WebpushSubscription

type WebpushSubscription struct {
	Endpoint string `db:"endpoint"`
	Keys     struct {
		Auth   string `db:"auth"`
		P256dh string `db:"p256dh"`
	} `db:"keys"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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