Documentation ¶
Index ¶
- Variables
- type Context
- func (context Context) AddModelToApplicableJobs(module types.Module) (err error)
- func (context Context) AsRoot() (rootContext Context)
- func (context Context) Clear(databaseName string) (err error)
- func (context Context) Clone() (clonedContext Context)
- func (context Context) CountJobs(filters F) (count int, err error)
- func (context Context) CountProcesses(filters F) (count int, err error)
- func (context Context) CountTasks(filters F) (count int, err error)
- func (context Context) CreateDataset(dataset types.Dataset) (result types.Dataset, err error)
- func (context Context) CreateJob(job types.Job) (result types.Job, err error)
- func (context Context) CreateModule(module types.Module) (result types.Module, err error)
- func (context Context) CreateProcess(proc types.Process) (result types.Process, err error)
- func (context Context) CreateTask(task types.Task) (result types.Task, err error)
- func (context Context) CreateUser(user types.User) (result types.User, err error)
- func (context Context) FlushDatasetAccessKey(id string) (err error)
- func (context Context) GetConfigCaches(models []string) (result []types.ConfigCache, err error)
- func (context Context) GetDatasetByID(id string) (result types.Dataset, err error)
- func (context Context) GetDatasets(filters F, limit int, cursor string, sortBy string, order string) (result []types.Dataset, cm types.CollectionMetadata, err error)
- func (context Context) GetJobByID(id bson.ObjectId) (result types.Job, err error)
- func (context Context) GetJobConfigSpace(job types.Job) (configSpace string, err error)
- func (context Context) GetJobConfigSpaceByID(id bson.ObjectId) (configSpace string, err error)
- func (context Context) GetJobs(filters F, limit int, cursor string, sortBy string, order string) (result []types.Job, cm types.CollectionMetadata, err error)
- func (context Context) GetModuleByID(id string) (result types.Module, err error)
- func (context Context) GetModules(filters F, limit int, cursor string, sortBy string, order string) (result []types.Module, cm types.CollectionMetadata, err error)
- func (context Context) GetProcessByID(id bson.ObjectId) (result types.Process, err error)
- func (context Context) GetProcesses(filters F, limit int, cursor string, sortBy string, order string) (result []types.Process, cm types.CollectionMetadata, err error)
- func (context Context) GetTaskByID(id string) (result types.Task, err error)
- func (context Context) GetTasks(filters F, limit int, cursor string, sortBy string, order string) (result []types.Task, cm types.CollectionMetadata, err error)
- func (context Context) GetUserByAPIKey(apiKey string) (result types.User, err error)
- func (context Context) GetUserByID(id string) (result types.User, err error)
- func (context Context) GetUsers(filters F, limit int, cursor string, sortBy string, order string) (result []types.User, cm types.CollectionMetadata, err error)
- func (context Context) Initialize(databaseName string) (err error)
- func (context Context) LockDataset(filters F, processID bson.ObjectId, sortBy string, order string) (result types.Dataset, err error)
- func (context Context) LockJob(filters F, processID bson.ObjectId, sortBy string, order string) (result types.Job, err error)
- func (context Context) LockModule(filters F, processID bson.ObjectId, sortBy string, order string) (result types.Module, err error)
- func (context Context) LockTask(filters F, processID bson.ObjectId, sortBy string, order string) (result types.Task, err error)
- func (context Context) PauseRunningTasks(jobID bson.ObjectId) (err error)
- func (context Context) ProcessKeepalive(id bson.ObjectId) (err error)
- func (context Context) ReleaseDatasetLockByProcess(processID bson.ObjectId) (numReleased int, err error)
- func (context Context) ReleaseJobLockByProcess(processID bson.ObjectId) (numReleased int, err error)
- func (context Context) ReleaseModuleLockByProcess(processID bson.ObjectId) (numReleased int, err error)
- func (context Context) ReleaseTaskLockByProcess(processID bson.ObjectId) (numReleased int, err error)
- func (context Context) ResumePausedTasks(jobID bson.ObjectId) (err error)
- func (context Context) SetProcessStatus(id bson.ObjectId, status string) (result types.Process, err error)
- func (context Context) StartProcess(processType string) (result types.Process, err error)
- func (context Context) TerminateDeadProcesses(cutoffTime time.Time) (err error)
- func (context Context) TerminateRunningTasks(jobID bson.ObjectId) (err error)
- func (context Context) UnlockDataset(id string, processID bson.ObjectId) (err error)
- func (context Context) UnlockJob(id bson.ObjectId, processID bson.ObjectId) (err error)
- func (context Context) UnlockModule(id string, processID bson.ObjectId) (err error)
- func (context Context) UnlockTask(id string, processID bson.ObjectId) (err error)
- func (context Context) UpdateDataset(id string, updates map[string]interface{}) (result types.Dataset, err error)
- func (context Context) UpdateDatasetStatus(id string, status string, statusMessage string) (err error)
- func (context Context) UpdateJob(id bson.ObjectId, updates map[string]interface{}) (result types.Job, err error)
- func (context Context) UpdateModule(id string, updates map[string]interface{}) (result types.Module, err error)
- func (context Context) UpdateModuleStatus(id string, status string, statusMessage string) (err error)
- func (context Context) UpdateProcess(id bson.ObjectId, updates map[string]interface{}) (result types.Process, err error)
- func (context Context) UpdateTask(id string, updates map[string]interface{}) (result types.Task, err error)
- func (context Context) UpdateTaskStage(id string, stage string) (err error)
- func (context Context) UpdateTaskStatus(id string, status string, statusMessage string) (err error)
- func (context Context) UpdateUser(id string, updates map[string]interface{}) (result types.User, err error)
- func (context Context) UserAuthenticate(user types.User) (result types.User, err error)
- func (context Context) UserDeleteAPIKey() (err error)
- func (context Context) UserGenerateAPIKey() (result string, err error)
- func (context Context) UserLogin() (result types.User, err error)
- func (context Context) UserLogout() (err error)
- type F
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound can be returend when we look for a specific single resource // by its ID but we get no result. ErrNotFound = e.New("requested resource not found") // ErrBadInput can be returned when a model function is given invalid parameters. ErrBadInput = e.New("the provided set of parameters is invalid") )
var IDRegexp = regexp.MustCompile(`^[a-zA-Z0-9_-]+$`)
IDRegexp defines the pattern of all acceptable identifiers.
var IDRegexpNegative = regexp.MustCompile(`[^a-zA-Z0-9_-]+`)
IDRegexpNegative defines all unacceptable characters in an identifier.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context contains information needed to access the data model and authorize the acessor.
func Connect ¶
func Connect(dataSourceName string, databaseName string, anonimous bool) (context Context, err error)
Connect establishes a connection with the database and returns a model context instance.
func (Context) AddModelToApplicableJobs ¶
AddModelToApplicableJobs searches for all datasets to which a model is applicable, looks for all jobs running on those datasets and adds the model to them if they have "accept-new-models" set to true.
func (Context) AsRoot ¶
AsRoot elevates the current model access context to root access privileges. Should be used only in special cases.
func (Context) CountJobs ¶
CountJobs is the same as GetJobs but returns only the count, not the actual tasks.
func (Context) CountProcesses ¶
CountProcesses is the same as GetProcesses but returns only the count, not the actual processes.
func (Context) CountTasks ¶
CountTasks is the same as GetTasks but returns only the count, not the actual tasks.
func (Context) CreateDataset ¶
CreateDataset adds a given dataset to the database.
func (Context) CreateModule ¶
CreateModule adds a given module to the database.
func (Context) CreateProcess ¶
CreateProcess adds a given process to the database.
func (Context) CreateTask ¶
CreateTask adds a given task to the database.
func (Context) CreateUser ¶
CreateUser adds the given user to the database.
func (Context) FlushDatasetAccessKey ¶
FlushDatasetAccessKey removes a used accessKey from the database.
func (Context) GetConfigCaches ¶
func (context Context) GetConfigCaches(models []string) (result []types.ConfigCache, err error)
GetConfigCaches returns a list of config for a given set of models. If models is nil, then all models are considered.
func (Context) GetDatasetByID ¶
GetDatasetByID returns the dataset given its id. The id is given as "user-id/dataset-id".
func (Context) GetDatasets ¶
func (context Context) GetDatasets( filters F, limit int, cursor string, sortBy string, order string, ) (result []types.Dataset, cm types.CollectionMetadata, err error)
GetDatasets lists all datasets given some filter criteria.
func (Context) GetJobByID ¶
GetJobByID returns the job given its id. The id is given as "user-id/job-id".
func (Context) GetJobConfigSpace ¶
GetJobConfigSpace takes a job and builds a complete config space given its models.
func (Context) GetJobConfigSpaceByID ¶
GetJobConfigSpaceByID searches for a job by ID and builds a complete config space given its models.
func (Context) GetJobs ¶
func (context Context) GetJobs( filters F, limit int, cursor string, sortBy string, order string, ) (result []types.Job, cm types.CollectionMetadata, err error)
GetJobs lists all jobs given some filter criteria.
func (Context) GetModuleByID ¶
GetModuleByID returns the module given its id. The id is given as "user-id/module-id".
func (Context) GetModules ¶
func (context Context) GetModules( filters F, limit int, cursor string, sortBy string, order string, ) (result []types.Module, cm types.CollectionMetadata, err error)
GetModules lists all modules given some filter criteria.
func (Context) GetProcessByID ¶
GetProcessByID returns a process given its id.
func (Context) GetProcesses ¶
func (context Context) GetProcesses( filters F, limit int, cursor string, sortBy string, order string, ) (result []types.Process, cm types.CollectionMetadata, err error)
GetProcesses lists all processes given some filter criteria.
func (Context) GetTaskByID ¶
GetTaskByID returns the task given its id. The id is given as "user-id/task-id".
func (Context) GetTasks ¶
func (context Context) GetTasks( filters F, limit int, cursor string, sortBy string, order string, ) (result []types.Task, cm types.CollectionMetadata, err error)
GetTasks lists all tasks given some filter criteria.
func (Context) GetUserByAPIKey ¶
GetUserByAPIKey looks up a user by its API key.
func (Context) GetUserByID ¶
GetUserByID returns a user given its id.
func (Context) GetUsers ¶
func (context Context) GetUsers( filters F, limit int, cursor string, sortBy string, order string, ) (result []types.User, cm types.CollectionMetadata, err error)
GetUsers lists all users given some filter criteria.
func (Context) Initialize ¶
Initialize ensures that the target database is properly initalized.
func (Context) LockDataset ¶
func (context Context) LockDataset( filters F, processID bson.ObjectId, sortBy string, order string, ) (result types.Dataset, err error)
LockDataset scans the available datasets (that are not currently locked), applies the specified filters, sorts them if specified and locks the first one by assigning it to the specified process.
func (Context) LockJob ¶
func (context Context) LockJob( filters F, processID bson.ObjectId, sortBy string, order string, ) (result types.Job, err error)
LockJob scans the available jobs (that are not currently locked), applies the specified filters, sorts them if specified and locks the first one by assigning it to the specified process.
func (Context) LockModule ¶
func (context Context) LockModule( filters F, processID bson.ObjectId, sortBy string, order string, ) (result types.Module, err error)
LockModule scans the available modules (that are not currently locked), applies the specified filters, sorts them if specified and locks the first one by assigning it to the specified process.
func (Context) LockTask ¶
func (context Context) LockTask( filters F, processID bson.ObjectId, sortBy string, order string, ) (result types.Task, err error)
LockTask scans the available tasks (that are not currently locked), applies the specified filters, sorts them if specified and locks the first one by assigning it to the specified process.
func (Context) PauseRunningTasks ¶
PauseRunningTasks goes through all tasks of a job that are still running and marks them as pausing.
func (Context) ProcessKeepalive ¶
ProcessKeepalive updates the keepalive-time field of the process thus notifying the system that it is still running.
func (Context) ReleaseDatasetLockByProcess ¶
func (context Context) ReleaseDatasetLockByProcess(processID bson.ObjectId) (numReleased int, err error)
ReleaseDatasetLockByProcess releases all datasets that have been locked by a given process and are not in the error state.
func (Context) ReleaseJobLockByProcess ¶
func (context Context) ReleaseJobLockByProcess(processID bson.ObjectId) (numReleased int, err error)
ReleaseJobLockByProcess releases all jobs that have been locked by a given process and are not in the error state.
func (Context) ReleaseModuleLockByProcess ¶
func (context Context) ReleaseModuleLockByProcess(processID bson.ObjectId) (numReleased int, err error)
ReleaseModuleLockByProcess releases all modules that have been locked by a given process and are not in the error state.
func (Context) ReleaseTaskLockByProcess ¶
func (context Context) ReleaseTaskLockByProcess(processID bson.ObjectId) (numReleased int, err error)
ReleaseTaskLockByProcess releases all tasks that have been locked by a given process and are not in the error state.
func (Context) ResumePausedTasks ¶
ResumePausedTasks goes through all tasks of a job that are pausing or paused and marks them as scheduled.
func (Context) SetProcessStatus ¶
func (context Context) SetProcessStatus(id bson.ObjectId, status string) (result types.Process, err error)
SetProcessStatus updates the processes state to terminated.
func (Context) StartProcess ¶
StartProcess starts a process of a given type and initializes all other fields automatically.
func (Context) TerminateDeadProcesses ¶
TerminateDeadProcesses goes through all processes that have stopped making keepalive updates and sets their status to terminated.
func (Context) TerminateRunningTasks ¶
TerminateRunningTasks goes through all tasks of a job that are still running and marks them as terminating.
func (Context) UnlockDataset ¶
UnlockDataset releases the lock on a given dataset.
func (Context) UnlockModule ¶
UnlockModule releases the lock on a given module.
func (Context) UnlockTask ¶
UnlockTask releases the lock on a given task.
func (Context) UpdateDataset ¶
func (context Context) UpdateDataset(id string, updates map[string]interface{}) (result types.Dataset, err error)
UpdateDataset updates the information about a given dataset.
func (Context) UpdateDatasetStatus ¶
func (context Context) UpdateDatasetStatus(id string, status string, statusMessage string) (err error)
UpdateDatasetStatus sets the status of the dataset and assigns the given status message.
func (Context) UpdateJob ¶
func (context Context) UpdateJob(id bson.ObjectId, updates map[string]interface{}) (result types.Job, err error)
UpdateJob updates the information about a given job.
func (Context) UpdateModule ¶
func (context Context) UpdateModule(id string, updates map[string]interface{}) (result types.Module, err error)
UpdateModule updates the information about a given module.
func (Context) UpdateModuleStatus ¶
func (context Context) UpdateModuleStatus(id string, status string, statusMessage string) (err error)
UpdateModuleStatus sets the status of the module and assigns the given status message.
func (Context) UpdateProcess ¶
func (context Context) UpdateProcess(id bson.ObjectId, updates map[string]interface{}) (result types.Process, err error)
UpdateProcess updates the information about a given process.
func (Context) UpdateTask ¶
func (context Context) UpdateTask(id string, updates map[string]interface{}) (result types.Task, err error)
UpdateTask updates the information about a given task.
func (Context) UpdateTaskStage ¶
UpdateTaskStage sets the stage of the task.
func (Context) UpdateTaskStatus ¶
UpdateTaskStatus sets the status of the task and assigns the given status message.
func (Context) UpdateUser ¶
func (context Context) UpdateUser(id string, updates map[string]interface{}) (result types.User, err error)
UpdateUser updates the information about a given user.
func (Context) UserAuthenticate ¶
UserAuthenticate checks the credentials of a given user against the users in the database. If the APIKey field contains a non-zero value, then an attempt to authenticate is made with that key. Otherwise, an attempt is made with the ID and PasswordHash fields.
func (Context) UserDeleteAPIKey ¶
UserDeleteAPIKey deletes the API key of the user.
func (Context) UserGenerateAPIKey ¶
UserGenerateAPIKey creates a new API key for the user and stores it in the database. The operation only works if the API key in the context corresponds to the API key in the database. Otherwise, no change will be applied and the caller should try again.
func (Context) UserLogin ¶
UserLogin logs in the user from the context. It is assumed that the user is already authenticated.
func (Context) UserLogout ¶
UserLogout logs the user out and invalidates their API key.