model

package
v0.5.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Down
	Down api.Status = 0
	// Up
	Up      api.Status = 1
	Unknown api.Status = 2
)
View Source
const (
	ApiTypeREST api.ApiType = 0 + iota // support for 1.0
	ApiTypeGRPC
	ApiTypeDUBBO
)
View Source
const (
	METHOD_UNSPECIFIED = 0 + iota // (DEFAULT)
	GET
	HEAD
	POST
	PUT
	DELETE
	CONNECT
	OPTIONS
	TRACE
)
View Source
const (
	REST_VALUE  = "REST"
	GRPC_VALUE  = "GRPC"
	DUBBO_VALUE = "DUBBO"
)

Variables

View Source
var (
	StatusName = map[int32]string{
		0: "Down",
		1: "Up",
		2: "Unknown",
	}

	StatusValue = map[string]int32{
		"Down":    0,
		"Up":      1,
		"Unknown": 2,
	}

	ApiTypeName = map[int32]string{
		0: REST_VALUE,
		1: GRPC_VALUE,
		2: DUBBO_VALUE,
	}

	ApiTypeValue = map[string]int32{
		REST_VALUE:  0,
		GRPC_VALUE:  1,
		DUBBO_VALUE: 2,
	}
)
View Source
var (
	// DiscoveryTypeName
	DiscoveryTypeName = map[DiscoveryType]string{
		Static:      "Static",
		StrictDNS:   "StrictDNS",
		LogicalDns:  "LogicalDns",
		EDS:         "EDS",
		OriginalDst: "OriginalDst",
	}

	// DiscoveryTypeValue
	DiscoveryTypeValue = map[string]DiscoveryType{
		"Static":      Static,
		"StrictDNS":   StrictDNS,
		"LogicalDns":  LogicalDns,
		"EDS":         EDS,
		"OriginalDst": OriginalDst,
	}
)
View Source
var (
	// ProtocolTypeName enum seq to protocol type name
	ProtocolTypeName = map[int32]string{
		0: "HTTP",
		1: "TCP",
		2: "UDP",
		3: "HTTPS",
		4: "GRPC",
		5: "HTTP2",
		6: "TRIPLE",
	}

	// ProtocolTypeValue protocol type name to enum seq
	ProtocolTypeValue = map[string]int32{
		"HTTP":   0,
		"TCP":    1,
		"UDP":    2,
		"HTTPS":  3,
		"GRPC":   4,
		"HTTP2":  5,
		"TRIPLE": 6,
	}
)
View Source
var (
	MatcherTypeName = map[int32]string{
		0: "Exact",
		1: "Prefix",
		2: "Suffix",
		3: "Regex",
	}

	MatcherTypeValue = map[string]int32{
		"Exact":  0,
		"Prefix": 1,
		"Suffix": 2,
		"Regex":  3,
	}
)
View Source
var LbPolicyTypeValue = map[string]LbPolicyType{
	"Rand":              LoadBalancerRand,
	"RoundRobin":        LoadBalancerRoundRobin,
	"ConsistentHashing": LoadBalanceConsistentHashing,
}
View Source
var RequestMethodName = map[int32]string{
	0: "METHOD_UNSPECIFIED",
	1: "GET",
	2: "HEAD",
	3: "POST",
	4: "PUT",
	5: "DELETE",
	6: "CONNECT",
	7: "OPTIONS",
	8: "TRACE",
}
View Source
var RequestMethodValue = map[string]int32{
	"METHOD_UNSPECIFIED": 0,
	"GET":                1,
	"HEAD":               2,
	"POST":               3,
	"PUT":                4,
	"DELETE":             5,
	"CONNECT":            6,
	"OPTIONS":            7,
	"TRACE":              8,
}

Functions

This section is empty.

Types

type APIMetaConfig

type APIMetaConfig struct {
	Address       string `yaml:"address" json:"address,omitempty"`
	APIConfigPath string `default:"/pixiu/config/api" yaml:"api_config_path" json:"api_config_path,omitempty" mapstructure:"api_config_path"`
}

APIMetaConfig how to find api config, file or etcd etc.

type Adapter

type Adapter struct {
	ID      string                 `yaml:"id" json:"id"`
	Name    string                 `yaml:"name" json:"name"` // Name the adapter unique name
	Enabled string                 `yaml:"enabled" json:"enabled" default:"true"`
	Config  map[string]interface{} `yaml:"config" json:"config" mapstructure:"config"` // Config adapter config
}

Adapter the adapter plugin for manage cluster or router

type Address

type Address struct {
	SocketAddress SocketAddress `yaml:"socket_address" json:"socket_address" mapstructure:"socket_address"`
	Name          string        `yaml:"name" json:"name" mapstructure:"name"`
}

Address the address

type ApiConfigSource

type ApiConfigSource struct {
	APIType        api.ApiType   `yaml:"omitempty" json:"omitempty"`
	APITypeStr     string        `yaml:"api_type" json:"api_type" mapstructure:"api_type"`
	ClusterName    []string      `yaml:"cluster_name" json:"cluster_name" mapstructure:"cluster_name"`
	RefreshDelay   string        `yaml:"refresh_delay" json:"refresh_delay" mapstructure:"refresh_delay"`
	RequestTimeout string        `yaml:"request_timeout" json:"request_timeout" mapstructure:"request_timeout"`
	GrpcServices   []GrpcService `yaml:"grpc_services" json:"grpc_services" mapstructure:"grpc_services"`
}

ApiConfigSource config the api info. compatible with envoy xDS API

	{
 "api_type": "...",
 "transport_api_version": "...",
 "cluster_names": [],
 "grpc_services": [],
 "refresh_delay": "{...}",
 "request_timeout": "{...}",
 "rate_limit_settings": "{...}",
 "set_node_on_first_message_only": "..."
	}

type Bootstrap

type Bootstrap struct {
	StaticResources  StaticResources   `yaml:"static_resources" json:"static_resources" mapstructure:"static_resources"`
	DynamicResources *DynamicResources `yaml:"dynamic_resources" json:"dynamic_resources" mapstructure:"dynamic_resources"`
	Metric           Metric            `yaml:"metric" json:"metric" mapstructure:"metric"`
	Node             *Node             `yaml:"node" json:"node" mapstructure:"node"`
	Trace            *TracerConfig     `yaml:"tracing" json:"tracing" mapstructure:"tracing"`
}

Bootstrap the door

func (*Bootstrap) ExistCluster

func (bs *Bootstrap) ExistCluster(name string) bool

ExistCluster

func (*Bootstrap) GetListeners

func (bs *Bootstrap) GetListeners() []*Listener

GetListeners

func (*Bootstrap) GetPprof

func (bs *Bootstrap) GetPprof() PprofConf

GetPprof

func (*Bootstrap) GetStaticListeners

func (bs *Bootstrap) GetStaticListeners() []*Listener

type ClusterConfig

type ClusterConfig struct {
	Name                 string              `yaml:"name" json:"name"` // Name the cluster unique name
	TypeStr              string              `yaml:"type" json:"type"` // Type the cluster discovery type string value
	Type                 DiscoveryType       `yaml:"-" json:"-"`       // Type the cluster discovery type
	EdsClusterConfig     EdsClusterConfig    `yaml:"eds_cluster_config" json:"eds_cluster_config" mapstructure:"eds_cluster_config"`
	LbStr                LbPolicyType        `yaml:"lb_policy" json:"lb_policy"` // Lb the cluster select node used loadBalance policy
	HealthChecks         []HealthCheckConfig `yaml:"health_checks" json:"health_checks"`
	Endpoints            []*Endpoint         `yaml:"endpoints" json:"endpoints"`
	PrePickEndpointIndex int
}

ClusterConfig a single upstream cluster

func (*ClusterConfig) GetEndpoint

func (c *ClusterConfig) GetEndpoint(mustHealth bool) []*Endpoint

type ConfigSource

type ConfigSource struct {
	Path            string          `yaml:"path" json:"path" mapstructure:"path"`
	ApiConfigSource ApiConfigSource `yaml:"api_config_source" json:"api_config_source" mapstructure:"api_config_source"`
}

ConfigSource todo remove un-used

type CustomHealthCheck

type CustomHealthCheck struct {
	HealthCheckConfig
	Name   string
	Config interface{}
}

CustomHealthCheck

type DiscoveryType

type DiscoveryType int32

DiscoveryType

const (
	Static DiscoveryType = iota
	StrictDNS
	LogicalDns
	EDS
	OriginalDst
)

type DubboFilter

type DubboFilter struct {
	Name   string                 `yaml:"name" json:"name" mapstructure:"name"`
	Config map[string]interface{} `yaml:"config" json:"config" mapstructure:"config"`
}

HTTPFilter http filter

type DubboProxyConnectionManagerConfig

type DubboProxyConnectionManagerConfig struct {
	RouteConfig  RouteConfiguration `yaml:"route_config" json:"route_config" mapstructure:"route_config"`
	DubboFilters []*DubboFilter     `yaml:"dubbo_filters" json:"dubbo_filters" mapstructure:"dubbo_filters"`
}

DubboProxyConnectionManagerConfig

type DynamicResources

type DynamicResources struct {
	LdsConfig *ApiConfigSource `yaml:"lds_config" json:"lds_config" mapstructure:"lds_config"`
	CdsConfig *ApiConfigSource `yaml:"cds_config" json:"cds_config" mapstructure:"cds_config"`
	AdsConfig *ApiConfigSource `yaml:"ads_config" json:"ads_config" mapstructure:"ads_config"`
}

DynamicResources config the dynamic resource source

	"lds_config": "{...}", # config lister load source
	"cds_config": "{...}", # config cluster load source
	"ads_config": "{...}"
 "ada_config": "{...}" # config adaptor load source

type EdsClusterConfig

type EdsClusterConfig struct {
	EdsConfig   ConfigSource `yaml:"eds_config" json:"eds_config" mapstructure:"eds_config"`
	ServiceName string       `yaml:"service_name" json:"service_name" mapstructure:"service_name"`
}

EdsClusterConfig todo remove un-used EdsClusterConfig

type Endpoint

type Endpoint struct {
	ID        string            `yaml:"ID" json:"ID"`                                                       // ID indicate one endpoint
	Name      string            `yaml:"name" json:"name"`                                                   // Name the cluster unique name
	Address   SocketAddress     `yaml:"socket_address" json:"socket_address" mapstructure:"socket_address"` // Address socket address
	Metadata  map[string]string `yaml:"meta" json:"meta"`                                                   // Metadata extra info such as label or other meta data
	UnHealthy bool
}

Endpoint

type FilterChain

type FilterChain struct {
	Filters []NetworkFilter `yaml:"filters" json:"filters" mapstructure:"filters"`
}

FilterChain filter chain

type FilterChainMatch

type FilterChainMatch struct {
	Domains []string `yaml:"domains" json:"domains" mapstructure:"domains"`
}

FilterChainMatch

type GRPCConnectionManagerConfig

type GRPCConnectionManagerConfig struct {
	RouteConfig RouteConfiguration `yaml:"route_config" json:"route_config" mapstructure:"route_config"`
}

GRPCConnectionManagerConfig

type GrpcHealthCheck

type GrpcHealthCheck struct {
	HealthCheckConfig
	ServiceName string
	Authority   string
}

GrpcHealthCheck

type GrpcService

type GrpcService struct {
	Timeout         string        `yaml:"timeout" json:"timeout" mapstructure:"timeout"`
	InitialMetadata []HeaderValue `yaml:"initial_metadata" json:"initial_metadata" mapstructure:"initial_metadata"`
}

GrpcService define grpc service context

type HTTPFilter

type HTTPFilter struct {
	Name   string                 `yaml:"name" json:"name" mapstructure:"name"`
	Config map[string]interface{} `yaml:"config" json:"config" mapstructure:"config"`
}

HTTPFilter http filter

type HeaderMatcher

type HeaderMatcher struct {
	Name   string   `yaml:"name" json:"name" mapstructure:"name"`
	Values []string `yaml:"values" json:"values" mapstructure:"values"`
	Regex  bool     `yaml:"regex" json:"regex" mapstructure:"regex"`
	// contains filtered or unexported fields
}

Name header key, Value header value, Regex header value is regex

type HeaderValue

type HeaderValue struct {
	Key   string `yaml:"key" json:"key" mapstructure:"key"`
	Value string `yaml:"value" json:"value" mapstructure:"value"`
}

HeaderValue

type HeaderValueOption

type HeaderValueOption struct {
	Header []HeaderValue `yaml:"header" json:"header" mapstructure:"header"`
	Append []bool        `yaml:"append" json:"append" mapstructure:"append"`
}

HeaderValueOption

type HealthCheckConfig

type HealthCheckConfig struct {
	Protocol            string                 `json:"protocol,omitempty"`
	TimeoutConfig       string                 `json:"timeout,omitempty"`
	IntervalConfig      string                 `json:"interval,omitempty"`
	InitialDelaySeconds string                 `json:"initial_delay_seconds,omitempty"`
	HealthyThreshold    uint32                 `json:"healthy_threshold,omitempty"`
	UnhealthyThreshold  uint32                 `json:"unhealthy_threshold,omitempty"`
	ServiceName         string                 `json:"service_name,omitempty"`
	SessionConfig       map[string]interface{} `json:"check_config,omitempty"`
	CommonCallbacks     []string               `json:"common_callbacks,omitempty"`
}

HealthCheck

type Http

type Http struct {
	Name   string      `yaml:"name"`
	Config interface{} `yaml:"config"`
}

Tracing

type HttpConfig

type HttpConfig struct {
	IdleTimeoutStr  string `yaml:"idle_timeout" json:"idle_timeout" mapstructure:"idle_timeout"`
	ReadTimeoutStr  string `json:"read_timeout,omitempty" yaml:"read_timeout,omitempty" mapstructure:"read_timeout"`
	WriteTimeoutStr string `json:"write_timeout,omitempty" yaml:"write_timeout,omitempty" mapstructure:"write_timeout"`
	MaxHeaderBytes  int    `json:"max_header_bytes,omitempty" yaml:"max_header_bytes,omitempty" mapstructure:"max_header_bytes"`
}

HttpConfig the http config

func MapInStruct

func MapInStruct(cfg interface{}) *HttpConfig

type HttpConnectionManagerConfig

type HttpConnectionManagerConfig struct {
	RouteConfig       RouteConfiguration `yaml:"route_config" json:"route_config" mapstructure:"route_config"`
	HTTPFilters       []*HTTPFilter      `yaml:"http_filters" json:"http_filters" mapstructure:"http_filters"`
	ServerName        string             `yaml:"server_name" json:"server_name" mapstructure:"server_name"`
	IdleTimeoutStr    string             `yaml:"idle_timeout" json:"idle_timeout" mapstructure:"idle_timeout"`
	GenerateRequestID bool               `yaml:"generate_request_id" json:"generate_request_id" mapstructure:"generate_request_id"`
}

HttpConnectionManagerConfig

type HttpHealthCheck

type HttpHealthCheck struct {
	HealthCheckConfig
	Host             string
	Path             string
	UseHttp2         bool
	ExpectedStatuses int64
}

HttpHealthCheck

type LbPolicyType

type LbPolicyType string

LbPolicyType the load balance policy enum

const (
	LoadBalancerRand             LbPolicyType = "Rand"
	LoadBalancerRoundRobin       LbPolicyType = "RoundRobin"
	LoadBalanceConsistentHashing LbPolicyType = "ConsistentHashing"
)

type Listener

type Listener struct {
	Name        string       `yaml:"name" json:"name" mapstructure:"name"`
	Address     Address      `yaml:"address" json:"address" mapstructure:"address"`
	ProtocolStr string       `default:"http" yaml:"protocol_type" json:"protocol_type" mapstructure:"protocol_type"`
	Protocol    ProtocolType `default:"http" yaml:"omitempty" json:"omitempty"`
	FilterChain FilterChain  `yaml:"filter_chains" json:"filter_chains" mapstructure:"filter_chains"`
	Config      interface{}  `yaml:"config" json:"config" mapstructure:"config"`
}

Listener is a server, listener a port

type MatcherType

type MatcherType int32

MatcherType matcher type

const (
	Exact MatcherType = 0 + iota
	Prefix
	Suffix
	Regex
)

type Metadata

type Metadata struct {
	Info map[string]MetadataValue
}

type MetadataValue

type MetadataValue interface{}

type Metric

type Metric struct {
	Enable         bool `yaml:"enable" json:"enable"`
	PrometheusPort int  `yaml:"prometheus_port" json:"prometheus_port"`
}

Metirc config for otel metric.

type NetworkFilter

type NetworkFilter struct {
	Name   string                 `yaml:"name" json:"name" mapstructure:"name"`       // Name filter name unique
	Config map[string]interface{} `yaml:"config" json:"config" mapstructure:"config"` // Config filter config
}

NetworkFilter core struct, filter is extend by user

type Node

type Node struct {
	Cluster string `yaml:"cluster" json:"cluster" mapstructure:"cluster"`
	Id      string `yaml:"id" json:"id" mapstructure:"id"`
}

Node node info for dynamic identifier

type PprofConf

type PprofConf struct {
	Enable  bool    `yaml:"enable" json:"enable" mapstructure:"enable" default:"false"`
	Address Address `yaml:"address" json:"address" mapstructure:"address"`
}

type ProtocolType

type ProtocolType int32

ProtocolType protocol type enum

const (
	ProtocolTypeHTTP ProtocolType = 0 + iota // support for 1.0
	ProtocolTypeTCP
	ProtocolTypeUDP
	ProtocolTypeHTTPS
	ProtocolTypeGRPC
	ProtocolTypeHTTP2
	ProtocolTypeTriple
)

type Registry

type Registry struct {
	Protocol  string `default:"zookeeper" yaml:"protocol" json:"protocol"`
	Timeout   string `yaml:"timeout" json:"timeout"`
	Address   string `yaml:"address" json:"address"`
	Username  string `yaml:"username" json:"username"`
	Password  string `yaml:"password" json:"password"`
	Group     string `default:"DEFAULT_GROUP"  yaml:"group" json:"group"`
	Namespace string `yaml:"namespace" json:"namespace"`
}

Registry remote registry where dubbo apis are registered. Here comes a problem, dubbo protocol proxy does not use the same registry as pixiu, so any modification to the config, should apply to both `pkg/client/dubbo/dubbo.go` and `pkg\adapter\dubboregistry\registry`

type RemoteConfig

type RemoteConfig struct {
	Protocol string `yaml:"protocol" json:"protocol" default:"zookeeper"`
	Timeout  string `yaml:"timeout" json:"timeout" default:"10s"`
	Address  string `yaml:"address" json:"address"`
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
	Group    string `yaml:"group" json:"group"`
	Root     string `yaml:"root" json:"root" default:"/services"`
}

RemoteConfig remote server info which offer server discovery or k/v or distribution function

type RequestMethod

type RequestMethod int32

type RouteAction

type RouteAction struct {
	Cluster                     string `yaml:"cluster" json:"cluster" mapstructure:"cluster"`
	ClusterNotFoundResponseCode int    `yaml:"cluster_not_found_response_code" json:"cluster_not_found_response_code" mapstructure:"cluster_not_found_response_code"`
}

RouteAction match route should do

type RouteConfiguration

type RouteConfiguration struct {
	RouteTrie trie.Trie `yaml:"-" json:"-" mapstructure:"-"`
	Routes    []*Router `yaml:"routes" json:"routes" mapstructure:"routes"`
	Dynamic   bool      `yaml:"dynamic" json:"dynamic" mapstructure:"dynamic"`
}

RouteConfiguration

func (*RouteConfiguration) Route

func (rc *RouteConfiguration) Route(req *stdHttp.Request) (*RouteAction, error)

func (*RouteConfiguration) RouteByPathAndMethod

func (rc *RouteConfiguration) RouteByPathAndMethod(path, method string) (*RouteAction, error)

type Router

type Router struct {
	ID    string      `yaml:"id" json:"id" mapstructure:"id"`
	Match RouterMatch `yaml:"match" json:"match" mapstructure:"match"`
	Route RouteAction `yaml:"route" json:"route" mapstructure:"route"`
}

Router struct

type RouterMatch

type RouterMatch struct {
	Prefix string `yaml:"prefix" json:"prefix" mapstructure:"prefix"`
	Path   string `yaml:"path" json:"path" mapstructure:"path"`
	// Regex   string          `yaml:"regex" json:"regex" mapstructure:"regex"` TODO: next version
	Methods []string `yaml:"methods" json:"methods" mapstructure:"methods"`
}

RouterMatch

func NewRouterMatchPrefix

func NewRouterMatchPrefix(name string) RouterMatch

type Sampler

type Sampler struct {
	Type  string  `yaml:"type" json:"type" mapstructure:"type"`
	Param float64 `yaml:"param" json:"param" mapstructure:"param"`
}

Sampler policy

type ShutdownConfig

type ShutdownConfig struct {
	Timeout      string `default:"60s" yaml:"timeout" json:"timeout,omitempty"`
	StepTimeout  string `default:"10s" yaml:"step_timeout" json:"step_timeout,omitempty"`
	RejectPolicy string `default:"immediacy" yaml:"reject_policy" json:"reject_policy,omitempty"`
}

ShutdownConfig how to shutdown server.

type SocketAddress

type SocketAddress struct {
	Address      string   `default:"0.0.0.0" yaml:"address" json:"address" mapstructure:"address"`
	Port         int      `default:"8881" yaml:"port" json:"port" mapstructure:"port"`
	ResolverName string   `yaml:"resolver_name" json:"resolver_name" mapstructure:"resolver_name"`
	Domains      []string `yaml:"domains" json:"domains" mapstructure:"domains"`
	CertsDir     string   `yaml:"certs_dir" json:"certs_dir" mapstructure:"certs_dir"`
}

SocketAddress specify either a logical or physical address and port, which are used to tell server where to bind/listen, connect to upstream and find management servers

func (SocketAddress) GetAddress

func (a SocketAddress) GetAddress() string

type StaticResources

type StaticResources struct {
	Listeners      []*Listener      `yaml:"listeners" json:"listeners" mapstructure:"listeners"`
	Clusters       []*ClusterConfig `yaml:"clusters" json:"clusters" mapstructure:"clusters"`
	Adapters       []*Adapter       `yaml:"adapters" json:"adapters" mapstructure:"adapters"`
	ShutdownConfig *ShutdownConfig  `yaml:"shutdown_config" json:"shutdown_config" mapstructure:"shutdown_config"`
	PprofConf      PprofConf        `yaml:"pprofConf" json:"pprofConf" mapstructure:"pprofConf"`
}

StaticResources

type StringMatcher

type StringMatcher struct {
	Matcher MatcherType
}

StringMatcher matcher string

func (*StringMatcher) Match

func (sm *StringMatcher) Match() (bool, error)

Match

type TimeoutConfig

type TimeoutConfig struct {
	ConnectTimeoutStr string `default:"5s" yaml:"connect_timeout" json:"connect_timeout,omitempty"` // ConnectTimeout timeout for connect to cluster node
	RequestTimeoutStr string `default:"10s" yaml:"request_timeout" json:"request_timeout,omitempty"`
}

TimeoutConfig the config of ConnectTimeout and RequestTimeout

type TracerConfig

type TracerConfig struct {
	Name        string                 `yaml:"name" json:"name" mapstructure:"name"`
	ServiceName string                 `yaml:"serviceName" json:"serviceName" mapstructure:"serviceName"`
	Sampler     Sampler                `yaml:"sampler" json:"sampler" mapstructure:"sampler"`
	Config      map[string]interface{} `yaml:"config" json:"config" mapstructure:"config"`
}

TracerConfig inclueds detail information about the exporter

type Tracing

type Tracing struct {
	Http Http   `yaml:"http" json:"http,omitempty"`
	URL  string `yaml:"url" json:"url,omitempty"`
	Type string `yaml:"type" json:"type,omitempty"`
}

Tracing

Jump to

Keyboard shortcuts

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