Documentation
¶
Index ¶
- type AsyncSubscriber
- type Authorization
- type AuthorizationError
- type AuthorizerPayload
- type AuthorizerResponse
- type HTTPResponse
- type Router
- func (router *Router) Drain()
- func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (router *Router) StartWorkers()
- func (router *Router) WaitForAsyncSubscriber(method, path string, eventType eventpkg.TypeName) <-chan struct{}
- func (router *Router) WaitForEventType(space string, name eventpkg.TypeName) <-chan struct{}
- func (router *Router) WaitForFunction(space string, id function.ID) <-chan struct{}
- func (router *Router) WaitForSyncSubscriber(method, path string, eventType eventpkg.TypeName) <-chan struct{}
- type SyncSubscriber
- type Targeter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AsyncSubscriber ¶
AsyncSubscriber store info about space and function ID.
type Authorization ¶
type Authorization struct { PrincipalID string `json:"principalId"` Context map[string]string `json:"context"` }
Authorization is an object containing authorization information
type AuthorizationError ¶
type AuthorizationError struct {
Message string `json:"message"`
}
AuthorizationError represents error during authorization process
type AuthorizerPayload ¶
type AuthorizerPayload struct { Event event.Event `json:"event"` Request event.HTTPRequestData `json:"request"` }
AuthorizerPayload is a object that authorizer function is invoked with
type AuthorizerResponse ¶
type AuthorizerResponse struct { Authorization *Authorization `json:"authorization"` AuthorizationError *AuthorizationError `json:"error"` }
AuthorizerResponse is a expected result from authorizer function
type HTTPResponse ¶
type HTTPResponse struct { StatusCode int `json:"statusCode"` Headers map[string]string `json:"headers"` Body string `json:"body"` }
HTTPResponse is a response schema returned by subscribed function in case of HTTP event.
type Router ¶
Router calls a target function when an endpoint is hit, and handles pubsub message delivery.
func New ¶
func New(workersNumber uint, backlogLength uint, targetCache Targeter, plugins *plugin.Manager, log *zap.Logger) *Router
New instantiates a new Router
func (*Router) Drain ¶
func (router *Router) Drain()
Drain causes new requests to return 503, and blocks until the work queue is processed.
func (*Router) StartWorkers ¶
func (router *Router) StartWorkers()
StartWorkers spins up workerNumber goroutines for processing the event subscriptions.
func (*Router) WaitForAsyncSubscriber ¶
func (router *Router) WaitForAsyncSubscriber(method, path string, eventType eventpkg.TypeName) <-chan struct{}
WaitForAsyncSubscriber returns a chan that is closed when an event has a subscriber. Primarily for testing purposes.
func (*Router) WaitForEventType ¶
WaitForEventType returns a chan that is closed when a event type is created. Primarily for testing purposes.
func (*Router) WaitForFunction ¶
WaitForFunction returns a chan that is closed when a function is created. Primarily for testing purposes.
type SyncSubscriber ¶
SyncSubscriber store info about space, function ID and path params for sync subscriptions.
type Targeter ¶
type Targeter interface { Function(space string, id function.ID) *function.Function EventType(space string, name event.TypeName) *event.Type AsyncSubscribers(method, path string, eventType event.TypeName) []AsyncSubscriber SyncSubscriber(method, path string, eventType event.TypeName) *SyncSubscriber CORS(method, path string) *cors.CORS }
Targeter is an interface for retrieving cached configuration for driving performance-sensitive routing decisions.