mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
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:
31
api/models/runner_pool.go
Normal file
31
api/models/runner_pool.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user