Documentation ¶
Index ¶
- type Api
- func (a *Api) AddTaskHandler(responseWriter http.ResponseWriter, request *http.Request)
- func (a *Api) GetDefaultRevisionsListHandler(responseWriter http.ResponseWriter, request *http.Request)
- func (a *Api) GetFunctionsListHandler(responseWriter http.ResponseWriter, request *http.Request)
- func (a *Api) GetTaskInfoHandler(responseWriter http.ResponseWriter, request *http.Request)
- func (a *Api) GetTasksListHandler(responseWriter http.ResponseWriter, request *http.Request)
- func (a *Api) InitRouter()
- func (a *Api) Start()
- func (a *Api) StopTaskHandler(responseWriter http.ResponseWriter, request *http.Request)
- func (a *Api) SwitchFunctionRevisionHandler(responseWriter http.ResponseWriter, request *http.Request)
- type ErrResponse
- type Worker
- func (worker *Worker) AddTask(t *task.Task)
- func (worker *Worker) Metrics()
- func (worker *Worker) PersistTask(t *task.Task)
- func (worker *Worker) RunTask() task.WasmRunnerResult
- func (worker *Worker) StartTask(t *task.Task) task.WasmRunnerResult
- func (worker *Worker) StopTask(t *task.Task) task.WasmRunnerResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api struct { Address string Port string Worker *Worker Router *chi.Mux Settings settings.Settings }
func (*Api) AddTaskHandler ¶
func (a *Api) AddTaskHandler(responseWriter http.ResponseWriter, request *http.Request)
func (*Api) GetDefaultRevisionsListHandler ¶
func (a *Api) GetDefaultRevisionsListHandler(responseWriter http.ResponseWriter, request *http.Request)
func (*Api) GetFunctionsListHandler ¶
func (a *Api) GetFunctionsListHandler(responseWriter http.ResponseWriter, request *http.Request)
func (*Api) GetTaskInfoHandler ¶
func (a *Api) GetTaskInfoHandler(responseWriter http.ResponseWriter, request *http.Request)
func (*Api) GetTasksListHandler ¶
func (a *Api) GetTasksListHandler(responseWriter http.ResponseWriter, request *http.Request)
func (*Api) InitRouter ¶
func (a *Api) InitRouter()
func (*Api) StopTaskHandler ¶
func (a *Api) StopTaskHandler(responseWriter http.ResponseWriter, request *http.Request)
func (*Api) SwitchFunctionRevisionHandler ¶
func (a *Api) SwitchFunctionRevisionHandler(responseWriter http.ResponseWriter, request *http.Request)
type ErrResponse ¶
type Worker ¶
type Worker struct { Queue queue.Queue TasksDb map[uuid.UUID]*task.Task TaskCount int // keep track of tasks a worker has at any given time Name string }
func (*Worker) PersistTask ¶
func (*Worker) RunTask ¶
func (worker *Worker) RunTask() task.WasmRunnerResult
- Pull a task of the queue - Convert it from an interface to a task.Task type // ??? 🤔 - Retrieve the task from the workers's Db - Check if the state transition is valid - If the task from the queue is in a state "Scheduled", call StartTask - If the task from the queue is in a state "Completed", call StopTask - Else, there is an invalid transition, so retuen an error
func (*Worker) StartTask ¶
func (worker *Worker) StartTask(t *task.Task) task.WasmRunnerResult
- Update the StartTime field on the task t. - Call the Run() method on the Worker struct. - Check if there were any errors in starting the task. - Save the updated task t to the worker’s Db field. - Return the result of the operation.
func (*Worker) StopTask ¶
func (worker *Worker) StopTask(t *task.Task) task.WasmRunnerResult
- Call the Stop() method on the Worker struct. - Check if there were any errors in stopping the task. - Update the FinishTime field on the task t. - Save the updated task t to the worker’s Db field. - Print an informative message and return the result of the operation.