Documentation ¶
Index ¶
- Constants
- Variables
- func CloseLogger()
- func CreateBinaries() error
- func CreateRunners() error
- func CreateUsers() error
- func LoadLanguages(activeLanguages []string) error
- func NewLogger(rotation string) (*zap.Logger, error)
- type Language
- type PipeChannel
- type RceEngine
- func (rce *RceEngine) CleanUp(user *pool.User, tempDirName string)
- func (rce *RceEngine) Dispatch(data pool.WorkData, pipeChannel PipeChannel) pool.CodeOutput
- func (rce *RceEngine) DispatchOnce(data pool.WorkData) pool.CodeOutput
- func (rce *RceEngine) DispatchStream(data pool.WorkData, pipeChannel PipeChannel)
Constants ¶
const ( ROTATE_MINUTE = "*/1 * * * *" ROTATE_HOUR = "0 * * * *" ROTATE_DAY = "0 0 * * *" ROTATE_WEEK = "0 0 * * 0" ROTATE_MONTH = "0 0 1 * *" )
Variables ¶
var LoadedLanguages map[string]Language
LoadedLanguages contains all the languages with an identifier as a key and the struct as a value.
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 ¶
LoadLanguages load all the specified active languages and define all the neccessary information for the `Language` struct.
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 ¶
GetLanguageByName gets a language by name from the loaded languages.
func GetLanguages ¶
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 ¶
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.