durable

package
v0.0.0-...-3890e79 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultChannelUUID = uuid.MustParse("76ffcb18-d3c7-40d5-abea-3fe86d02a4ba")

Functions

This section is empty.

Types

type Channel

type Channel struct {
	UUID        uuid.UUID `db:"uuid"`
	Name        string    `db:"name"`
	Comment     *string   `db:"comment"`
	Applets     []ChannelApplet
	Subscribers []ChannelSubscriber
}

type ChannelApplet

type ChannelApplet struct {
	UUID   uuid.UUID `db:"uuid"`
	Idx    int       `db:"idx"`
	AppID  string    `db:"app_id"`
	Config *string   `db:"config"`
}

type ChannelSubscriber

type ChannelSubscriber struct {
	UUID uuid.UUID `db:"uuid"`
	Name string    `db:"name"`
}

type Count

type Count struct {
	Count int `db:"count"`
}

type Device

type Device struct {
	UUID               uuid.UUID `db:"uuid"`
	Name               string    `db:"name"`
	ChannelUUID        uuid.UUID `db:"channel_uuid"`
	ChannelName        *string   `db:"channel_name"`
	LastIP             *string   `db:"last_ip"`
	LastConnectTime    *string   `db:"last_connect_time"`
	LastDisconnectTime *string   `db:"last_disconnect_time"`
}

type SchemaVersion

type SchemaVersion struct {
	Version int `db:"version"`
}

type Store

type Store struct {
	DB *sqlair.DB
}

func NewStore

func NewStore() (*Store, error)

func NewStoreWithDB

func NewStoreWithDB(db *sqlair.DB) *Store

NewStoreWithDB creates a Store with a pre-initialized sqlair.DB. This is primarily used for testing with in-memory databases.

func (*Store) CreateChannel

func (store *Store) CreateChannel(ctx context.Context, name string, comment *string) (*Channel, error)

func (*Store) CreateChannelApplet

func (store *Store) CreateChannelApplet(ctx context.Context, channelUUID uuid.UUID, app *ChannelApplet) error

func (*Store) DeleteChannel

func (store *Store) DeleteChannel(ctx context.Context, channelUUID uuid.UUID) error

func (*Store) DeleteChannelApplet

func (store *Store) DeleteChannelApplet(ctx context.Context, channelUUID uuid.UUID, appletUUID uuid.UUID) error

func (*Store) DeleteDevice

func (store *Store) DeleteDevice(ctx context.Context, uuid uuid.UUID) error

func (*Store) GetAllChannels

func (store *Store) GetAllChannels(ctx context.Context) ([]Channel, error)

func (*Store) GetAllDevices

func (store *Store) GetAllDevices(ctx context.Context) ([]Device, error)

func (*Store) GetChannelByName

func (store *Store) GetChannelByName(ctx context.Context, name string) (*Channel, error)

func (*Store) GetChannelByUUID

func (store *Store) GetChannelByUUID(ctx context.Context, uuid uuid.UUID) (*Channel, error)

func (*Store) GetDeviceByUUID

func (store *Store) GetDeviceByUUID(ctx context.Context, uuid uuid.UUID) (*Device, error)

func (*Store) LoginDevice

func (store *Store) LoginDevice(ctx context.Context, uuid uuid.UUID, remoteIP string) (*Device, error)

func (*Store) LogoutDevice

func (store *Store) LogoutDevice(ctx context.Context, uuid uuid.UUID) error

func (*Store) ModifyChannel

func (store *Store) ModifyChannel(ctx context.Context, uuid uuid.UUID, name *string, comment *string) error

func (*Store) ModifyChannelApplet

func (store *Store) ModifyChannelApplet(ctx context.Context, channelUUID uuid.UUID, appletUUID uuid.UUID, idx *int, cfg *string) error

func (*Store) ModifyDevice

func (store *Store) ModifyDevice(ctx context.Context, device *Device) error

func (*Store) Transaction

func (store *Store) Transaction(ctx context.Context, opts *sqlair.TXOptions, fn func(*TX) error) error

func (*Store) Update

func (store *Store) Update(ctx context.Context, fn func(*TX) error) error

func (*Store) View

func (store *Store) View(ctx context.Context, fn func(*TX) error) error

type TX

type TX struct {
	Context context.Context
	// contains filtered or unexported fields
}

func (*TX) Query

func (tx *TX) Query(s *sqlair.Statement, inputArgs ...any) *sqlair.Query

Jump to

Keyboard shortcuts

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