router

package
v0.0.0-...-089673d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AsyncSubscriber

type AsyncSubscriber struct {
	Space      string
	FunctionID function.ID
}

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

type Router struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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) ServeHTTP

func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

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

func (router *Router) WaitForEventType(space string, name eventpkg.TypeName) <-chan struct{}

WaitForEventType returns a chan that is closed when a event type is created. Primarily for testing purposes.

func (*Router) WaitForFunction

func (router *Router) WaitForFunction(space string, id function.ID) <-chan struct{}

WaitForFunction returns a chan that is closed when a function is created. Primarily for testing purposes.

func (*Router) WaitForSyncSubscriber

func (router *Router) WaitForSyncSubscriber(method, path string, eventType eventpkg.TypeName) <-chan struct{}

WaitForSyncSubscriber returns a chan that is closed when an a sync subscriber is created. Primarily for testing purposes.

type SyncSubscriber

type SyncSubscriber struct {
	Space      string
	FunctionID function.ID
	Params     pathtree.Params
}

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.

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL