model

package
v0.0.0-...-d3ed2aa Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2016 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIStatusDown down status
	APIStatusDown = iota
	//APIStatusUp up status
	APIStatusUp
)
View Source
const (
	// FromQueryString query string
	FromQueryString = iota
	// FromForm form data
	FromForm
)
View Source
const (
	// Down backend server down status
	Down = Status(0)
	// Up backend server up status
	Up = Status(1)
)
View Source
const (
	// CircuitOpen Circuit open status
	CircuitOpen = Circuit(0)
	// CircuitHalf Circuit half status
	CircuitHalf = Circuit(1)
	// CircuitClose Circuit close status
	CircuitClose = Circuit(2)
)
View Source
const (
	// DefaultCheckDurationInSeconds Default duration to check server
	DefaultCheckDurationInSeconds = 5
	// DefaultCheckTimeoutInSeconds Default timeout to check server
	DefaultCheckTimeoutInSeconds = 3
)
View Source
const (
	// ActionClusters query cluster
	ActionClusters = "/clusters"
	// ActionServers query servers
	ActionServers = "/clusters/"
)
View Source
const (
	// EventTypeNew event type new
	EventTypeNew = EvtType(0)
	// EventTypeUpdate event type update
	EventTypeUpdate = EvtType(1)
	// EventTypeDelete event type delete
	EventTypeDelete = EvtType(2)
)
View Source
const (
	// EventSrcCluster cluster event
	EventSrcCluster = EvtSrc(0)
	// EventSrcServer server event
	EventSrcServer = EvtSrc(1)
	// EventSrcBind bind event
	EventSrcBind = EvtSrc(2)
	// EventSrcAPI api event
	EventSrcAPI = EvtSrc(3)
	// EventSrcRouting routing event
	EventSrcRouting = EvtSrc(4)
)
View Source
const (
	// Regexp reg type
	Regexp = iota
)

Variables

View Source
var (
	// TICKER ticket
	TICKER = time.Second * 3
	// TTL timeout
	TTL = uint64(5)
)
View Source
var (
	// GlobalCfgDesc global desc cfg
	GlobalCfgDesc = "desc"
	// GlobalCfgOrder global order cfg
	GlobalCfgOrder = "order"
	// GlobalCfgDeadline global deadline cfg
	GlobalCfgDeadline = "deadline"
	// GlobalCfgRule global rule cfg
	GlobalCfgRule = "rule"
	// GlobalCfgOr global or cfg
	GlobalCfgOr = "or"
)
View Source
var (
	// ValueHeader value of header prefix
	ValueHeader = "$HEADER"
	// ValueCookie value of cookie prefix
	ValueCookie = "$COOKIE"
	// ValueQuery value of query string prefix
	ValueQuery = "$QUERY"
)

rule: left [==,>,<=,>=,in,~] right can use var: $header_, $cookie_, $query_

View Source
var (
	// EQ ==
	EQ = "=="
	// LT <
	LT = "<"
	// LE <=
	LE = "<="
	// GT >
	GT = ">"
	// GE >=
	GE = ">="
	// IN in
	IN = "in"
	// MATCH reg matches
	MATCH = "~"

	// PATTERN reg pattern for expression
	PATTERN = regexp.MustCompile(fmt.Sprintf("^(?U)(.+)(%s|%s|%s|%s|%s|%s|%s)(.+)$", EQ, LE, LT, GE, GT, IN, MATCH))
)
View Source
var (
	// ErrServerExists Server already exist
	ErrServerExists = errors.New("Server already exist")
	// ErrClusterExists Cluster already exist
	ErrClusterExists = errors.New("Cluster already exist")
	// ErrBindExists Bind already exist
	ErrBindExists = errors.New("Bind already exist")
	// ErrAPIExists API already exist
	ErrAPIExists = errors.New("API already exist")
	// ErrRoutingExists Routing already exist
	ErrRoutingExists = errors.New("Routing already exist")
	// ErrServerNotFound Server not found
	ErrServerNotFound = errors.New("Server not found")
	// ErrClusterNotFound Cluster not found
	ErrClusterNotFound = errors.New("Cluster not found")
	// ErrBindNotFound Bind not found
	ErrBindNotFound = errors.New("Bind not found")
	// ErrAPINotFound API not found
	ErrAPINotFound = errors.New("API not found")
	// ErrRoutingNotFound Routing not found
	ErrRoutingNotFound = errors.New("Routing not found")
)
View Source
var (
	// ErrHasBind error has bind into, can not delete
	ErrHasBind = errors.New("Has bind info, can not delete")
)
View Source
var (
	// ErrSyntax Syntax error
	ErrSyntax = errors.New("Syntax error")
)

Functions

func MinusClusters

func MinusClusters(c map[string]*Cluster, c1 map[string]*Cluster, filter func(*Cluster) bool) map[string]*Cluster

MinusClusters get minus collection return collection which element is in c1 and not in c, c1 - c

func MinusServers

func MinusServers(c map[string]*Server, c1 map[string]*Server, filter func(*Server) bool) map[string]*Server

MinusServers get minus collection return collection which element is in c1 and not in c

Types

type API

type API struct {
	Name          string         `json:"name, omitempty"`
	URL           string         `json:"url"`
	Method        string         `json:"method"`
	Domain        string         `json:"domain, omitempty"`
	Status        int            `json:"status, omitempty"`
	AccessControl *AccessControl `json:"accessControl, omitempty"`
	Mock          *Mock          `json:"mock, omitempty"`
	Nodes         []*Node        `json:"nodes"`
	Desc          string         `json:"desc, omitempty"`
	Pattern       *regexp.Regexp `json:"-"`
}

API a api define

func NewAPI

func NewAPI(url string, nodes []*Node) *API

NewAPI create a API

func UnMarshalAPI

func UnMarshalAPI(data []byte) *API

UnMarshalAPI unmarshal

func UnMarshalAPIFromReader

func UnMarshalAPIFromReader(r io.Reader) (*API, error)

UnMarshalAPIFromReader unmarshal from reader

func (*API) AccessCheckBlacklist

func (a *API) AccessCheckBlacklist(ip string) bool

AccessCheckBlacklist check blacklist

func (*API) AccessCheckWhitelist

func (a *API) AccessCheckWhitelist(ip string) bool

AccessCheckWhitelist check whitelist

func (*API) Marshal

func (a *API) Marshal() []byte

Marshal marshal

func (*API) Parse

func (a *API) Parse()

Parse parse

func (*API) RenderMock

func (a *API) RenderMock(ctx *fasthttp.RequestCtx)

RenderMock dender mock response

type AccessControl

type AccessControl struct {
	Whitelist []string `json:"whitelist, omitempty"`
	Blacklist []string `json:"blacklist, omitempty"`
	// contains filtered or unexported fields
}

AccessControl access control

type AddAnalysisPointReq

type AddAnalysisPointReq struct {
	Addr string
	Secs int
}

AddAnalysisPointReq AddAnalysisPointReq

type AddAnalysisPointRsp

type AddAnalysisPointRsp struct {
	Code int
}

AddAnalysisPointRsp AddAnalysisPointRsp

type Analysis

type Analysis struct {
	// contains filtered or unexported fields
}

Analysis analysis struct

func (*Analysis) AddRecentCount

func (a *Analysis) AddRecentCount(key string, secs int)

AddRecentCount add analysis point on a key

func (*Analysis) Failure

func (a *Analysis) Failure(key string)

Failure incr failure count

func (*Analysis) GetContinuousFailureCount

func (a *Analysis) GetContinuousFailureCount(server string) int

GetContinuousFailureCount return Continuous failure request count in spec secs

func (*Analysis) GetQPS

func (a *Analysis) GetQPS(server string, secs int) int

GetQPS return qps in spec secs

func (*Analysis) GetRecentlyAvg

func (a *Analysis) GetRecentlyAvg(server string, secs int) int

GetRecentlyAvg return avg latency in spec secs

func (*Analysis) GetRecentlyMax

func (a *Analysis) GetRecentlyMax(server string, secs int) int

GetRecentlyMax return max latency in spec secs

func (*Analysis) GetRecentlyMin

func (a *Analysis) GetRecentlyMin(server string, secs int) int

GetRecentlyMin return min latency in spec secs

func (*Analysis) GetRecentlyRejectCount

func (a *Analysis) GetRecentlyRejectCount(server string, secs int) int

GetRecentlyRejectCount return reject count in spec secs

func (*Analysis) GetRecentlyRequestCount

func (a *Analysis) GetRecentlyRequestCount(server string, secs int) int

GetRecentlyRequestCount return the server request count in spec seconds

func (*Analysis) GetRecentlyRequestFailureCount

func (a *Analysis) GetRecentlyRequestFailureCount(server string, secs int) int

GetRecentlyRequestFailureCount return failure request count in spec secs

func (*Analysis) GetRecentlyRequestSuccessedCount

func (a *Analysis) GetRecentlyRequestSuccessedCount(server string, secs int) int

GetRecentlyRequestSuccessedCount return successed request count in spec secs

func (*Analysis) Reject

func (a *Analysis) Reject(key string)

Reject incr reject count

func (*Analysis) Request

func (a *Analysis) Request(key string)

Request incr request count

func (*Analysis) Response

func (a *Analysis) Response(key string, cost int64)

Response incr successed count

type Bind

type Bind struct {
	ClusterName string `json:"clusterName,omitempty"`
	ServerAddr  string `json:"serverAddr,omitempty"`
}

Bind a bind server and cluster

func UnMarshalBindFromReader

func UnMarshalBindFromReader(r io.Reader) (*Bind, error)

UnMarshalBindFromReader unmarshal

func (*Bind) Marshal

func (b *Bind) Marshal() []byte

Marshal marshal

func (*Bind) ToString

func (b *Bind) ToString() string

ToString return a desc string

type Circuit

type Circuit int

Circuit circuit status

type Cluster

type Cluster struct {
	Name   string `json:"name,omitempty"`
	LbName string `json:"lbName,omitempty"`
	// External external, e.g. create from external service discovery
	External    bool     `json:"external,omitempty"`
	BindServers []string `json:"bindServers,omitempty"`
	// contains filtered or unexported fields
}

Cluster cluster

func NewCluster

func NewCluster(name string, lbName string) (*Cluster, error)

NewCluster create a cluster

func UnMarshalCluster

func UnMarshalCluster(data []byte) *Cluster

UnMarshalCluster unmarshal

func UnMarshalClusterFromReader

func UnMarshalClusterFromReader(r io.Reader) (*Cluster, error)

UnMarshalClusterFromReader unmarshal from reader

func (*Cluster) AddBind

func (c *Cluster) AddBind(bind *Bind)

AddBind add bind

func (*Cluster) HasBind

func (c *Cluster) HasBind() bool

HasBind add bind

func (*Cluster) Marshal

func (c *Cluster) Marshal() []byte

Marshal marshal

func (*Cluster) RemoveBind

func (c *Cluster) RemoveBind(serverAddr string)

RemoveBind remove bind

func (*Cluster) Select

func (c *Cluster) Select(req *fasthttp.Request) string

Select return a server using spec loadbalance

type Clusters

type Clusters struct {
	Clusters map[string]*Cluster `json:"clusters"`
}

Clusters clusters

type EtcdStore

type EtcdStore struct {
	// contains filtered or unexported fields
}

EtcdStore etcd store impl

func (EtcdStore) AddAnalysisPoint

func (e EtcdStore) AddAnalysisPoint(proxyAddr, serverAddr string, secs int) error

AddAnalysisPoint add a analysis point

func (EtcdStore) ChangeLogLevel

func (e EtcdStore) ChangeLogLevel(addr string, level string) error

ChangeLogLevel change proxy log level

func (EtcdStore) Clean

func (e EtcdStore) Clean() error

Clean clean data in store

func (EtcdStore) DeleteAPI

func (e EtcdStore) DeleteAPI(apiURL, method string) error

DeleteAPI delete a api from store

func (EtcdStore) DeleteCluster

func (e EtcdStore) DeleteCluster(name string) error

DeleteCluster delete a cluster from store

func (EtcdStore) DeleteServer

func (e EtcdStore) DeleteServer(addr string) error

DeleteServer delete a server from store

func (EtcdStore) GC

func (e EtcdStore) GC() error

GC exec gc, delete some data

func (EtcdStore) GetAPI

func (e EtcdStore) GetAPI(apiURL, method string) (*API, error)

GetAPI return api by url from store

func (EtcdStore) GetAPIs

func (e EtcdStore) GetAPIs() ([]*API, error)

GetAPIs return api list from store

func (EtcdStore) GetAnalysisPoint

func (e EtcdStore) GetAnalysisPoint(proxyAddr, serverAddr string, secs int) (*GetAnalysisPointRsp, error)

GetAnalysisPoint return analysis point data

func (EtcdStore) GetBinds

func (e EtcdStore) GetBinds() ([]*Bind, error)

GetBinds return binds info

func (EtcdStore) GetCluster

func (e EtcdStore) GetCluster(clusterName string) (*Cluster, error)

GetCluster return cluster info

func (EtcdStore) GetClusters

func (e EtcdStore) GetClusters() ([]*Cluster, error)

GetClusters return clusters in store

func (EtcdStore) GetProxies

func (e EtcdStore) GetProxies() ([]*ProxyInfo, error)

GetProxies return runable proxies

func (EtcdStore) GetRoutings

func (e EtcdStore) GetRoutings() ([]*Routing, error)

GetRoutings return routes in store

func (EtcdStore) GetServer

func (e EtcdStore) GetServer(serverAddr string) (*Server, error)

GetServer return spec server

func (EtcdStore) GetServers

func (e EtcdStore) GetServers() ([]*Server, error)

GetServers return server from store

func (EtcdStore) Registry

func (e EtcdStore) Registry(proxyInfo *ProxyInfo) error

Registry registry self

func (EtcdStore) SaveAPI

func (e EtcdStore) SaveAPI(api *API) error

SaveAPI save a api in store

func (EtcdStore) SaveBind

func (e EtcdStore) SaveBind(bind *Bind) error

SaveBind save bind to store

func (EtcdStore) SaveCluster

func (e EtcdStore) SaveCluster(cluster *Cluster) error

SaveCluster save a cluster to store

func (EtcdStore) SaveRouting

func (e EtcdStore) SaveRouting(routing *Routing) error

SaveRouting save route to store

func (EtcdStore) SaveServer

func (e EtcdStore) SaveServer(svr *Server) error

SaveServer save a server to store

func (EtcdStore) UnBind

func (e EtcdStore) UnBind(bind *Bind) error

UnBind delete bind from store

func (EtcdStore) UpdateAPI

func (e EtcdStore) UpdateAPI(api *API) error

UpdateAPI update a api in store

func (EtcdStore) UpdateCluster

func (e EtcdStore) UpdateCluster(cluster *Cluster) error

UpdateCluster update a cluster to store

func (EtcdStore) UpdateServer

func (e EtcdStore) UpdateServer(svr *Server) error

UpdateServer update a server to store

func (EtcdStore) Watch

func (e EtcdStore) Watch(evtCh chan *Evt, stopCh chan bool) error

Watch watch event from etcd

type Evt

type Evt struct {
	Src   EvtSrc
	Type  EvtType
	Key   string
	Value interface{}
}

Evt event

type EvtSrc

type EvtSrc int

EvtSrc event src

type EvtType

type EvtType int

EvtType event type

type GetAnalysisPointReq

type GetAnalysisPointReq struct {
	Addr string
	Secs int
}

GetAnalysisPointReq GetAnalysisPointReq

type GetAnalysisPointRsp

type GetAnalysisPointRsp struct {
	Code                   int `json:"schema,omitempty"`
	RequestCount           int `json:"requestCount"`
	RejectCount            int `json:"rejectCount"`
	RequestSuccessedCount  int `json:"requestSuccessedCount"`
	RequestFailureCount    int `json:"requestFailureCount"`
	ContinuousFailureCount int `json:"continuousFailureCount"`
	QPS                    int `json:"qps"`
	Max                    int `json:"max"`
	Min                    int `json:"min"`
	Avg                    int `json:"avg"`
}

GetAnalysisPointRsp GetAnalysisPointRsp

type Mock

type Mock struct {
	Value         string             `json:"value"`
	ContentType   string             `json:"contentType, omitempty"`
	Headers       []*MockHeader      `json:"headers, omitempty"`
	Cookies       []string           `json:"cookies, omitempty"`
	ParsedCookies []*fasthttp.Cookie `json:"-"`
}

Mock mock

type MockHeader

type MockHeader struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

MockHeader header

type Node

type Node struct {
	ClusterName string        `json:"clusterName, omitempty"`
	Rewrite     string        `json:"rewrite, omitempty"`
	AttrName    string        `json:"attrName, omitempty"`
	Validations []*Validation `json:"validations, omitempty"`
}

Node api dispatch node

func (*Node) Validate

func (n *Node) Validate(req *fasthttp.Request) bool

Validate validate request

type ProxyInfo

type ProxyInfo struct {
	Conf *conf.Conf `json:"conf,omitempty"`
}

ProxyInfo proxy info

func UnMarshalProxyInfo

func UnMarshalProxyInfo(data []byte) *ProxyInfo

UnMarshalProxyInfo unmarshal

func (*ProxyInfo) Marshal

func (p *ProxyInfo) Marshal() string

Marshal marshal

type Recently

type Recently struct {
	// contains filtered or unexported fields
}

Recently recently point data

type Register

type Register interface {
	Registry(proxyInfo *ProxyInfo) error

	GetProxies() ([]*ProxyInfo, error)

	ChangeLogLevel(proxyAddr string, level string) error

	AddAnalysisPoint(proxyAddr, serverAddr string, secs int) error

	GetAnalysisPoint(proxyAddr, serverAddr string, secs int) (*GetAnalysisPointRsp, error)
}

Register register

type RouteResult

type RouteResult struct {
	API   *API
	Node  *Node
	Svr   *Server
	Err   error
	Code  int
	Res   *fasthttp.Response
	Merge bool
}

RouteResult RouteResult

func (*RouteResult) GetRewritePath

func (result *RouteResult) GetRewritePath(req *fasthttp.Request) string

GetRewritePath get rewrite path

func (*RouteResult) NeedRewrite

func (result *RouteResult) NeedRewrite() bool

NeedRewrite need rewrite

func (*RouteResult) Release

func (result *RouteResult) Release()

Release release resp

type RouteTable

type RouteTable struct {
	// contains filtered or unexported fields
}

RouteTable route table

func NewRouteTable

func NewRouteTable(cnf *conf.Conf, store Store, serviceDiscoveryDriver *ServiceDiscoveryDriver) *RouteTable

NewRouteTable create a new RouteTable

func (*RouteTable) AddNewAPI

func (r *RouteTable) AddNewAPI(api *API) error

AddNewAPI add a new API

func (*RouteTable) AddNewCluster

func (r *RouteTable) AddNewCluster(cluster *Cluster) error

AddNewCluster add new cluster

func (*RouteTable) AddNewRouting

func (r *RouteTable) AddNewRouting(routing *Routing) error

AddNewRouting add a new route

func (*RouteTable) AddNewServer

func (r *RouteTable) AddNewServer(svr *Server) error

AddNewServer add a new server

func (*RouteTable) Bind

func (r *RouteTable) Bind(svrAddr string, clusterName string) error

Bind bind server and cluster

func (*RouteTable) DeleteAPI

func (r *RouteTable) DeleteAPI(url, method string) error

DeleteAPI delete a api using url

func (*RouteTable) DeleteCluster

func (r *RouteTable) DeleteCluster(clusterName string) error

DeleteCluster delete a cluster

func (*RouteTable) DeleteRouting

func (r *RouteTable) DeleteRouting(id string) error

DeleteRouting delete a route

func (*RouteTable) DeleteServer

func (r *RouteTable) DeleteServer(serverAddr string) error

DeleteServer delete a server

func (*RouteTable) GetAnalysis

func (r *RouteTable) GetAnalysis() *Analysis

GetAnalysis return analysis

func (*RouteTable) GetServer

func (r *RouteTable) GetServer(addr string) *Server

GetServer return server

func (*RouteTable) GetTimeWheel

func (r *RouteTable) GetTimeWheel() *goetty.HashedTimeWheel

GetTimeWheel return time wheel

func (*RouteTable) Load

func (r *RouteTable) Load()

Load load info from store

func (*RouteTable) Select

func (r *RouteTable) Select(req *fasthttp.Request) []*RouteResult

Select return route result

func (*RouteTable) UnBind

func (r *RouteTable) UnBind(svrAddr string, clusterName string) error

UnBind unbind cluster and server

func (*RouteTable) UpdateAPI

func (r *RouteTable) UpdateAPI(api *API) error

UpdateAPI update API

func (*RouteTable) UpdateCluster

func (r *RouteTable) UpdateCluster(cluster *Cluster) error

UpdateCluster update cluster

func (*RouteTable) UpdateServer

func (r *RouteTable) UpdateServer(svr *Server) error

UpdateServer update server

type Routing

type Routing struct {
	ClusterName string `json:"clusterName, omitempty"`
	ID          string `json:"id,omitempty"`
	Cfg         string `json:"cfg,omitempty"`
	URL         string `json:"url,omitempty"`
	// contains filtered or unexported fields
}

Routing routing

func NewRouting

func NewRouting(cfgString string, clusterName string, url string) (*Routing, error)

NewRouting create a new Routing

func UnMarshalRouting

func UnMarshalRouting(data []byte) *Routing

UnMarshalRouting unmarshal

func UnMarshalRoutingFromReader

func UnMarshalRoutingFromReader(r io.Reader) (*Routing, error)

UnMarshalRoutingFromReader unmarshal

func (*Routing) Check

func (r *Routing) Check() error

Check check config

func (*Routing) Marshal

func (r *Routing) Marshal() []byte

Marshal marshal

func (*Routing) Matches

func (r *Routing) Matches(req *fasthttp.Request) bool

Matches return true if req matches

type RoutingItem

type RoutingItem struct {
	// contains filtered or unexported fields
}

RoutingItem routing item

type Server

type Server struct {
	Schema string `json:"schema,omitempty"`
	Addr   string `json:"addr,omitempty"`

	// External external, e.g. create from external service discovery
	External bool `json:"external,omitempty"`
	// CheckPath begin with / checkpath, expect return CheckResponsedBody.
	CheckPath string `json:"checkPath,omitempty"`
	// CheckResponsedBody check url responsed http body, if not set, not check body
	CheckResponsedBody string `json:"checkResponsedBody"`
	// CheckDuration check interval, unit second
	CheckDuration int `json:"checkDuration,omitempty"`
	// CheckTimeout timeout to check server
	CheckTimeout int `json:"checkTimeout,omitempty"`
	// Status Server status
	Status Status `json:"status,omitempty"`

	// MaxQPS the backend server max qps support
	MaxQPS          int `json:"maxQPS,omitempty"`
	HalfToOpen      int `json:"halfToOpen,omitempty"`
	HalfTrafficRate int `json:"halfTrafficRate,omitempty"`
	CloseCount      int `json:"closeCount,omitempty"`

	BindClusters []string `json:"bindClusters,omitempty"`
	// contains filtered or unexported fields
}

Server server

func UnMarshalServer

func UnMarshalServer(data []byte) *Server

UnMarshalServer unmarshal

func UnMarshalServerFromReader

func UnMarshalServerFromReader(r io.Reader) (*Server, error)

UnMarshalServerFromReader unmarshal

func (*Server) AddBind

func (s *Server) AddBind(bind *Bind)

AddBind add bind

func (*Server) CloseCircuit

func (s *Server) CloseCircuit()

CloseCircuit set circuit close status

func (*Server) GetCircuit

func (s *Server) GetCircuit() Circuit

GetCircuit return circuit status

func (*Server) HalfCircuit

func (s *Server) HalfCircuit()

HalfCircuit set circuit half status

func (*Server) HasBind

func (s *Server) HasBind() bool

HasBind add bind

func (*Server) Lock

func (s *Server) Lock()

Lock lock

func (*Server) Marshal

func (s *Server) Marshal() []byte

Marshal marshal

func (*Server) OpenCircuit

func (s *Server) OpenCircuit()

OpenCircuit set circuit open status

func (*Server) RemoveBind

func (s *Server) RemoveBind(clusterName string)

RemoveBind remove bind

func (*Server) UnLock

func (s *Server) UnLock()

UnLock unlock

type Servers

type Servers struct {
	Servers map[string]*Server `json:"servers"`
}

Servers servers

type ServiceDiscoveryDriver

type ServiceDiscoveryDriver struct {
	// contains filtered or unexported fields
}

ServiceDiscoveryDriver service discovery driver service discovery is used for auto discovery domains, servers and binds.

func NewServiceDiscoveryDriver

func NewServiceDiscoveryDriver(registryCenter *plugin.RegistryCenter) *ServiceDiscoveryDriver

NewServiceDiscoveryDriver new ServiceDiscoveryDriver

func (*ServiceDiscoveryDriver) GetAllClusters

func (d *ServiceDiscoveryDriver) GetAllClusters() (*Clusters, error)

GetAllClusters get all clusters

func (*ServiceDiscoveryDriver) GetServersByClusterName

func (d *ServiceDiscoveryDriver) GetServersByClusterName(clusterName string) (*Servers, error)

GetServersByClusterName get all servers in domains

type SetLogReq

type SetLogReq struct {
	Level string
}

SetLogReq SetLogReq

type SetLogRsp

type SetLogRsp struct {
	Code int
}

SetLogRsp SetLogRsp

type SetReqHeadStaticMappingReq

type SetReqHeadStaticMappingReq struct {
	Name  string
	Value string
}

SetReqHeadStaticMappingReq SetReqHeadStaticMappingReq

type SetReqHeadStaticMappingRsp

type SetReqHeadStaticMappingRsp struct {
	Code int
}

SetReqHeadStaticMappingRsp SetReqHeadStaticMappingRsp

type Status

type Status int

Status status

type Store

type Store interface {
	SaveBind(bind *Bind) error
	UnBind(bind *Bind) error
	GetBinds() ([]*Bind, error)

	SaveCluster(cluster *Cluster) error
	UpdateCluster(cluster *Cluster) error
	DeleteCluster(name string) error
	GetClusters() ([]*Cluster, error)
	GetCluster(clusterName string) (*Cluster, error)

	SaveServer(svr *Server) error
	UpdateServer(svr *Server) error
	DeleteServer(addr string) error
	GetServers() ([]*Server, error)
	GetServer(serverAddr string) (*Server, error)

	SaveAPI(api *API) error
	UpdateAPI(api *API) error
	DeleteAPI(url string, method string) error
	GetAPIs() ([]*API, error)
	GetAPI(url string, method string) (*API, error)

	SaveRouting(routing *Routing) error
	GetRoutings() ([]*Routing, error)

	Watch(evtCh chan *Evt, stopCh chan bool) error

	Clean() error
	GC() error
}

Store store interface

func NewEtcdStore

func NewEtcdStore(etcdAddrs []string, prefix string) (Store, error)

NewEtcdStore create a etcd store

type Validation

type Validation struct {
	Attr     string            `json:"attr, omitempty"`
	GetFrom  int               `json:"getFrom, omitempty"`
	Required bool              `json:"required, omitempty"`
	Rules    []*ValidationRule `json:"rules, omitempty"`
}

Validation validate rule

func (Validation) ParseValidation

func (v Validation) ParseValidation()

ParseValidation parse validation

type ValidationRule

type ValidationRule struct {
	Type       int    `json:"type, omitempty"`
	Expression string `json:"expression, omitempty"`
	// contains filtered or unexported fields
}

ValidationRule validation rule

Jump to

Keyboard shortcuts

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