mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Moves out node pool manager behind an extension using runner pool abstraction (Part 2) (#862)
* Move out node-pool manager and replace it with RunnerPool extension * adds extension points for runner pools in load-balanced mode * adds error to return values in RunnerPool and Runner interfaces * Implements runner pool contract with context-aware shutdown * fixes issue with range * fixes tests to use runner abstraction * adds empty test file as a workaround for build requiring go source files in top-level package * removes flappy timeout test * update docs to reflect runner pool setup * refactors system tests to use runner abstraction * removes poolmanager * moves runner interfaces from models to api/runnerpool package * Adds a second runner to pool docs example * explicitly check for request spillover to second runner in test * moves runner pool package name for system tests * renames runner pool pointer variable for consistency * pass model json to runner * automatically cast to http.ResponseWriter in load-balanced call case * allow overriding of server RunnerPool via a programmatic ServerOption * fixes return type of ResponseWriter in test * move Placer interface to runnerpool package * moves hash-based placer out of open source project * removes siphash from Gopkg.lock
This commit is contained in:
39
api/runnerpool/runner_pool.go
Normal file
39
api/runnerpool/runner_pool.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package runnerpool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/fnproject/fn/api/models"
|
||||
)
|
||||
|
||||
// Placer implements a placement strategy for calls that are load-balanced
|
||||
// across runners in a pool
|
||||
type Placer interface {
|
||||
PlaceCall(rp RunnerPool, ctx context.Context, call RunnerCall) error
|
||||
}
|
||||
|
||||
// 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(context.Context) 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(ctx context.Context) 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() http.ResponseWriter
|
||||
StdErr() io.ReadWriteCloser
|
||||
Model() *models.Call
|
||||
}
|
||||
Reference in New Issue
Block a user