plugins

package
v0.0.0-...-d8099e1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListPluginsStr

func ListPluginsStr() string

ListPluginsStr returns a string listing the registered plugins.

func LoadESPlugin

func LoadESPlugin(router *mux.Router, p ESPlugin, mw []middleware.Middleware) error

func LoadPlugin

func LoadPlugin(router *mux.Router, p Plugin) error

LoadPlugin is currently responsible for two things: firstly, it executes the plugin's initFunc to ensure it makes all the initializations before the plugin is functional and second, calling loadRoutes

func LoadRSPlugin

func LoadRSPlugin(router *mux.Router, p RSPlugin, mw []middleware.Middleware) error

func RegisterPlugin

func RegisterPlugin(p Plugin)

RegisterPlugin plugs in plugin. All plugins must have a name: preferably lowercase and one word. The name of the plugin must be unique. A plugin, however, may not define any routes, but still be useful, like a middleware.

Types

type ESPlugin

type ESPlugin interface {

	// mw takes a array of middleware to be intialized by ES Plugin
	InitFunc(mw []middleware.Middleware) error
	// contains filtered or unexported methods
}

ElasticSearchPlugin holds the plugin for ES

type Plugin

type Plugin interface {

	// InitFunc returns the plugin's setup function that is executed
	// before the plugin routes are loaded in the router.
	InitFunc() error

	// The plugin's elastic search middleware, if any.
	ESMiddleware() []middleware.Middleware

	// The plugin's reactive search middleware, if any.
	RSMiddleware() []middleware.Middleware
	// contains filtered or unexported methods
}

Plugin is a type that holds information about the plugin.

func ListPlugins

func ListPlugins() []Plugin

ListPlugins returns the list of plugins that are currently registered.

type PluginBy

type PluginBy func(p1, p2 Plugin) bool

By is the type of a "less" function that defines the ordering of Plugins.

func (PluginBy) PluginSort

func (by PluginBy) PluginSort(plugins []Plugin)

Sort is a method on the function type, By, that sorts the argument slice according to the function.

type RSPlugin

type RSPlugin interface {

	// mw takes a array of middleware to be intialized by ES Plugin
	InitFunc(mw []middleware.Middleware) error
	// contains filtered or unexported methods
}

ReactiveSearchPlugin holds the plugin for ReactiveSearch API

type RSUtil

type RSUtil struct {
}

RSUtil will contain uril methods for working with RS internally.

func RSUtilInstance

func RSUtilInstance() *RSUtil

RSUtilInstance will return single instance for RSUtil This should be the only access for the RSUtil Instance

func (*RSUtil) Address

func (rsUtil *RSUtil) Address() string

Address will return the RS Address for the current instance

func (*RSUtil) IsHttps

func (rsUtil *RSUtil) IsHttps() bool

IsHttps will return whether or not SSL is being used

func (*RSUtil) MasterCredentials

func (rsUtil *RSUtil) MasterCredentials() string

MasterCredentials will return the master credentials for the current instance in the username:password format.

func (*RSUtil) Port

func (rsUtil *RSUtil) Port() int

Port will return the RS Port for the current instance

func (*RSUtil) URL

func (rsUtil *RSUtil) URL(withCredentials bool) string

URL will expose the RS Url for the current instance.

type Route

type Route struct {
	// Name is the name of the route. In order to avoid conflicts in
	// the router, the name preferably should be a combination of both
	// http method type and the path. For example: "Get foobar" would
	// be an appropriate name for [GET foobar] endpoint.
	Name string

	// Methods represents an array of HTTP method type. It is preferable
	// to use values defined in net/http package to avoid typos.
	Methods []string

	// Path is the path that it expects to serve the requests on.
	// If the path contains any variables, then they must be declared
	// in accordance to the format define by the router to which
	// these routes are registered which in our case is: gorilla/mux.
	Path string

	// PathPrefix serves as a matcher for the URL path prefix.
	// This matches if the given template is a prefix of the full
	// URL path. See Route.Path() for details on the tpl argument.
	// Note that it does not treat slashes specially ("/foobar/"
	// will be matched by the prefix "/foo") so you may want to
	// use a trailing slash here.
	PathPrefix string

	// HandlerFunc is the handler function that is responsible for
	// responding the request made to this route.
	HandlerFunc http.HandlerFunc

	// Description about this route.
	Description string

	// Indicate whether the current route is a special pipeline router
	// or not
	IsPipeline bool
	// Matcher function to match for the route. This field might not be provided
	// in which case we need to ignore it
	Matcher mux.MatcherFunc
}

Route is a type that contains information about a route.

type RouteBy

type RouteBy func(r1, r2 Route) bool

By is the type of a "less" function that defines the ordering of routes.

func (RouteBy) RouteSort

func (by RouteBy) RouteSort(routes []Route)

Sort is a method on the function type, By, that sorts the argument slice according to the function.

type RouterHealthCheck

type RouterHealthCheck struct {
	// CheckDetails can contain maximum 3 elements.
	CheckedDetails []bool
	// contains filtered or unexported fields
}

RouterHealthCheck will handle checking the routers health.

func RouterHealthCheckInstance

func RouterHealthCheckInstance() *RouterHealthCheck

RouterHealthCheckInstance returns one instance and should be the only way health check is accessed

func (*RouterHealthCheck) Append

func (h *RouterHealthCheck) Append(status bool)

Append will append the newly added detail to the HealthCheck array making sure that it is of length 3.

func (*RouterHealthCheck) Check

func (h *RouterHealthCheck) Check()

Check will check the routers health by hitting the dry health check endpoint.

This function should be run with a cron job to be effective.

func (*RouterHealthCheck) SetAttrs

func (h *RouterHealthCheck) SetAttrs(port int, address string, isHttps bool)

SetAttrs sets the router related attributes in the HealthCheck struct.

type RouterSwapper

type RouterSwapper struct {
	Routes []Route
	// contains filtered or unexported fields
}

routerSwapper lets routers to be swapper

func RouterSwapperInstance

func RouterSwapperInstance() *RouterSwapper

RouterSwapperInstance returns one instance and should be the only way swapper is accessed Pipelines plugin deals with managing user defined pipelines.

func (*RouterSwapper) RestartServer

func (rs *RouterSwapper) RestartServer()

RestartServer shuts down the current server and starts it again

It is useful when a router swap happens

func (*RouterSwapper) Router

func (rs *RouterSwapper) Router() *mux.Router

Router exposes the router from the RouterSwapper instance

func (*RouterSwapper) SetRouterAttrs

func (rs *RouterSwapper) SetRouterAttrs(address string, port int, isHttps bool)

SetRouterAttrs sets the router attributes to the current instance of RouterSwapper

func (*RouterSwapper) StartServer

func (rs *RouterSwapper) StartServer()

StartServer starts the server by using the latest routerswapper interface router, creating a handler and listening

func (*RouterSwapper) Swap

func (rs *RouterSwapper) Swap(newRouter *mux.Router)

Swap swaps the passed router with the older one

Jump to

Keyboard shortcuts

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