mongo

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

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

Go to latest
Published: Jun 12, 2017 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseName          = "deployment_service"
	CollectionDeployments = "deployments"
)

Database settings

View Source
const (
	StorageKeyDeploymentName         = "deploymentconstructor.name"
	StorageKeyDeploymentArtifactName = "deploymentconstructor.artifactname"
	StorageKeyDeploymentStats        = "stats"
	StorageKeyDeploymentFinished     = "finished"
)
View Source
const (
	StorageKeyDeviceDeploymentAssignedImage   = "image"
	StorageKeyDeviceDeploymentAssignedImageId = StorageKeyDeviceDeploymentAssignedImage + "." + imagesMongo.StorageKeySoftwareImageId
	StorageKeyDeviceDeploymentDeviceId        = "deviceid"
	StorageKeyDeviceDeploymentStatus          = "status"
	StorageKeyDeviceDeploymentDeploymentID    = "deploymentid"
	StorageKeyDeviceDeploymentFinished        = "finished"
	StorageKeyDeviceDeploymentIsLogAvailable  = "log"
)

Database keys

View Source
const (
	// TODO: do we have any naming convention for mongo collections?
	CollectionDeviceDeploymentLogs = "devices.logs"
)

Database settings

View Source
const (
	CollectionDevices = "devices"
)

Database settings

View Source
const (
	StorageKeyDeviceDeploymentLogMessages = "messages"
)

Database keys

Variables

View Source
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

View Source
var (
	ErrStorageInvalidDeviceDeployment = errors.New("Invalid device deployment")
)

Errors

View Source
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) Find

func (*DeploymentsStorage) FindByID

func (*DeploymentsStorage) FindUnfinishedByID

func (d *DeploymentsStorage) FindUnfinishedByID(ctx context.Context,
	id string) (*deployments.Deployment, error)

func (*DeploymentsStorage) Finish

func (d *DeploymentsStorage) Finish(ctx context.Context, id string, when time.Time) error

func (*DeploymentsStorage) Insert

func (d *DeploymentsStorage) Insert(ctx context.Context, deployment *deployments.Deployment) error

Insert persists object

func (*DeploymentsStorage) UpdateStats

func (d *DeploymentsStorage) UpdateStats(ctx context.Context, id string,
	state_from, state_to string) error

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) 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 (d *DeviceDeploymentsStorage) GetDeviceDeploymentStatus(ctx context.Context,
	deploymentID string, deviceID string) (string, error)

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 (d *DeviceDeploymentsStorage) UpdateDeviceDeploymentLogAvailability(ctx context.Context,
	deviceID string, deploymentID string, log bool) error

func (*DeviceDeploymentsStorage) UpdateDeviceDeploymentStatus

func (d *DeviceDeploymentsStorage) UpdateDeviceDeploymentStatus(ctx context.Context,
	deviceID string, deploymentID string, status string, finishTime *time.Time) (string, error)

Jump to

Keyboard shortcuts

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