database

package
v0.0.0-...-8f1fe78 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Name   string
	Secret string
	Token  string
}

Database types to serialize back into

type Database

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

func InitDatabase

func InitDatabase(filepath string, cleanup bool) (*Database, error)

func (*Database) AcceptJobs

func (db *Database) AcceptJobs(
	request *pb.AcceptJobsRequest,
	cluster *Cluster,
) (*pb.AcceptJobsResponse, error)

AcceptJobs We use this function after validating a cluster with a secret and simply retrieve the ids and delete them from the database if they exist

func (*Database) GetCluster

func (db *Database) GetCluster(name string) (*Cluster, error)

GetCluster gets a cluster by name

func (*Database) ReceiveJobs

func (db *Database) ReceiveJobs(
	request *pb.ReceiveJobsRequest,
	cluster *Cluster,
) (*pb.ReceiveJobsResponse, error)

Request MaxJobs for a cluster to receive

func (*Database) RegisterCluster

func (db *Database) RegisterCluster(
	name, globalToken string,
	nodesGraph graph.JsonGraph,
) (*pb.RegisterResponse, error)

RegisterCluster registers a cluster or returns another status

func (*Database) SubmitJob

func (db *Database) SubmitJob(
	job *pb.SubmitJobRequest,
	cluster *Cluster,
) (*pb.SubmitJobResponse, error)

SubmitJob adds the assigned job to the database

func (*Database) ValidateClusterSecret

func (db *Database) ValidateClusterSecret(name, secret string) (*Cluster, error)

ValidateClusterSecret checks if a cluster secret is valid The secret is used for validating a request for jobs.

func (*Database) ValidateClusterToken

func (db *Database) ValidateClusterToken(name, token string) (*Cluster, error)

ValidateClusterToken checks if a cluster token is valid The token is used for validating a submission request.

type Job

type Job struct {
	Id      int32  `json:"id"`
	Cluster string `json:"cluster"`
	Name    string `json:"name"`
	Jobspec string `json:"jobspec"`
	Command string `json:"command"`
}

func (*Job) ToJson

func (j *Job) ToJson() (string, error)

ToJson converts the job to json for sending back!

Jump to

Keyboard shortcuts

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