mongo

package
v0.0.0-...-1a0b003 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DevicesCollectionName refers to the name of the collection of stored devices
	DevicesCollectionName = "devices"

	// SessionsCollectionName refers to the name of the collection of sessions
	SessionsCollectionName = "sessions"

	// RecordingsCollectionName name of the collection of session recordings
	RecordingsCollectionName = "recordings"

	// ControlCollectionName name of the collection of session control data
	ControlCollectionName = "control"
)
View Source
const (
	// DbVersion is the current schema version
	DbVersion = "2.0.1"

	// DbName is the database name
	DbName = "deviceconnect"
)
View Source
const (
	IndexNameLogsExpire = "RecordingExpire"
)

Variables

View Source
var (
	ErrUnknownControlMessageType = errors.New("unknown control message type")
	ErrRecordingDataInconsistent = errors.New("recording data corrupt")
)

Functions

func Migrate

func Migrate(ctx context.Context,
	db string,
	version string,
	client *mongo.Client,
	automigrate bool) error

Migrate applies migrations to the database

func NewClient

func NewClient(ctx context.Context, c config.Reader) (*mongo.Client, error)

NewClient returns a mongo client

func NewDataStoreWithClient

func NewDataStoreWithClient(client *mongo.Client, expire time.Duration) store.DataStore

NewDataStoreWithClient initializes a DataStore object

func SetupDataStore

func SetupDataStore(automigrate bool) (store.DataStore, error)

SetupDataStore returns the mongo data store and optionally runs migrations

Types

type ControlMessageReader

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

func NewControlMessageReader

func NewControlMessageReader(ctx context.Context, c *mongo.Cursor) *ControlMessageReader

func (*ControlMessageReader) Pop

func (r *ControlMessageReader) Pop() *app.Control

type DataStoreMongo

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

DataStoreMongo is the data storage service

func (*DataStoreMongo) AllocateSession

func (db *DataStoreMongo) AllocateSession(ctx context.Context, sess *model.Session) error

AllocateSession allocates a new session.

func (*DataStoreMongo) Close

func (db *DataStoreMongo) Close() error

Close disconnects the client

func (*DataStoreMongo) DeleteDevice

func (db *DataStoreMongo) DeleteDevice(ctx context.Context, tenantID, deviceID string) error

DeleteDevice deletes a device

func (*DataStoreMongo) DeleteSession

func (db *DataStoreMongo) DeleteSession(
	ctx context.Context, sessionID string,
) (*model.Session, error)

DeleteSession deletes a session

func (*DataStoreMongo) DropDatabase

func (db *DataStoreMongo) DropDatabase() error

func (*DataStoreMongo) GetDevice

func (db *DataStoreMongo) GetDevice(
	ctx context.Context,
	tenantID string,
	deviceID string,
) (*model.Device, error)

GetDevice returns a device

func (*DataStoreMongo) GetSession

func (db *DataStoreMongo) GetSession(
	ctx context.Context,
	sessionID string,
) (*model.Session, error)

GetSession returns a session

func (*DataStoreMongo) InsertControlRecording

func (db *DataStoreMongo) InsertControlRecording(ctx context.Context,
	sessionID string,
	sessionBytes []byte) error

Inserts control data recording

func (*DataStoreMongo) InsertSessionRecording

func (db *DataStoreMongo) InsertSessionRecording(ctx context.Context,
	sessionID string,
	sessionBytes []byte) error

SetSession saves a session recording

func (*DataStoreMongo) Ping

func (db *DataStoreMongo) Ping(ctx context.Context) error

Ping verifies the connection to the database

func (*DataStoreMongo) ProvisionDevice

func (db *DataStoreMongo) ProvisionDevice(ctx context.Context, tenantID, deviceID string) error

ProvisionDevice provisions a new device

func (*DataStoreMongo) UpsertDeviceStatus

func (db *DataStoreMongo) UpsertDeviceStatus(
	ctx context.Context,
	tenantID string,
	deviceID string,
	status string,
) error

UpsertDeviceStatus upserts the connection status of a device

func (*DataStoreMongo) WriteSessionRecords

func (db *DataStoreMongo) WriteSessionRecords(ctx context.Context,
	sessionID string,
	w io.Writer) error

GetSession writes session recordings to given io.Writer

type RecordingReader

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

func NewRecordingReader

func NewRecordingReader(ctx context.Context, c *mongo.Cursor) *RecordingReader

func (*RecordingReader) Read

func (rr *RecordingReader) Read(buffer []byte) (int, error)

type RecordingWriter

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

func NewRecordingWriter

func NewRecordingWriter(sessionID string, w io.Writer) *RecordingWriter

func (*RecordingWriter) Write

func (r *RecordingWriter) Write(d []byte) (n int, err error)

Jump to

Keyboard shortcuts

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