store

package
v0.0.0-...-4a3d6f3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSerialization  = errors.New("store: failed to serialize object")
	ErrObjectNotFound = errors.New("store: object not found")

	ErrObjectExists = errors.New("store: the object already exists")
)

Functions

This section is empty.

Types

type DataStore

type DataStore interface {
	Ping(ctx context.Context) error
	Close() error

	GetIntegrations(context.Context, model.IntegrationFilter) ([]model.Integration, error)
	GetIntegrationById(context.Context, uuid.UUID) (*model.Integration, error)
	CreateIntegration(context.Context, model.Integration) (*model.Integration, error)
	GetDevice(ctx context.Context, deviceID string) (*model.Device, error)
	GetDeviceByIntegrationID(
		ctx context.Context,
		deviceID string,
		integrationID uuid.UUID,
	) (*model.Device, error)
	DoDevicesExistByIntegrationID(context.Context, uuid.UUID) (bool, error)
	// RemoveDevicesFromIntegration integration with the given integrationID
	// from all devices belonging to the tenant within the context.
	RemoveDevicesFromIntegration(
		ctx context.Context,
		integrationID uuid.UUID,
	) (deviceCount int64, err error)
	// UsertDeviceIntegrations adds the list of integration IDs to the
	// device and creates it if it does not exist.
	UpsertDeviceIntegrations(
		ctx context.Context,
		deviceID string,
		integrationIDs []uuid.UUID,
	) (newDevice *model.Device, err error)
	DeleteDevice(ctx context.Context, deviceID string) error
	SetIntegrationCredentials(context.Context, uuid.UUID, model.Credentials) error
	RemoveIntegration(context.Context, uuid.UUID) error

	// GetAllDevices returns an iterator over ALL devices sorted by tenant ID.
	GetAllDevices(ctx context.Context) (Iterator, error)

	// GetEvents returns list of event objects
	GetEvents(ctx context.Context, fltr model.EventsFilter) ([]model.Event, error)
	// SaveEvent saves the event in the database
	SaveEvent(ctx context.Context, event model.Event) error
}

DataStore interface for DataStore services

type Iterator

type Iterator interface {
	Next(ctx context.Context) bool
	Decode(value interface{}) error
	Close(ctx context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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