mongodb

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseName = "flame"

	ComputeCollection    = "t_compute"
	DatasetCollection    = "t_dataset"
	DesignCollection     = "t_design"
	JobCollection        = "t_job"
	TaskCollection       = "t_task"
	DeploymentCollection = "t_deployment"
)

Variables

This section is empty.

Functions

func ErrorCheck

func ErrorCheck(err error) error

func GetStringID

func GetStringID(id interface{}) string

Types

type FileInfo

type FileInfo struct {
	ZipName  string          `json:"zipname"`
	DataSet  []util.FileData `json:"dataset"`
	Revision int32           `json:"revision"`
}

type MongoService

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

func NewMongoService

func NewMongoService(uri string) (*MongoService, error)

func NewMongoServiceWithClient added in v0.2.2

func NewMongoServiceWithClient(ctx context.Context, client *mongo.Client) (*MongoService, error)

func (*MongoService) CreateDataset

func (db *MongoService) CreateDataset(userId string, dataset openapi.DatasetInfo) (string, error)

CreateDataset creates a new dataset entry in the database

func (*MongoService) CreateDesign

func (db *MongoService) CreateDesign(userId string, design openapi.Design) error

CreateDesign create a new design entry in the database

func (*MongoService) CreateDesignCode

func (db *MongoService) CreateDesignCode(userId string, designId string, fileName string, fileData *os.File) error

func (*MongoService) CreateDesignSchema

func (db *MongoService) CreateDesignSchema(userId string, designId string, ds openapi.DesignSchema) error

CreateDesignSchema adds schema design to the design template information

func (*MongoService) CreateJob

func (db *MongoService) CreateJob(userId string, jobSpec openapi.JobSpec) (openapi.JobStatus, error)

CreateJob creates a new job specification and returns JobStatus

func (*MongoService) CreateTasks

func (db *MongoService) CreateTasks(tasks []objects.Task, dirty bool) error

CreateTasks creates task records in task db collection

func (*MongoService) DeleteDesign added in v0.1.6

func (db *MongoService) DeleteDesign(userId string, designId string) error

func (*MongoService) DeleteDesignCode added in v0.1.6

func (db *MongoService) DeleteDesignCode(userId string, designId string) error

func (*MongoService) DeleteDesignSchema added in v0.1.6

func (db *MongoService) DeleteDesignSchema(userId string, designId string) error

DeleteDesignSchema deletes design schema for the given design Id

func (*MongoService) DeleteJob

func (db *MongoService) DeleteJob(userId string, jobId string) error

func (*MongoService) DeleteTasks

func (db *MongoService) DeleteTasks(jobId string, dirty bool) error

func (*MongoService) GetComputeById added in v0.1.5

func (db *MongoService) GetComputeById(computeId string) (openapi.ComputeSpec, error)

func (*MongoService) GetComputeIdsByRegion added in v0.1.5

func (db *MongoService) GetComputeIdsByRegion(region string) ([]string, error)

func (*MongoService) GetDatasetById

func (db *MongoService) GetDatasetById(datasetId string) (openapi.DatasetInfo, error)

func (*MongoService) GetDatasets

func (db *MongoService) GetDatasets(userId string, limit int32) ([]openapi.DatasetInfo, error)

func (*MongoService) GetDesign

func (db *MongoService) GetDesign(userId string, designId string) (openapi.Design, error)

GetDesign returns the details about the given design id

func (*MongoService) GetDesignCode

func (db *MongoService) GetDesignCode(userId string, designId string) ([]byte, error)

func (*MongoService) GetDesignCodeRevision added in v0.3.0

func (db *MongoService) GetDesignCodeRevision(userId string, designId string) (openapi.CodeApiResponse, error)

func (*MongoService) GetDesignSchema

func (db *MongoService) GetDesignSchema(userId string, designId string) (openapi.DesignSchema, error)

func (*MongoService) GetDesigns

func (db *MongoService) GetDesigns(userId string, limit int32) ([]openapi.DesignInfo, error)

GetDesigns get a lists of all the designs created by the user TODO: update the method to implement a limit next based cursor

func (*MongoService) GetJob

func (db *MongoService) GetJob(userId string, jobId string) (openapi.JobSpec, error)

func (*MongoService) GetJobById

func (db *MongoService) GetJobById(jobId string) (openapi.JobSpec, error)

func (*MongoService) GetJobStatus

func (db *MongoService) GetJobStatus(userId string, jobId string) (openapi.JobStatus, error)

func (*MongoService) GetJobs

func (db *MongoService) GetJobs(userId string, limit int32) ([]openapi.JobStatus, error)

func (*MongoService) GetJobsByCompute added in v0.2.3

func (db *MongoService) GetJobsByCompute(computeId string) ([]openapi.JobStatus, error)

func (*MongoService) GetTask

func (db *MongoService) GetTask(jobId string, taskId string, key string) (map[string][]byte, error)

func (*MongoService) GetTaskInfo added in v0.1.2

func (db *MongoService) GetTaskInfo(userId string, jobId string, taskId string) (openapi.TaskInfo, error)

func (*MongoService) GetTasksInfo

func (db *MongoService) GetTasksInfo(userId string, jobId string, limit int32, inclKey bool) ([]openapi.TaskInfo, error)

func (*MongoService) GetTasksInfoGeneric added in v0.1.5

func (db *MongoService) GetTasksInfoGeneric(client string, jobId string, limit int32,
	inclKey bool, isDeployer bool) ([]openapi.TaskInfo, error)

This is a generic function to return a list of task information. Two types of clients us it: (a) users and (b) deployers. If the client is a user, the taskInfo may or may not include taskKey (as required). If the deployer calls it, the taskKey is likely to be returned.

func (*MongoService) IsOneTaskInState

func (db *MongoService) IsOneTaskInState(jobId string, state openapi.JobState) bool

IsOneTaskInState returns true if the state of at least one task is set to the given state. Otherwise, it returns false.

func (*MongoService) IsOneTaskInStateWithRole

func (db *MongoService) IsOneTaskInStateWithRole(jobId string, state openapi.JobState, role string) bool

func (*MongoService) MonitorTasks

func (db *MongoService) MonitorTasks(jobId string) (chan openapi.TaskInfo, chan error, context.CancelFunc, error)

MonitorTasks creates and returns a watcher to monitor state changes of tasks in a job

func (*MongoService) RegisterCompute added in v0.1.5

func (db *MongoService) RegisterCompute(computeSpec openapi.ComputeSpec) (openapi.ComputeStatus, error)

RegisterCompute creates a new cluster compute specification and returns ComputeStatus

func (*MongoService) SetTaskDirtyFlag

func (db *MongoService) SetTaskDirtyFlag(jobId string, dirty bool) error

func (*MongoService) UpdateComputeStatus added in v0.1.5

func (db *MongoService) UpdateComputeStatus(computeId string, computeStatus openapi.ComputeStatus) (time.Time, error)

UpdateComputeStatus update compute cluster's status

func (*MongoService) UpdateDeploymentStatus added in v0.1.6

func (db *MongoService) UpdateDeploymentStatus(computeId string, jobId string, agentStatuses map[string]openapi.AgentState) error

func (*MongoService) UpdateDesignSchema

func (db *MongoService) UpdateDesignSchema(userId string, designId string, ds openapi.DesignSchema) error

func (*MongoService) UpdateJob

func (db *MongoService) UpdateJob(userId string, jobId string, jobSpec openapi.JobSpec) error

func (*MongoService) UpdateJobStatus

func (db *MongoService) UpdateJobStatus(userId string, jobId string, jobStatus openapi.JobStatus) error

UpdateJobStatus update Job's status

func (*MongoService) UpdateTaskStateByFilter

func (db *MongoService) UpdateTaskStateByFilter(jobId string, newState openapi.JobState, userFilter map[string]interface{}) error

UpdateTaskStateByFilter updates the status of tasks on a particular state in a job. The function should be only called by a system; hence, this function shouldn't become open to user API

func (*MongoService) UpdateTaskStatus

func (db *MongoService) UpdateTaskStatus(jobId string, taskId string, taskStatus openapi.TaskStatus) error

Jump to

Keyboard shortcuts

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