request

package
v0.0.0-...-f628d08 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddJobStatus

func AddJobStatus(jobMsg *RunJobMessage, status *JobStatus)

AddJobStatus add a stage to job's runtime info

func GetCloudor

func GetCloudor(username *string, token *string, apiPath string) ([]byte, error)

GetCloudor issues a Get to ServerURL

func GetJobDuration

func GetJobDuration(jobMsg *RunJobMessage) int64

GetJobDuration gets the elapsed time in second between finished/failed to started

func GetMD5

func GetMD5(fileName string) (string, error)

GetMD5 returns a md5 of a file

func GetStatusTs

func GetStatusTs(jobMsg *RunJobMessage, status string) int64

GetStatusTs returns the unix time in second for a status

func LastStatus

func LastStatus(jobMsg *RunJobMessage) string

LastStatus gets the last stage's status

func LoginCloudor

func LoginCloudor(username, password, urlPath string) ([]byte, error)

LoginHandler handles login requets

func PostCloudor

func PostCloudor(requestBody *[]byte, username *string, token *string, apiPath string) (*resty.Response, error)

PostCloudor issues a POST to ServerURL

func TrimQuotes

func TrimQuotes(s string) string

Types

type Cost

type Cost struct {
	HourRate       float64 `json:"hour_rate,omitempty" yaml:"hour_rate"`
	RateUnit       string  `json:"rate_unit,omitempty" yaml:"rate_unit"`
	ComputeCost    float64 `json:"compute_cost,omitempty" yaml:"compute_cost"`
	EgressGB       float64 `json:"egress_gb,omitempty" yaml:"egress_gb"`
	EgressCost     float64 `json:"egress_cost,omitempty" yaml:"egress_cost"`
	AdjustCost     float64 `json:"adjust_cost,omitempty" yaml:"adjust_cost"`
	ReservedCredit float64 `json:"reserved_credit,omitempty" yaml:"reserved_credit"`
}

type CreateRequest

type CreateRequest struct {
	UserName string `json:"user_name,omitempty" yaml:"user_name"`
	YAML     string `json:"yaml,omitempty" yaml:"yaml"`
	Name     string `json:"name,omitempty" yaml:"name"`
	Image    string `json:"image,omitempty" yaml:"image"`
}

CreateRequest defines the create request

type CreditSchema

type CreditSchema struct {
	UserName string  `json:"user_name,omitempty" yaml:"user_name"`
	Credit   float64 `json:"credit,omitempty" yaml:"credit"`
	Reserved float64 `json:"reserved,omitempty" yaml:"reserved"`
	Unit     string  `json:"unit,omitempty" yaml:"unit"`
}

CreditSchema defines the credit interface

type Instance

type Instance struct {
	Price     float64 `json:"price,omitempty"`
	Unit      string  `json:"unit,omitempty"`
	CPU       int32   `json:"cpu,omitempty"`
	GPU       string  `json:"gpu,omitempty"`
	MemoryGiB int32   `json:"memory_gib,omitempty"`
}

Instance specifies instance features

type JobRunInfo

type JobRunInfo struct {
	// unique id, read-only
	// job name, can be auto-generated
	JobName      string             `json:"job_name,omitempty" yaml:"job_name"`
	TimeoutInMin float64            `json:"timeout_in_min,omitempty" yaml:"timeout_in_min"`
	Duration     int64              `json:"duration,omitempty" yaml:"duration"`
	Instances    *int32             `json:"instances,omitempty" yaml:"instances"`
	Cost         Cost               `json:"cost,omitempty" yaml:"cost"`
	VendorIndex  *int32             `json:"vendor_index,omitempty" yaml:"vendor_index"`
	InputStages  []api.StageStorage `json:"input_stages,omitempty" yaml:"input_stages"`
	OutputStage  []api.StageStorage `json:"output_stage,omitempty" yaml:"output_stage"`
	ImageStage   api.StageStorage   `json:"image_stage,omitempty" yaml:"image_stage"`
	WorkingDir   string             `json:"working_dir,omitempty" yaml:"working_dir"`
	Stages       []Status           `json:"stages,omitempty" yaml:"stages"`
	// Internal usage
	UpdateNotice api.Notice        `json:"update_notice,omitempty" yaml:"update_notice"`
	Reserved     map[string]string `json:"reserved,omitempty" yaml:"reserved"`
}

type JobStat

type JobStat struct {
	Booting         int32
	Running         int32
	AssignInstances int
}

type JobStatus

type JobStatus struct {
	UserName    string `json:"user_name,omitempty" yaml:"user_name"`
	ID          string `json:"id,omitempty" yaml:"id"`
	Status      string `json:"status,omitempty" yaml:"status"`
	StatusCode  int32  `json:"status_code,omitempty" yaml:"status_code"`
	Vendor      string `json:"vendor,omitempty" yaml:"vendor"`
	Description string `json:"description,omitempty" yaml:"description"`
}

JobStatus is used for streaming job status to the client

type ListClustersResponse

type ListClustersResponse struct {
	Vendor       string   `json:"vendor" yaml:"vendor"`
	Region       string   `json:"region" yaml:"region"`
	InstanceType string   `json:"instance_type" yaml:"instance"`
	Queue        []string `json:"queue,omitempty" yaml:"queue"`
}

type ListJobRequest

type ListJobRequest struct {
	UserName string `json:"user_name,omitempty"`
	ID       string `json:"id,omitempty"`
	Status   string `json:"status,omitempty"`
}

type LoginResponse

type LoginResponse struct {
	Token string `json:"token,omitempty"`
}

LoginResponse defines the body from login request

type RunJobMessage

type RunJobMessage struct {
	UserName   string     `json:"user_name,omitempty" yaml:"user_name"`
	Created    int64      `json:"created,omitempty" yaml:"created"`
	ID         string     `json:"id,omitempty" yaml:"id"`
	RunInfo    JobRunInfo `json:"run_info,omitempty" yaml:"run_info"`
	VendorMeta string     `json:"vendor_meta,omitempty" yaml:"vendor_meta"`
	Job        api.Job    `json:"job,omitempty" yaml:"job"`
}

RunJobMessage is the structured data structure for communication

type RunJobRequest

type RunJobRequest struct {
	UserName     string  `json:"user_name,omitempty" yaml:"user_name"`
	JobName      string  `json:"job_name,omitempty" yaml:"job_name"`
	RunTag       string  `json:"run_tag,omitempty" yaml:"run_tag"`
	DryRun       bool    `json:"dry_run,omitempty" yaml:"dry_run"`
	NumInstances int     `json:"num_instances,omitempty" yaml:"num_instances"`
	TimeoutInMin float64 `json:"timeout_in_min,omitempty" yaml:"timeout_in_min"`
	YAML         string  `json:"yaml,omitempty" yaml:"yaml"`
}

RunJobRequest defines the request for running a job

type SchedulerStatus

type SchedulerStatus struct {
	Waiting int
	Status  map[string]State
}

type SignupRequest

type SignupRequest struct {
	Email    string `json:"email,omitempty"`
	Password string `json:"password,omitempty"`
}

type State

type State struct {
	Idling      int
	Busying     int
	Reserved    int
	Terminating int
	Booting     int
	Max         int
	Tag         string
	JobState    *JobStat
}

type Status

type Status struct {
	ReturnCode  int32  `json:"return_code,omitempty" yaml:"return_code"`
	Status      string `json:"status,omitempty" yaml:"status"`
	Description string `json:"description,omitempty" yaml:"description"`
	StdOut      string `json:"std_out,omitempty" yaml:"stdout"`
	UnixTime    int64  `json:"unix_time,omitempty" yaml:"unix_time"`
}

type SupportedOSArch

type SupportedOSArch struct {
	OS      string `json:"os,omitempty" yaml:"os"`
	Arch    string `json:"arch,omitempty" yaml:"arch"`
	Release string `json:"release,omitempty" yaml:"release"`
	MD5     string `json:"md5,omitempty" yaml:"md5"`
}

SupportedOSArch defines a supported os/arch pairs

type TransInfo

type TransInfo struct {
	// job or pay
	Type         string  `json:"type,omitempty"`
	JobID        string  `json:"job_id,omitempty"`
	CreditBefore float64 `json:"credit_before,omitempty"`
	CreditAfter  float64 `json:"credit_after,omitempty"`
}

TransInfo defines a transaction

type TransSchema

type TransSchema struct {
	UserName  string    `json:"user_name,omitempty"`
	ID        string    `json:"id,omitempty"`
	TimeStamp int64     `json:"timestamp,omitempty"`
	Amount    float64   `json:"amount"`
	Unit      string    `json:"unit,omitempty"`
	Info      TransInfo `json:"info,omitempty"`
}

TransSchema defines the json returned from transaction list

type Vendors

type Vendors map[string]map[string]map[string]Instance

Vendors defines a multi-level map of vendor instances vendor_name -> region -> instance_type -> Instance

Jump to

Keyboard shortcuts

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