jobs

package
v0.0.0-...-a01d039 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GID int

GID is used to store the group id associated with a specific group

View Source
var URI = resources.UnmarsharlYaml(resources.ReadFileBytes(getHome() + "/odin-config.yml")).Mongo.Address

URI is used to store the address to the MongoDB instance used by the Odin Engine

Functions

func AddJobLink(client *mongo.Client, from string, to string, uid string) int64

AddJobLink is used to add links the job is associated with parameters: client (a *mongo.Client), from (a string of a job ID to give a new link), to (a string of a job ID to create a link to), uid (a string of the user's ID) returns: int64 (value of the number of entries modified)

func ChownR

func ChownR(path string, uid, gid int) bool

ChownR is used to recursively change the owner of each subdir under /etc parameters: path (a string of the directory path to chown), uid (an int used to set the owner uid), gid (an int used to set the owner gid) returns: bool

func DeleteJobByValue

func DeleteJobByValue(client *mongo.Client, filter bson.M, uid string) bool

DeleteJobByValue is used to delete a job in MongoDB parameters: parameters: client (a *mongo.Client), filter (a bson encoding of a job id), uid (a string of the user's ID) returns: bool (whether a job was deleted or not)

func DeleteJobLink(client *mongo.Client, from string, to string, uid string) int64

DeleteJobLink is used to delete links the job is associated with parameters: client (a *mongo.Client), from (a string of a job ID to remove a link from), to (a string of a job ID to remove), uid (a string of the user's ID) returns: int64 (value of the number of entries modified)

func Format

func Format(id string, description string, valType string, value string) string

Format is used to format the output of MongoDB stat contents parameters: id, description, valType, value (four strings corresponding to individual job stats) returns: string (a space formatted string used for display)

func InsertIntoMongo

func InsertIntoMongo(client *mongo.Client, d []byte, path string, uid string) string

InsertIntoMongo is used to add information to the MongoDB instance parameters: client (a *mongo.Client), d (a byte array containing marshaled JSON), and path (a string to set as the new job.File) returns: interface{} (an interface on the insertion results)

func MakePostRequest

func MakePostRequest(link string, data *bytes.Buffer) string

MakePostRequest is used to make a post request to a given url parameters: link (a string of the link to make a request to), data (a buffer to pass to the post request) returns: string (the result of a POST to the provided link with the given data)

func RunLinks(links []string, uid uint32, httpAddr string, store fsm.Store)

RunLinks is used to run jobs linked to a job which has just been executed parameters: links (a string array of Job ID's to execute), uid (a uint32 of that user's id), httpAddr (a string port of the master node), store (a fsm.Store containing information about other nodes) returns: nil

func SchFormat

func SchFormat(id string, name, string, description string, links string, schedule string) string

SchFormat is used to parse and format the output of the MongoDB schedule contents parameters: id, name, description, schedule (four strings corresponding to individual job data) returns: string (a space formatted string used for display)

func SetupClient

func SetupClient() (*mongo.Client, error)

SetupClient is used to set up a MongoDB client and test it with a ping command parameters: nil returns: *mogno.Client (a client)

func SetupEnvironment

func SetupEnvironment(d []byte) string

SetupEnvironment is used to kickstart the process for setting up the correct directories and files used by odin parameters: d (a byte array containing marshaled JSON) returns: string (the path to the newly created file)

func StartTicker

func StartTicker(store fsm.Store, httpAddr string)

StartTicker starts the countdown process, specifying the parameters of execution for doEvery parameters: store (a fsm containing node information), httpAddr (an address string from the server) returns: nil

func UpdateJobByValue

func UpdateJobByValue(client *mongo.Client, job NewJob) int64

UpdateJobByValue is used to modify a job in MongoDB parameters: client (a *mongo.Client), job (a NewJob structure) returns: int64 (value of the number of entries modified)

Types

type ExecNode

type ExecNode struct {
	Items []byte
	Store fsm.Store
}

ExecNode is a type used to define the job data executed and the finite state machine info

type JobStats

type JobStats struct {
	ID          string
	Description string
	Type        string
	Value       string
}

JobStats is a type to be used for accessing and storing job stats information

func GetJobStats

func GetJobStats(client *mongo.Client, id string) []JobStats

GetJobStats is used to retrieve the stats associated with each job from the MongoDB instance parameters: client (a *mongo.Client), id (a string representation of a job's id) returns: []JobStats (the collection of fetched job stats)

type NewJob

type NewJob struct {
	ID          string `yaml:"id"`
	UID         string `yaml:"uid"`
	GID         string `yaml:"gid"`
	Name        string `yaml:"name"`
	Description string `yaml:"description"`
	Language    string `yaml:"language"`
	File        string `yaml:"file"`
	Stats       string `yaml:"stats"`
	Schedule    string `yaml:"schedule"`
	Runs        int
	Links       string
}

NewJob is a type to be used for accessing and storing job information

func GetAll

func GetAll(client *mongo.Client) []NewJob

GetAll is used to return all jobs in MongoDB parameters: client (a *mongo.Client) returns: []NewJob (all jobs in the Mongo instance)

func GetJobByValue

func GetJobByValue(client *mongo.Client, filter bson.M, uid string) NewJob

GetJobByValue is used to return a job in MongoDB by filtering on a certain value pertaining to that job parameters: client (a *mongo.Client), filter (a bson encoding of a job id), uid (a string of the user's ID) returns: NewJob (the fetched job)

func GetUserJobs

func GetUserJobs(client *mongo.Client, uid string) []NewJob

GetUserJobs is used to return a specific user's jobs from MongoDB parameters: client (a *mongo.Client), uid (a string of that user's id) returns: []NewJob (all jobs in the Mongo instance)

type Node

type Node struct {
	ID       string
	UID      uint32
	GID      uint32
	Lang     string
	File     string
	Schedule []int
	Links    string
}

Node is a type used to define a job in the Queue

type Queue

type Queue struct {
	Items []Node
}

Queue is a type used to access an array of Nodes

Jump to

Keyboard shortcuts

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