Adds extension points for runner pools in load-balanced mode (Patch 1/2) (#851)

* adds extension points for runner pools in load-balanced mode

* adds error to return values in RunnerPool and Runner interfaces
This commit is contained in:
Gerardo Viedma
2018-03-15 10:28:56 +00:00
committed by GitHub
parent 7df6863678
commit 6bc1220d8b
3 changed files with 41 additions and 0 deletions

31
api/models/runner_pool.go Normal file
View File

@@ -0,0 +1,31 @@
package models
import (
"context"
"io"
"net/http"
"time"
)
// RunnerPool is the abstraction for getting an ordered list of runners to try for a call
type RunnerPool interface {
Runners(call RunnerCall) ([]Runner, error)
Shutdown() error
}
// Runner is the interface to invoke the execution of a function call on a specific runner
type Runner interface {
TryExec(ctx context.Context, call RunnerCall) (bool, error)
Close() error
Address() string
}
// RunnerCall provides access to the necessary details of request in order for it to be
// processed by a RunnerPool
type RunnerCall interface {
SlotDeadline() time.Time
Request() *http.Request
ResponseWriter() io.Writer
StdErr() io.ReadWriteCloser
Model() *Call
}