model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ApiTypeName = map[int32]string{
	0: REST_VALUE,
	1: GRPC_VALUE,
	2: DUBBO_VALUE,
}
View Source
var ApiTypeValue = map[string]int32{
	REST_VALUE:  0,
	GRPC_VALUE:  1,
	DUBBO_VALUE: 2,
}
View Source
var DiscoveryTypeName = map[int32]string{
	0: "Static",
	1: "StrictDNS",
	2: "LogicalDns",
	3: "EDS",
	4: "OriginalDst",
}

DiscoveryTypeName

View Source
var DiscoveryTypeValue = map[string]int32{
	"Static":      0,
	"StrictDNS":   1,
	"LogicalDns":  2,
	"EDS":         3,
	"OriginalDst": 4,
}

DiscoveryTypeValue

View Source
var LbPolicyName = map[int32]string{
	0: "RoundRobin",
	1: "IPHash",
	2: "WightRobin",
	3: "Rand",
}

LbPolicyName key int32 for LbPolicy, value string

View Source
var LbPolicyValue = map[string]int32{
	"RoundRobin": 0,
	"IPHash":     1,
	"WightRobin": 2,
	"Rand":       3,
}

LbPolicyValue key string, value int32 for LbPolicy

View Source
var LimitTypeName = map[int32]string{
	0: "IP",
	1: "App",
}

LimitTypeName key int32 for LimitType, value string

View Source
var LimitTypeValue = map[string]int32{
	"IP":  0,
	"App": 1,
}

LimitTypeValue key string, value int32 for LimitType

View Source
var MatcherTypeName = map[int32]string{
	0: "Exact",
	1: "Prefix",
	2: "Suffix",
	3: "Regex",
}
View Source
var MatcherTypeValue = map[string]int32{
	"Exact":  0,
	"Prefix": 1,
	"Suffix": 2,
	"Regex":  3,
}
View Source
var ProtocolTypeName = map[int32]string{
	0: "HTTP",
	1: "TCP",
	2: "UDP",
}

ProtocolTypeName

View Source
var ProtocolTypeValue = map[string]int32{
	"HTTP": 0,
	"TCP":  1,
	"UDP":  2,
}

ProtocolTypeValue

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,
}
View Source
var StatusName = map[int32]string{
	0: "Down",
	1: "Up",
	2: "Unknown",
}
View Source
var StatusValue = map[string]int32{
	"Down":    0,
	"Up":      1,
	"Unknown": 2,
}
View Source
var StrategyTypeName = map[int32]string{
	0: "Whitelist",
	1: "Blacklist",
}

StrategyTypeName key int32 for StrategyType, value string

View Source
var StrategyTypeValue = map[string]int32{
	"Whitelist": 0,
	"Blacklist": 1,
}

StrategyTypeValue key string, value int32 for StrategyType

Functions

func WriteToFile

func WriteToFile(accessLogMsg string, filePath string) error

write message to access log file

Types

type APIMetaConfig added in v0.2.0

type APIMetaConfig struct {
	Address       string `yaml:"address" json:"address,omitempty"`
	APIConfigPath string `default:"/proxy/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 AccessLogConfig

type AccessLogConfig struct {
	Enable     bool   `yaml:"enable" json:"enable" mapstructure:"enable" default:"true"`
	OutPutPath string `yaml:"outPutPath" json:"outPutPath" mapstructure:"outPutPath" default:"console"`
}

access log config, enable default value true, outputpath default value console access log will out put into console

type AccessLogData

type AccessLogData struct {
	AccessLogMsg    string
	AccessLogConfig AccessLogConfig
}

access log data

type AccessLogWriter

type AccessLogWriter struct {
	AccessLogDataChan chan AccessLogData
}

access log chan

func (*AccessLogWriter) Write

func (alw *AccessLogWriter) Write()

write log into out put path

func (*AccessLogWriter) Writer

func (alw *AccessLogWriter) Writer(accessLogData AccessLogData)

writer msg into chan

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"`
}

ApiConfigSource

type AuthorityConfiguration

type AuthorityConfiguration struct {
	Rules []AuthorityRule `yaml:"authority_rules" json:"authority_rules"` //Rules the authority rule list
}

AuthorityConfiguration blacklist/whitelist config

type AuthorityRule

type AuthorityRule struct {
	Strategy StrategyType `yaml:"strategy" json:"strategy"` //Strategy the authority rule strategy
	Limit    LimitType    `yaml:"limit" json:"limit"`       //Limit the authority rule limit
	Items    []string     `yaml:"items" json:"items"`       //Items the authority rule items
}

AuthorityRule blacklist/whitelist rule

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"`
	Tracing          Tracing          `yaml:"tracing" json:"tracing" mapstructure:"tracing"`
}

Bootstrap the door

func (*Bootstrap) ExistCluster

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

ExistCluster

func (*Bootstrap) GetAPIMetaConfig added in v0.2.0

func (bs *Bootstrap) GetAPIMetaConfig() *APIMetaConfig

GetAPIMetaConfig get api meta config from bootstrap

func (*Bootstrap) GetListeners

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

GetListeners

func (*Bootstrap) GetPprof

func (bs *Bootstrap) GetPprof() PprofConf

GetPprof

type Cluster

type Cluster 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:",omitempty" json:",omitempty"` // Type the cluster discovery type
	EdsClusterConfig  EdsClusterConfig    `yaml:"eds_cluster_config" json:"eds_cluster_config"`
	LbStr             string              `yaml:"lb_policy" json:"lb_policy"`             // Lb the cluster select node used loadBalance policy
	Lb                LbPolicy            `yaml:",omitempty" json:",omitempty"`           // Lb the cluster select node used loadBalance policy
	ConnectTimeoutStr string              `yaml:"connect_timeout" json:"connect_timeout"` // ConnectTimeout timeout for connect to cluster node
	HealthChecks      []HealthCheck       `yaml:"health_checks" json:"health_checks"`
	Hosts             []Address           `yaml:"hosts" json:"hosts"` // Hosts whe discovery type is Static, StrictDNS or LogicalDns,this need config
	RequestTimeoutStr string              `yaml:"request_timeout" json:"request_timeout"`
	Registries        map[string]Registry `yaml:"registries" json:"registries"`
}

Cluster a single upstream cluster

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

type CorsPolicy

type CorsPolicy struct {
	AllowOrigin      []string `yaml:"allow_origin" json:"allow_origin" mapstructure:"allow_origin"`
	AllowMethods     string   // access-control-allow-methods
	AllowHeaders     string   // access-control-allow-headers
	ExposeHeaders    string   // access-control-expose-headers
	MaxAge           string   // access-control-max-age
	AllowCredentials bool
	Enabled          bool `yaml:"enabled" json:"enabled" mapstructure:"enabled"`
}

CorsPolicy

type CustomHealthCheck

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

CustomHealthCheck

type DiscoveryType

type DiscoveryType int32

DiscoveryType

const (
	Static DiscoveryType = 0 + iota
	StrictDNS
	LogicalDns
	EDS
	OriginalDst
)

type DynamicResources

type DynamicResources struct {
}

DynamicResources TODO

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

type Filter

type Filter struct {
	Name   string      `yaml:"name" json:"name" mapstructure:"name"`       // Name filter name unique
	Config interface{} `yaml:"config" json:"config" mapstructure:"config"` // Config filter config
}

Filter core struct, filter is extend by user

type FilterChain

type FilterChain struct {
	FilterChainMatch FilterChainMatch `yaml:"filter_chain_match" json:"filter_chain_match" mapstructure:"filter_chain_match"`
	Filters          []Filter         `yaml:"filters" json:"filters" mapstructure:"filters"`
}

FilterChain filter chain

type FilterChainMatch

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

FilterChainMatch

type GrpcHealthCheck

type GrpcHealthCheck struct {
	HealthCheck
	ServiceName string
	Authority   string
}

GrpcHealthCheck

type HTTPFilter

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

HTTPFilter http filter

type HeaderMatcher

type HeaderMatcher struct {
	Name  string `yaml:"name" json:"name"`
	Value string `yaml:"value" json:"value"`
	Regex bool   `yaml:"regex" json:"regex"`
}

HeaderMatcher header matcher struct 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 HealthCheck

type HealthCheck struct {
}

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

type HttpConnectionManager

type HttpConnectionManager struct {
	RouteConfig       RouteConfiguration     `yaml:"route_config" json:"route_config" mapstructure:"route_config"`
	AuthorityConfig   AuthorityConfiguration `yaml:"authority_config" json:"authority_config" mapstructure:"authority_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"`
}

HttpConnectionManager

type HttpHealthCheck

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

HttpHealthCheck

type LbPolicy

type LbPolicy int32

LbPolicy the load balance policy enum

const (
	RoundRobin LbPolicy = 0
	IPHash     LbPolicy = 1
	WightRobin LbPolicy = 2
	Rand       LbPolicy = 3
)

type LimitType

type LimitType int32

LimitType the authority rule limit enum

const (
	IP  LimitType = 0
	App LimitType = 1
)

LimitType limit type const

type Listener

type Listener struct {
	Name    string  `yaml:"name" json:"name" mapstructure:"name"`
	Address Address `yaml:"address" json:"address" mapstructure:"address"`

	FilterChains []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 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

const (
	HTTP ProtocolType = 0 + iota // support for 1.0
	TCP
	UDP
)

type Registry

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

Registry remote registry where dubbo apis are registered.

type RequestMethod

type RequestMethod int32

type RouteAction

type RouteAction struct {
	Cluster                     string            `yaml:"cluster" json:"cluster"` // Cluster cluster name
	ClusterNotFoundResponseCode int               `yaml:"cluster_not_found_response_code" json:"cluster_not_found_response_code"`
	PrefixRewrite               string            `yaml:"prefix_rewrite" json:"prefix_rewrite"`
	HostRewrite                 string            `yaml:"host_rewrite" json:"host_rewrite"`
	Timeout                     string            `yaml:"timeout" json:"timeout"`
	Priority                    int8              `yaml:"priority" json:"priority"`
	ResponseHeadersToAdd        HeaderValueOption `yaml:"response_headers_to_add" json:"response_headers_to_add"`       // ResponseHeadersToAdd add response head
	ResponseHeadersToRemove     []string          `yaml:"response_headers_to_remove" json:"response_headers_to_remove"` // ResponseHeadersToRemove remove response head
	RequestHeadersToAdd         HeaderValueOption `yaml:"request_headers_to_add" json:"request_headers_to_add"`         // RequestHeadersToAdd add request head
	Cors                        CorsPolicy        `yaml:"cors" json:"cors"`
}

RouteAction match route should do

type RouteConfiguration

type RouteConfiguration struct {
	InternalOnlyHeaders     []string          `yaml:"internal_only_headers" json:"internal_only_headers"`           // InternalOnlyHeaders used internal, clear http request head
	ResponseHeadersToAdd    HeaderValueOption `yaml:"response_headers_to_add" json:"response_headers_to_add"`       // ResponseHeadersToAdd add response head
	ResponseHeadersToRemove []string          `yaml:"response_headers_to_remove" json:"response_headers_to_remove"` // ResponseHeadersToRemove remove response head
	RequestHeadersToAdd     HeaderValueOption `yaml:"request_headers_to_add" json:"request_headers_to_add"`         // RequestHeadersToAdd add request head
	Routes                  []Router          `yaml:"routes" json:"routes"`
}

RouteConfiguration

type Router

type Router struct {
	Match    RouterMatch `yaml:"match" json:"match"`
	Route    RouteAction `yaml:"route" json:"route"`
	Redirect RouteAction `yaml:"redirect" json:"redirect"`
}

Router 路由

type RouterMatch

type RouterMatch struct {
	Prefix        string          `yaml:"prefix" json:"prefix"`
	Path          string          `yaml:"path" json:"path"`
	Regex         string          `yaml:"regex" json:"regex"`
	CaseSensitive bool            // CaseSensitive default true
	Headers       []HeaderMatcher `yaml:"headers" json:"headers"`
}

RouterMatch

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 `yaml:"reject_policy" json:"reject_policy,omitempty"`
}

ShutdownConfig how to shutdown proxy.

type SocketAddress

type SocketAddress struct {
	ProtocolStr  string       `yaml:"protocol_type" json:"protocol_type" mapstructure:"protocol_type"`
	Protocol     ProtocolType `yaml:"omitempty" json:"omitempty"`
	Address      string       `yaml:"address" json:"address" mapstructure:"address"`
	Port         int          `yaml:"port" json:"port" mapstructure:"port"`
	ResolverName string       `yaml:"resolver_name" json:"resolver_name" mapstructure:"resolver_name"`
}

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

type StaticResources

type StaticResources struct {
	Listeners       []Listener      `yaml:"listeners" json:"listeners" mapstructure:"listeners"`
	Clusters        []Cluster       `yaml:"clusters" json:"clusters" mapstructure:"clusters"`
	ShutdownConfig  *ShutdownConfig `yaml:"shutdown_config" json:"shutdown_config" mapstructure:"shutdown_config"`
	PprofConf       PprofConf       `yaml:"pprofConf" json:"pprofConf" mapstructure:"pprofConf"`
	AccessLogConfig AccessLogConfig `yaml:"accessLog" json:"accessLog" mapstructure:"accessLog"`
	APIMetaConfig   *APIMetaConfig  `yaml:"api_meta_config" json:"api_meta_config,omitempty"`
}

StaticResources

type StrategyType

type StrategyType int32

StrategyType the authority rule strategy enum

const (
	Whitelist StrategyType = 0
	Blacklist StrategyType = 1
)

StrategyType strategy type const

type StringMatcher

type StringMatcher struct {
	Matcher MatcherType
}

StringMatcher matcher string

func (*StringMatcher) Match

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

Match

type Tracing

type Tracing struct {
	Http Http `yaml:"http" json:"http,omitempty"`
}

Tracing

Jump to

Keyboard shortcuts

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