Documentation
¶
Overview ¶
Package orch provides some orchestration functions.
Index ¶
- Variables
- func BuildStaticServers(servers []Server) (loadbalancer.Endpoints, error)
- func CompareServer(a, b Server) int
- func GetConfig(v any) any
- type Discovery
- type HttpMatcher
- type HttpMatchers
- type HttpRoute
- type Middleware
- type MiddlewareGroup
- type Middlewares
- type Retry
- type Server
- type StaticDiscovery
- type Upstream
Constants ¶
This section is empty.
Variables ¶
var ( // BuildStaticServer is used to customize the building of the static server, // which is used by the default discovery builder. // // Default: use http/endpoint.New to build it. BuildStaticServer func(server Server) (loadbalancer.Endpoint, error) // BuildDiscovery builds a discovery by the config. BuildDiscovery func(upid string, discovery Discovery) (loadbalancer.Discovery, error) )
var BuildHttpRouteResponser func(r HttpRoute) (core.Responser, error)
BuildHttpRouteResponser is used to build a responser of the http route.
If not set or return nil, use core.StdResponse instead.
Default: nil
Functions ¶
func BuildStaticServers ¶
BuildStaticServers builds a set of servers, which use BuildStaticServer to build each server.
func CompareServer ¶
CompareServer compares the two servers to sort a set of servers.
-1 if a < b 0 if a == b 1 if a > b
Types ¶
type Discovery ¶
type Discovery struct {
Static *StaticDiscovery `json:"static,omitempty" yaml:"static,omitempty"`
}
Discovery is the configuration of the upstream server discovery.
type HttpMatcher ¶
type HttpMatcher struct { // Exact(www.example.com) or Wildcard(*.example.com) // // OR Match Hosts []string `json:"hosts,omitempty" yaml:"hosts,omitempty"` // Exact OR Match Methods []string `json:"methods,omitempty" yaml:"methods,omitempty"` // Exact OR Match Paths []string `json:"paths,omitempty" yaml:"paths,omitempty"` PathPrefixes []string `json:"pathPrefixes,omitempty" yaml:"pathPrefixes,omitempty"` // Exact Match Headers map[string]string `json:"headers,omitempty" yaml:"headers,omitempty"` Queries map[string]string `json:"queries,omitempty" yaml:"queries,omitempty"` // IPv4CIDR or IPv6CIDR ClientIps []string `json:"clientIps,omitempty" yaml:"clientIps,omitempty"` ServerIps []string `json:"serverIps,omitempty" yaml:"serverIps,omitempty"` }
HttpRouteMatcher is the configuraiton of a route matcher.
type HttpRoute ¶
type HttpRoute struct { // Required Id string `json:"id" yaml:"id"` Upstream string `json:"upstream" yaml:"upstream"` Matchers HttpMatchers `json:"matchers" yaml:"matchers"` // Optional Protect bool `json:"protect,omitempty" yaml:"protect,omitempty"` Priority int `json:"priority,omitempty" yaml:"priority,omitempty"` RequestTimeout time.Duration `json:"requestTimeout,omitempty" yaml:"requestTimeout,omitempty"` ForwardTimeout time.Duration `json:"forwardTimeout,omitempty" yaml:"forwardTimeout,omitempty"` Middlewares Middlewares `json:"middlewares,omitempty" yaml:"middlewares,omitempty"` MiddlewareGroups []string `json:"middlewareGroups,omitempty" yaml:"middlewareGroups,omitempty"` // Addon information. Handler any `json:"handler,omitempty" yaml:"handler,omitempty"` Extra any `json:"extra,omitempty" yaml:"extra,omitempty"` }
HttpRoute is a http route configuration.
func DiffHttpRoutes ¶
DiffHttpRoutes compares the difference between new and old routes, and reutrns the added and deleted routes.
type Middleware ¶
type Middleware struct { Name string `json:"name,omitempty" yaml:"name,omitempty"` Conf any `json:"conf,omitempty" yaml:"conf,omitempty"` }
Middleware represents a middleware.
func (Middleware) HttpBuild ¶
func (m Middleware) HttpBuild() (middleware.Middleware, error)
HttpBuild builds the middleware based on http.
type MiddlewareGroup ¶
type MiddlewareGroup struct { // Optional, One of "tcp", "http" // // Default: http Type string `json:"type,omitempty" yaml:"type,omitempty"` // Required Name string `json:"name,omitempty" yaml:"name,omitempty"` Middlewares Middlewares `json:"middlewares,omitempty" yaml:"middlewares,omitempty"` }
MiddlewareGroup is the configuration of a middleare group.
func DiffMiddlewareGroups ¶
func DiffMiddlewareGroups(news, olds []MiddlewareGroup) (adds, dels []MiddlewareGroup)
DiffMiddlewareGroups compares the difference between new and old middleware groups, and returns the changed middleware groups.
func (MiddlewareGroup) Equal ¶
func (g MiddlewareGroup) Equal(other MiddlewareGroup) bool
Equal reports whether it is equal to other middlewares.
func (MiddlewareGroup) HttpBuild ¶
func (g MiddlewareGroup) HttpBuild() (*middleware.Group, error)
HttpBuild builds a middleware group based on http.
type Retry ¶
type Retry struct { Number int `json:"number,omitempty" yaml:"number,omitempty"` // <0: disabled Interval time.Duration `json:"interval,omitempty" yaml:"interval,omitempty"` // [0, +∞), Unit: ms }
Retry is a retry configuration.
type Server ¶
type Server struct { Host string `json:"host,omitempty" yaml:"host,omitempty"` Port uint16 `json:"port,omitempty" yaml:"port,omitempty"` Weight int `json:"weight,omitempty" yaml:"weight,omitempty"` }
Server is the configuraiton of an upstream server.
type StaticDiscovery ¶
type StaticDiscovery struct {
Servers []Server `json:"servers,omitempty" yaml:"servers,omitempty"`
}
StaticDiscovery is the configuration of the static upstream server discovery.
type Upstream ¶
type Upstream struct { // Required Id string `json:"id" yaml:"id"` Discovery Discovery `json:"discovery" yaml:"discovery"` // Optional, Default: 0 Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"` // Optional Policy string `json:"policy,omitempty" yaml:"policy,omitempty"` // Default: roundrobin Retry Retry `json:"retry,omitempty" yaml:"retry,omitempty"` // Optional Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"` // "http(default)", "https", "tcp", "tls" Host string `json:"host,omitempty" yaml:"host,omitempty"` // "$client"(default), "$server", "xxx" Path string `json:"path,omitempty" yaml:"path,omitempty"` }
Upstream is an upstream configuraiton.
func DiffUpstreams ¶
DiffUpstreams compares the difference between new and old upstreams, and reutrns the added and deleted upstreams.
NOTICE: adds also contains the existed but changed upstreams.
func (Upstream) ForwardPolicy ¶
ForwardPolicy returns the normalized forwarding policy.