Documentation ¶
Index ¶
- Constants
- Variables
- type DeploymentsStorage
- func (d *DeploymentsStorage) Delete(ctx context.Context, id string) error
- func (d *DeploymentsStorage) DeviceCountByDeployment(ctx context.Context, id string) (int, error)
- func (d *DeploymentsStorage) DoEnsureIndexing(db string, session *mgo.Session) error
- func (d *DeploymentsStorage) EnsureIndexing(ctx context.Context, session *mgo.Session) error
- func (d *DeploymentsStorage) ExistByArtifactId(ctx context.Context, id string) (bool, error)
- func (d *DeploymentsStorage) ExistUnfinishedByArtifactId(ctx context.Context, id string) (bool, error)
- func (d *DeploymentsStorage) Find(ctx context.Context, match deployments.Query) ([]*deployments.Deployment, error)
- func (d *DeploymentsStorage) FindByID(ctx context.Context, id string) (*deployments.Deployment, error)
- func (d *DeploymentsStorage) FindUnfinishedByID(ctx context.Context, id string) (*deployments.Deployment, error)
- func (d *DeploymentsStorage) Finish(ctx context.Context, id string, when time.Time) error
- func (d *DeploymentsStorage) Insert(ctx context.Context, deployment *deployments.Deployment) error
- func (d *DeploymentsStorage) UpdateStats(ctx context.Context, id string, state_from, state_to string) error
- func (d *DeploymentsStorage) UpdateStatsAndFinishDeployment(ctx context.Context, id string, stats deployments.Stats) error
- type DeviceDeploymentLogsStorage
- type DeviceDeploymentsStorage
- func (d *DeviceDeploymentsStorage) AbortDeviceDeployments(ctx context.Context, deploymentId string) error
- func (d *DeviceDeploymentsStorage) AggregateDeviceDeploymentByStatus(ctx context.Context, id string) (deployments.Stats, error)
- func (d *DeviceDeploymentsStorage) AssignArtifact(ctx context.Context, deviceID string, deploymentID string, ...) error
- func (d *DeviceDeploymentsStorage) DecommissionDeviceDeployments(ctx context.Context, deviceId string) error
- func (d *DeviceDeploymentsStorage) ExistAssignedImageWithIDAndStatuses(ctx context.Context, imageID string, statuses ...string) (bool, error)
- func (d *DeviceDeploymentsStorage) FindAllDeploymentsForDeviceIDWithStatuses(ctx context.Context, deviceID string, statuses ...string) ([]deployments.DeviceDeployment, error)
- func (d *DeviceDeploymentsStorage) FindOldestDeploymentForDeviceIDWithStatuses(ctx context.Context, deviceID string, statuses ...string) (*deployments.DeviceDeployment, error)
- func (d *DeviceDeploymentsStorage) GetDeviceDeploymentStatus(ctx context.Context, deploymentID string, deviceID string) (string, error)
- func (d *DeviceDeploymentsStorage) GetDeviceStatusesForDeployment(ctx context.Context, deploymentID string) ([]deployments.DeviceDeployment, error)
- func (d *DeviceDeploymentsStorage) HasDeploymentForDevice(ctx context.Context, deploymentID string, deviceID string) (bool, error)
- func (d *DeviceDeploymentsStorage) InsertMany(ctx context.Context, deployments ...*deployments.DeviceDeployment) error
- func (d *DeviceDeploymentsStorage) UpdateDeviceDeploymentLogAvailability(ctx context.Context, deviceID string, deploymentID string, log bool) error
- func (d *DeviceDeploymentsStorage) UpdateDeviceDeploymentStatus(ctx context.Context, deviceID string, deploymentID string, ...) (string, error)
Constants ¶
const ( DatabaseName = "deployment_service" CollectionDeployments = "deployments" )
Database settings
const ( StorageKeyDeploymentName = "deploymentconstructor.name" StorageKeyDeploymentArtifactName = "deploymentconstructor.artifactname" StorageKeyDeploymentStats = "stats" StorageKeyDeploymentFinished = "finished" StorageKeyDeploymentArtifacts = "artifacts" )
const ( StorageKeyDeviceDeploymentAssignedImage = "image" StorageKeyDeviceDeploymentAssignedImageId = StorageKeyDeviceDeploymentAssignedImage + "." + imagesMongo.StorageKeySoftwareImageId StorageKeyDeviceDeploymentDeviceId = "deviceid" StorageKeyDeviceDeploymentStatus = "status" StorageKeyDeviceDeploymentSubState = "substate" StorageKeyDeviceDeploymentDeploymentID = "deploymentid" StorageKeyDeviceDeploymentFinished = "finished" StorageKeyDeviceDeploymentIsLogAvailable = "log" StorageKeyDeviceDeploymentArtifact = "image" )
Database keys
const (
// TODO: do we have any naming convention for mongo collections?
CollectionDeviceDeploymentLogs = "devices.logs"
)
Database settings
const (
CollectionDevices = "devices"
)
Database settings
const (
IndexDeploymentArtifactNameStr = "deploymentArtifactNameIndex"
)
const (
StorageKeyDeviceDeploymentLogMessages = "messages"
)
Database keys
Variables ¶
var ( ErrDeploymentStorageInvalidDeployment = errors.New("Invalid deployment") ErrStorageInvalidID = errors.New("Invalid id") ErrStorageNotFound = errors.New("Not found") ErrDeploymentStorageInvalidQuery = errors.New("Invalid query") ErrDeploymentStorageCannotExecQuery = errors.New("Cannot execute query") ErrStorageInvalidInput = errors.New("invalid input") )
Errors
var (
ErrStorageInvalidDeviceDeployment = errors.New("Invalid device deployment")
)
Errors
var ( StorageIndexes = []string{ "$text:" + StorageKeyDeploymentName, "$text:" + StorageKeyDeploymentArtifactName, } )
Functions ¶
This section is empty.
Types ¶
type DeploymentsStorage ¶
type DeploymentsStorage struct {
// contains filtered or unexported fields
}
DeploymentsStorage is a data layer for deployments based on MongoDB
func NewDeploymentsStorage ¶
func NewDeploymentsStorage(session *mgo.Session) *DeploymentsStorage
NewDeploymentsStorage new data layer object
func (*DeploymentsStorage) Delete ¶
func (d *DeploymentsStorage) Delete(ctx context.Context, id string) error
Delete removed entry by ID Noop on ID not found
func (*DeploymentsStorage) DeviceCountByDeployment ¶
func (*DeploymentsStorage) DoEnsureIndexing ¶
func (d *DeploymentsStorage) DoEnsureIndexing(db string, session *mgo.Session) error
func (*DeploymentsStorage) EnsureIndexing ¶
func (d *DeploymentsStorage) EnsureIndexing(ctx context.Context, session *mgo.Session) error
func (*DeploymentsStorage) ExistByArtifactId ¶
ExistByArtifactId check if there is any deployment that uses give artifact
func (*DeploymentsStorage) ExistUnfinishedByArtifactId ¶
func (d *DeploymentsStorage) ExistUnfinishedByArtifactId(ctx context.Context, id string) (bool, error)
ExistUnfinishedByArtifactId checks if there is an active deployment that uses given artifact
func (*DeploymentsStorage) Find ¶
func (d *DeploymentsStorage) Find(ctx context.Context, match deployments.Query) ([]*deployments.Deployment, error)
func (*DeploymentsStorage) FindByID ¶
func (d *DeploymentsStorage) FindByID(ctx context.Context, id string) (*deployments.Deployment, error)
func (*DeploymentsStorage) FindUnfinishedByID ¶
func (d *DeploymentsStorage) FindUnfinishedByID(ctx context.Context, id string) (*deployments.Deployment, error)
func (*DeploymentsStorage) Insert ¶
func (d *DeploymentsStorage) Insert(ctx context.Context, deployment *deployments.Deployment) error
Insert persists object
func (*DeploymentsStorage) UpdateStats ¶
func (*DeploymentsStorage) UpdateStatsAndFinishDeployment ¶
func (d *DeploymentsStorage) UpdateStatsAndFinishDeployment(ctx context.Context, id string, stats deployments.Stats) error
type DeviceDeploymentLogsStorage ¶
type DeviceDeploymentLogsStorage struct {
// contains filtered or unexported fields
}
DeviceDeploymentLogsStorage is a data layer for deployment logs based on MongoDB
func NewDeviceDeploymentLogsStorage ¶
func NewDeviceDeploymentLogsStorage(session *mgo.Session) *DeviceDeploymentLogsStorage
func (*DeviceDeploymentLogsStorage) GetDeviceDeploymentLog ¶
func (d *DeviceDeploymentLogsStorage) GetDeviceDeploymentLog(ctx context.Context, deviceID, deploymentID string) (*deployments.DeploymentLog, error)
func (*DeviceDeploymentLogsStorage) SaveDeviceDeploymentLog ¶
func (d *DeviceDeploymentLogsStorage) SaveDeviceDeploymentLog(ctx context.Context, log deployments.DeploymentLog) error
type DeviceDeploymentsStorage ¶
type DeviceDeploymentsStorage struct {
// contains filtered or unexported fields
}
DeviceDeploymentsStorage is a data layer for deployments based on MongoDB
func NewDeviceDeploymentsStorage ¶
func NewDeviceDeploymentsStorage(session *mgo.Session) *DeviceDeploymentsStorage
NewDeviceDeploymentsStorage new data layer object
func (*DeviceDeploymentsStorage) AbortDeviceDeployments ¶
func (d *DeviceDeploymentsStorage) AbortDeviceDeployments(ctx context.Context, deploymentId string) error
func (*DeviceDeploymentsStorage) AggregateDeviceDeploymentByStatus ¶
func (d *DeviceDeploymentsStorage) AggregateDeviceDeploymentByStatus(ctx context.Context, id string) (deployments.Stats, error)
func (*DeviceDeploymentsStorage) AssignArtifact ¶
func (d *DeviceDeploymentsStorage) AssignArtifact(ctx context.Context, deviceID string, deploymentID string, artifact *images.SoftwareImage) error
AssignArtifact assignes artifact to the device deployment
func (*DeviceDeploymentsStorage) DecommissionDeviceDeployments ¶
func (d *DeviceDeploymentsStorage) DecommissionDeviceDeployments(ctx context.Context, deviceId string) error
func (*DeviceDeploymentsStorage) ExistAssignedImageWithIDAndStatuses ¶
func (d *DeviceDeploymentsStorage) ExistAssignedImageWithIDAndStatuses(ctx context.Context, imageID string, statuses ...string) (bool, error)
ExistAssignedImageWithIDAndStatuses checks if image is used by deplyment with specified status.
func (*DeviceDeploymentsStorage) FindAllDeploymentsForDeviceIDWithStatuses ¶
func (d *DeviceDeploymentsStorage) FindAllDeploymentsForDeviceIDWithStatuses(ctx context.Context, deviceID string, statuses ...string) ([]deployments.DeviceDeployment, error)
FindAllDeploymentsForDeviceIDWithStatuses finds all deployments matching device id and one of specified statuses.
func (*DeviceDeploymentsStorage) FindOldestDeploymentForDeviceIDWithStatuses ¶
func (d *DeviceDeploymentsStorage) FindOldestDeploymentForDeviceIDWithStatuses(ctx context.Context, deviceID string, statuses ...string) (*deployments.DeviceDeployment, error)
FindOldestDeploymentForDeviceIDWithStatuses find oldest deployment matching device id and one of specified statuses.
func (*DeviceDeploymentsStorage) GetDeviceDeploymentStatus ¶
func (*DeviceDeploymentsStorage) GetDeviceStatusesForDeployment ¶
func (d *DeviceDeploymentsStorage) GetDeviceStatusesForDeployment(ctx context.Context, deploymentID string) ([]deployments.DeviceDeployment, error)
GetDeviceStatusesForDeployment retrieve device deployment statuses for a given deployment.
func (*DeviceDeploymentsStorage) HasDeploymentForDevice ¶
func (d *DeviceDeploymentsStorage) HasDeploymentForDevice(ctx context.Context, deploymentID string, deviceID string) (bool, error)
Returns true if deployment of ID `deploymentID` is assigned to device with ID `deviceID`, false otherwise. In case of errors returns false and an error that occurred
func (*DeviceDeploymentsStorage) InsertMany ¶
func (d *DeviceDeploymentsStorage) InsertMany(ctx context.Context, deployments ...*deployments.DeviceDeployment) error
InsertMany stores multiple device deployment objects. TODO: Handle error cleanup, multi insert is not atomic, loop into two-phase commits
func (*DeviceDeploymentsStorage) UpdateDeviceDeploymentLogAvailability ¶
func (*DeviceDeploymentsStorage) UpdateDeviceDeploymentStatus ¶
func (d *DeviceDeploymentsStorage) UpdateDeviceDeploymentStatus(ctx context.Context, deviceID string, deploymentID string, ddStatus deployments.DeviceDeploymentStatus) (string, error)