pkg

package
v0.0.0-...-6ed6190 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ROTATE_MINUTE = "*/1 * * * *"
	ROTATE_HOUR   = "0 * * * *"
	ROTATE_DAY    = "0 0 * * *"
	ROTATE_WEEK   = "0 0 * * 0"
	ROTATE_MONTH  = "0 0 1 * *"
)

Variables

View Source
var LoadedLanguages map[string]Language

LoadedLanguages contains all the languages with an identifier as a key and the struct as a value.

View Source
var (
	Logger *zap.Logger
)

Functions

func CloseLogger

func CloseLogger()

CloseLogger sets the initialized logger to `nil`, stops the cronjob and disconnects from the database.

func CreateBinaries

func CreateBinaries() error

CreateBinaries gets all the `install.sh` scripts from the activated languages and tries to install all their binaries.

func CreateRunners

func CreateRunners() error

CreateRunners execute the `/scripts/create-runners.sh` script which creates the runners group.

func CreateUsers

func CreateUsers() error

CreateUsers tries to run the `/scripts/create-users.sh` script which adds the linux users to the machine.

func LoadLanguages

func LoadLanguages(activeLanguages []string) error

LoadLanguages load all the specified active languages and define all the neccessary information for the `Language` struct.

func NewLogger

func NewLogger(rotation string) (*zap.Logger, error)

NewLogger creates a new logger with a specific rotation. It also connects to the database and creates a new `zap` logger.

Types

type Language

type Language struct {
	// Name of the language.
	Name string `json:"name"`
	// Version that is currently used.
	Version string `json:"version"`
	// Extension of the to be executed files for the language.
	Extension string `json:"extension"`
	// Timeout of the execution, when the code will be terminated.
	Timeout int `json:"timeout"`
	// Compiled set whether the language needs to be compiled beforehand.
	Compiled bool `json:"compiled"`
}

func GetLanguageByName

func GetLanguageByName(key string) (Language, error)

GetLanguageByName gets a language by name from the loaded languages.

func GetLanguages

func GetLanguages() ([]Language, error)

GetLanguages gets all loaded languages as an array.

type PipeChannel

type PipeChannel struct {
	// Data which represents the streamed output by the execution.
	Data chan pool.StreamOutput
	// Terminate describes whether the execution has terminated or not.
	Terminate chan bool
	// ExecutionInformation describes the information about the execution.
	ExecutionInformation chan pool.ExecutionInformation
}

type RceEngine

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

RceEngine is the main struct which contains the worker pool, the system users and the cache.

func NewRceEngine

func NewRceEngine() *RceEngine

NewRceEngine creates a new RceEngine instance that can be used to execute code.

func (*RceEngine) CleanUp

func (rce *RceEngine) CleanUp(user *pool.User, tempDirName string)

CleanUp cleans up the user's temporary directory, kills all running processes for this user, releases the user's uid and restores the user's directory.

func (*RceEngine) Dispatch

func (rce *RceEngine) Dispatch(data pool.WorkData, pipeChannel PipeChannel) pool.CodeOutput

Dispatch dispatches a new job to the worker pool with streaming or one-time execution functionality. When the `pipeChannel` is an empty struct, it will only execute the job once, but when the argument is not empty, it will stream to the output to the corresponding channels.

func (*RceEngine) DispatchOnce

func (rce *RceEngine) DispatchOnce(data pool.WorkData) pool.CodeOutput

DispatchOnce dispatches a new job to the worker pool and returns the output of the submitted job.

func (*RceEngine) DispatchStream

func (rce *RceEngine) DispatchStream(data pool.WorkData, pipeChannel PipeChannel)

DispatchStream dispatches a new job to the worker pool and streams the output of the submitted job to the `pipeChannel` parameter.

Jump to

Keyboard shortcuts

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