Documentation ¶
Index ¶
- Constants
- Variables
- func Migrate(ctx context.Context, db string, version string, client *mongo.Client, ...) error
- func NewClient(ctx context.Context, c config.Reader) (*mongo.Client, error)
- func NewDataStoreWithClient(client *mongo.Client, expire time.Duration) store.DataStore
- func SetupDataStore(automigrate bool) (store.DataStore, error)
- type ControlMessageReader
- type DataStoreMongo
- func (db *DataStoreMongo) AllocateSession(ctx context.Context, sess *model.Session) error
- func (db *DataStoreMongo) Close() error
- func (db *DataStoreMongo) DeleteDevice(ctx context.Context, tenantID, deviceID string) error
- func (db *DataStoreMongo) DeleteSession(ctx context.Context, sessionID string) (*model.Session, error)
- func (db *DataStoreMongo) DropDatabase() error
- func (db *DataStoreMongo) GetDevice(ctx context.Context, tenantID string, deviceID string) (*model.Device, error)
- func (db *DataStoreMongo) GetSession(ctx context.Context, sessionID string) (*model.Session, error)
- func (db *DataStoreMongo) InsertControlRecording(ctx context.Context, sessionID string, sessionBytes []byte) error
- func (db *DataStoreMongo) InsertSessionRecording(ctx context.Context, sessionID string, sessionBytes []byte) error
- func (db *DataStoreMongo) Ping(ctx context.Context) error
- func (db *DataStoreMongo) ProvisionDevice(ctx context.Context, tenantID, deviceID string) error
- func (db *DataStoreMongo) UpsertDeviceStatus(ctx context.Context, tenantID string, deviceID string, status string) error
- func (db *DataStoreMongo) WriteSessionRecords(ctx context.Context, sessionID string, w io.Writer) error
- type RecordingReader
- type RecordingWriter
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 NewDataStoreWithClient ¶
NewDataStoreWithClient initializes a DataStore object
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 ¶
AllocateSession allocates a new session.
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
type RecordingWriter ¶
type RecordingWriter struct {
// contains filtered or unexported fields
}
func NewRecordingWriter ¶
func NewRecordingWriter(sessionID string, w io.Writer) *RecordingWriter
Click to show internal directories.
Click to hide internal directories.