Documentation
¶
Index ¶
- Constants
- func IsDuplicateKeyErr(err error) bool
- type MongoStore
- func (db *MongoStore) Close(ctx context.Context) error
- func (db *MongoStore) Database(ctx context.Context, opt ...*mopts.DatabaseOptions) *mongo.Database
- func (db *MongoStore) DeleteDevice(ctx context.Context, devID string) error
- func (db *MongoStore) DeleteTenant(ctx context.Context, tenant_id string) error
- func (db *MongoStore) DropDatabase(ctx context.Context) error
- func (db *MongoStore) GetDevice(ctx context.Context, devID string) (model.Device, error)
- func (db *MongoStore) InsertDevice(ctx context.Context, dev model.Device) error
- func (db *MongoStore) Migrate(ctx context.Context, version string, automigrate bool) error
- func (db *MongoStore) MigrateLatest(ctx context.Context) error
- func (db *MongoStore) Ping(ctx context.Context) error
- func (db *MongoStore) ReplaceConfiguration(ctx context.Context, dev model.Device) error
- func (db *MongoStore) ReplaceReportedConfiguration(ctx context.Context, dev model.Device) error
- func (db *MongoStore) SetDeploymentID(ctx context.Context, devID string, deploymentID uuid.UUID) error
- func (db *MongoStore) UpdateConfiguration(ctx context.Context, devID string, attrs model.Attributes) error
- type MongoStoreConfig
Constants ¶
View Source
const ( // CollDevices refers to the collection name for device configurations CollDevices = "devices" KeyTenantID = "tenant_id" )
View Source
const ( // DbVersion is the current schema version DbVersion = "1.0.1" // DbName is the database name DbName = "deviceconfig" )
View Source
const (
ErrCodeDuplicateKey = 11000
)
Variables ¶
This section is empty.
Functions ¶
func IsDuplicateKeyErr ¶
IsDuplicateKeyErr checks the errors and inspects if (one of) the error(s) is duplicate key a error.
Types ¶
type MongoStore ¶
type MongoStore struct {
// contains filtered or unexported fields
}
MongoStore is the data storage service
func NewMongoStore ¶
func NewMongoStore(ctx context.Context, config MongoStoreConfig) (*MongoStore, error)
SetupDataStore returns the mongo data store and optionally runs migrations
func (*MongoStore) Close ¶
func (db *MongoStore) Close(ctx context.Context) error
Close disconnects the client
func (*MongoStore) Database ¶
func (db *MongoStore) Database(ctx context.Context, opt ...*mopts.DatabaseOptions) *mongo.Database
func (*MongoStore) DeleteDevice ¶
func (db *MongoStore) DeleteDevice(ctx context.Context, devID string) error
func (*MongoStore) DeleteTenant ¶
func (db *MongoStore) DeleteTenant(ctx context.Context, tenant_id string) error
func (*MongoStore) DropDatabase ¶
func (db *MongoStore) DropDatabase(ctx context.Context) error
func (*MongoStore) InsertDevice ¶
func (*MongoStore) Migrate ¶
Migrate applies all migrations under the given context. That is, if ctx has an associated identity.Identity set, it will ONLY migrate the single tenant's db. If ctx does not have an identity, all deviceconfig databases will be migrated to the given version.
func (*MongoStore) MigrateLatest ¶
func (db *MongoStore) MigrateLatest(ctx context.Context) error
func (*MongoStore) Ping ¶
func (db *MongoStore) Ping(ctx context.Context) error
Ping verifies the connection to the database
func (*MongoStore) ReplaceConfiguration ¶
func (*MongoStore) ReplaceReportedConfiguration ¶
func (*MongoStore) SetDeploymentID ¶
func (*MongoStore) UpdateConfiguration ¶
func (db *MongoStore) UpdateConfiguration( ctx context.Context, devID string, attrs model.Attributes, ) error
type MongoStoreConfig ¶
type MongoStoreConfig struct { // MongoURL holds the URL to the MongoDB server. MongoURL *url.URL // TLSConfig holds optional tls configuration options for connecting // to the MongoDB server. TLSConfig *tls.Config // Username holds the user id credential for authenticating with the // MongoDB server. Username string // Password holds the password credential for authenticating with the // MongoDB server. Password string // DbName contains the name of the deviceconfig database. DbName string }
Click to show internal directories.
Click to hide internal directories.