Add queuing system
This commit is contained in:
parent
bb86563ed9
commit
f2eacf41cf
6 changed files with 106 additions and 17 deletions
|
|
@ -6,8 +6,23 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
const CTR_NAME_PREFIX = "minifaas"
|
||||
|
||||
func GenContainerPrefix(jobtype string) string {
|
||||
return fmt.Sprintf("minifaas-%x-", sha256.Sum224([]byte(jobtype)))
|
||||
return fmt.Sprintf("%s-%x-", CTR_NAME_PREFIX, sha256.Sum224([]byte(jobtype)))
|
||||
}
|
||||
|
||||
func ParseContainerName(name string) (jobtype, id string, err error) {
|
||||
if !strings.HasPrefix(name, "/"+CTR_NAME_PREFIX+"-") {
|
||||
return "", "", fmt.Errorf("This is not a %s job: starting with %q", CTR_NAME_PREFIX, name)
|
||||
}
|
||||
|
||||
tmp := strings.Split(name, "-")
|
||||
if len(tmp) < 3 {
|
||||
return "", "", fmt.Errorf("This is not a %s job: %q didn't has at least 3 args", CTR_NAME_PREFIX, name)
|
||||
}
|
||||
|
||||
return tmp[1], strings.Join(tmp[2:], "-"), nil
|
||||
}
|
||||
|
||||
func FilterRunningContainers(jobtype string, ctrs map[string]string) (ret []string) {
|
||||
|
|
|
|||
Reference in a new issue