Documentation ¶
Index ¶
Constants ¶
const ( MountSource = "target" MountTarget = "/target" )
const ProgramFilename = "Main"
Variables ¶
var ( Golang = newLanguageCharacteristic("golang", "/usr/local/go/bin/go run Main.go", ".go") Python3 = newLanguageCharacteristic("python3", "python3 Main.py", ".py") Javascript = newLanguageCharacteristic("javascript", "nodejs Main.js", ".js") NodeJS = newLanguageCharacteristic("nodejs", "nodejs Main.js", ".js") Java8 = newLanguageCharacteristic("java8", "javac Main.java && java Main", ".java") C = newLanguageCharacteristic("c", "gcc Main.c -o Main && ./Main", ".c") CPlusplus = newLanguageCharacteristic("c++", "g++ Main.cpp -o Main && ./Main", ".cpp") )
Functions ¶
Types ¶
type Codexec ¶
type Codexec struct {
// contains filtered or unexported fields
}
func New ¶
func New(containerClient ContainerClient, hostConfig *container.HostConfig, write Write) *Codexec
func (*Codexec) Exec ¶
func (c *Codexec) Exec(ctx context.Context, containerID string, info ExecutionInfo) (*ExecutionRes, error)
func (*Codexec) ExecOnce ¶
func (c *Codexec) ExecOnce(ctx context.Context, info ExecutionInfo) (*ExecutionRes, error)
type Codexecutor ¶
type Codexecutor interface {
Exec(ctx context.Context, containerID string, info ExecutionInfo) (*ExecutionRes, error)
}
type ContainerBalancer ¶
type ContainerBalancer struct {
// contains filtered or unexported fields
}
func NewContainerBalancer ¶
func NewContainerBalancer(containerClient ContainerClient, containerPool *ContainerPool, hostConfig *container.HostConfig, executor Codexecutor) *ContainerBalancer
func (*ContainerBalancer) Balance ¶
func (cb *ContainerBalancer) Balance(ticker *time.Ticker)
Balance get the snapshot of the containers average, min and max response times. According to containers response times decide to create new containers or delete the existing ones to not waste a resource. If there is no snapshot just took a snapshot and also limit the container creation and deletion to the min and max limits.
func (*ContainerBalancer) Exec ¶
func (cb *ContainerBalancer) Exec(ctx context.Context, info ExecutionInfo) (*ExecutionRes, error)
Exec get the execution info and find the next container to use that container to execute the programming content when execution is done send response to client and start a goroutine to update the container status and metrics
func (*ContainerBalancer) FillPool ¶
func (cb *ContainerBalancer) FillPool(ctx context.Context)
FillPool use container client to list all active containers and the fill the pool with the active containers
func (*ContainerBalancer) Shutdown ¶
func (cb *ContainerBalancer) Shutdown(ctx context.Context)
type ContainerClient ¶
type ContainerNode ¶
type ContainerNode struct { ID string ExecutionCount int64 AvgResTime time.Duration MaxResTime time.Duration MinResTime time.Duration Prev *ContainerNode Next *ContainerNode }
ContainerNode node that stores the container id, next and prev and metrics information
type ContainerPool ¶
type ContainerPool struct { Head *ContainerNode Tail *ContainerNode Curr *ContainerNode Nodes map[string]*ContainerNode Garbage map[string]*ContainerNode }
ContainerPool stores the container nodes in a structured way Active container nodes stored in a Circular Doubly Linked List and Nodes map Passive, Exited container nodes are removed from CDLL and stored in garbage
func NewContainerPool ¶
func NewContainerPool() *ContainerPool
func (*ContainerPool) Add ¶
func (p *ContainerPool) Add(id string)
func (*ContainerPool) Get ¶
func (p *ContainerPool) Get() *ContainerNode
func (*ContainerPool) Remove ¶
func (p *ContainerPool) Remove(id string)
type ExecutionInfo ¶
func (ExecutionInfo) Command ¶
func (info ExecutionInfo) Command() []string
type ExecutionRes ¶
type LanguageCharacteristic ¶
func (LanguageCharacteristic) Filename ¶
func (c LanguageCharacteristic) Filename() string
type SupportedLanguages ¶
type SupportedLanguages map[string]LanguageCharacteristic
func (SupportedLanguages) Get ¶
func (s SupportedLanguages) Get(lang string) LanguageCharacteristic
func (SupportedLanguages) IsSupported ¶
func (s SupportedLanguages) IsSupported(lang string) bool