Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Hook = &v1alpha1.WebhookContext{
Endpoint: "/fake",
Port: "12000",
URL: "test-url",
}
View Source
var ( // Mutex synchronizes ActiveServerHandlers Lock sync.Mutex )
Functions ¶
func ManageRoute ¶
func ManageRoute(ctx context.Context, router Router, controller *Controller, dispatch func([]byte) error) error
ManagerRoute manages the lifecycle of a route
func ProcessRouteStatus ¶
func ProcessRouteStatus(ctrl *Controller)
ProcessRouteStatus processes route status as active and inactive.
func ValidateWebhookContext ¶
func ValidateWebhookContext(context *v1alpha1.WebhookContext) error
ValidateWebhookContext validates a webhook context
Types ¶
type Controller ¶
type Controller struct { // ActiveServerHandlers keeps track of currently active mux/router for the http servers. ActiveServerHandlers map[string]*mux.Router // AllRoutes keep track of routes that are already registered with server and their status active or inactive AllRoutes map[string]*mux.Route // RouteActivateChan handles activation of routes RouteActivateChan chan Router // RouteDeactivateChan handles inactivation of routes RouteDeactivateChan chan Router }
Controller controls the active servers and endpoints
type FakeHttpWriter ¶
func (*FakeHttpWriter) Header ¶
func (f *FakeHttpWriter) Header() http.Header
func (*FakeHttpWriter) WriteHeader ¶
func (f *FakeHttpWriter) WriteHeader(status int)
type FakeRouter ¶
type FakeRouter struct {
// contains filtered or unexported fields
}
func (*FakeRouter) GetRoute ¶
func (f *FakeRouter) GetRoute() *Route
func (*FakeRouter) HandleRoute ¶
func (f *FakeRouter) HandleRoute(writer http.ResponseWriter, request *http.Request)
func (*FakeRouter) PostActivate ¶
func (f *FakeRouter) PostActivate() error
func (*FakeRouter) PostInactivate ¶
func (f *FakeRouter) PostInactivate() error
type Route ¶
type Route struct { // WebhookContext refers to the webhook context Context *v1alpha1.WebhookContext // Logger to log stuff Logger *zap.SugaredLogger // StartCh controls the StartCh chan struct{} // EventSourceName refers to event source name EventSourceName string // EventName refers to event name EventName string // active determines whether the route is active and ready to process incoming requets // or it is an inactive route Active bool // data channel to receive data on this endpoint DataCh chan []byte // Stop channel to signal the end of the event source. StopChan chan struct{} }
Route contains general information about a route
func GetFakeRoute ¶
func GetFakeRoute() *Route
func NewRoute ¶
func NewRoute(hookContext *v1alpha1.WebhookContext, logger *zap.SugaredLogger, eventSourceName, eventName string) *Route
NewRoute returns a vanilla route
type Router ¶
type Router interface { // GetRoute returns the route GetRoute() *Route // HandleRoute processes the incoming requests on the route HandleRoute(writer http.ResponseWriter, request *http.Request) // PostActivate captures the operations if any after route being activated and ready to process requests. PostActivate() error // PostInactivate captures cleanup operations if any after route is inactivated PostInactivate() error }
Router is an interface to manage the route
Click to show internal directories.
Click to hide internal directories.