mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
the mqs are storing a models.Task, which was not incorporating all the fields that are in a task.Config. I would very much like to merge these two things, but expect to do this in a future restructuring as both are used widely and not cordoned off properly (Config has a channel, stdin, stdout, stderr -- and isn't just a 'config', so to speak, as Task is). Since a task.Config is what is used to actually run a container, the result of the aforementioned deficiency was #193 where tasks are improperly configured and ran (namely, memory wrong). async tasks can still not be hot, they will be reverted to default format. would also like to fix this (also part of restructuring). I actually started doing this, hence the changes to those files (the surface area of the change is small and discourages improper future use, so I've left what I've done). this will: closes #193 closes #195 closes #154 removes many unused fields in models.Task, since we have not implemented retries. priority & delay are left, even though they are not used either, the main goal of this is to resolve #193 and both these fields are strongly plumbed into all the mqs, so punting on those two.
107 lines
2.9 KiB
Go
107 lines
2.9 KiB
Go
package models
|
|
|
|
import (
|
|
strfmt "github.com/go-openapi/strfmt"
|
|
)
|
|
|
|
const (
|
|
// TypeNone ...
|
|
TypeNone = ""
|
|
// TypeSync ...
|
|
TypeSync = "sync"
|
|
// TypeAsync ...
|
|
TypeAsync = "async"
|
|
)
|
|
|
|
const (
|
|
// FormatDefault ...
|
|
FormatDefault = "default"
|
|
// FormatHTTP ...
|
|
FormatHTTP = "http"
|
|
)
|
|
|
|
// TODO this should either be Task, or should be removed in favor of Task
|
|
type FnCall struct {
|
|
IDStatus
|
|
CompletedAt strfmt.DateTime `json:"completed_at,omitempty"`
|
|
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
|
|
StartedAt strfmt.DateTime `json:"started_at,omitempty"`
|
|
AppName string `json:"app_name,omitempty"`
|
|
Path string `json:"path"`
|
|
}
|
|
|
|
type FnCallLog struct {
|
|
CallID string `json:"call_id"`
|
|
Log string `json:"log"`
|
|
}
|
|
|
|
func (fnCall *FnCall) FromTask(task *Task) *FnCall {
|
|
return &FnCall{
|
|
CreatedAt: task.CreatedAt,
|
|
StartedAt: task.StartedAt,
|
|
CompletedAt: task.CompletedAt,
|
|
AppName: task.AppName,
|
|
Path: task.Path,
|
|
IDStatus: IDStatus{
|
|
ID: task.ID,
|
|
Status: task.Status,
|
|
},
|
|
}
|
|
}
|
|
|
|
// Task is a representation of a specific invocation of a route.
|
|
type Task struct {
|
|
IDStatus
|
|
|
|
// App this task belongs to.
|
|
AppName string `json:"app_name"`
|
|
|
|
// Path of the route that is responsible for this task
|
|
Path string `json:"path"`
|
|
|
|
// Name of Docker image to use.
|
|
Image string `json:"image"`
|
|
|
|
// Number of seconds to wait before queueing the task for consumption for the first time. Must be a positive integer. Tasks with a delay start in state "delayed" and transition to "running" after delay seconds.
|
|
Delay int32 `json:"delay,omitempty"`
|
|
|
|
// Payload for the task. This is only used by async tasks, to store their input.
|
|
Payload string `json:"payload,omitempty"`
|
|
|
|
// Priority of the task. Higher has more priority. 3 levels from 0-2. Tasks at same priority are processed in FIFO order.
|
|
Priority *int32 `json:"priority"`
|
|
|
|
// Maximum runtime in seconds.
|
|
Timeout int32 `json:"timeout,omitempty"`
|
|
|
|
// Hot function idle timeout in seconds before termination.
|
|
IdleTimeout int32 `json:"idle_timeout,omitempty"`
|
|
|
|
// Memory is the amount of RAM this task is allocated.
|
|
Memory uint64 `json:"memory,omitempty"`
|
|
|
|
// BaseEnv are the env vars for hot containers, not request specific.
|
|
BaseEnv map[string]string `json:"base_env,omitempty"`
|
|
|
|
// Env vars for the task. Comes from the ones set on the Route.
|
|
EnvVars map[string]string `json:"env_vars,omitempty"`
|
|
|
|
// Format is the format to pass input into the function.
|
|
// TODO plumb this in async land
|
|
// Format string `json:"format,omitempty"`
|
|
|
|
// Time when task completed, whether it was successul or failed. Always in UTC.
|
|
CompletedAt strfmt.DateTime `json:"completed_at,omitempty"`
|
|
|
|
// Time when task was submitted. Always in UTC.
|
|
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
|
|
|
|
// Time when task started execution. Always in UTC.
|
|
StartedAt strfmt.DateTime `json:"started_at,omitempty"`
|
|
}
|
|
|
|
type CallFilter struct {
|
|
Path string
|
|
AppName string
|
|
}
|