gw

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProtocolHTTP gw service http protocol
	ProtocolHTTP = "HTTP"
	// ProtocolHTTPS gw service https protocol
	// Temporarily, only ProtocolHTTPS is used
	ProtocolHTTPS = "HTTPS"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Cluster string
	ZkPath  string
	// contains filtered or unexported fields
}

Client client for operate gw services

func NewClient

func NewClient(ctx context.Context, cluster string, r *rdiscover.RegDiscover, zkPath string) *Client

NewClient create new client for gw server

func NewClientWithTLS

func NewClientWithTLS(ctx context.Context, cluster string, r *rdiscover.RegDiscover, zkPath string, tlsConfig *tls.Config) *Client

NewClientWithTLS create new client for tls gw server

func (*Client) Delete

func (c *Client) Delete(svcs []*Service) error

Delete call delete api to gw concentrator

func (*Client) Run

func (c *Client) Run() error

Run start discover gw server master

func (*Client) Update

func (c *Client) Update(svcs []*Service) error

Update call update api to gw concentrator

type DeleteRequest

type DeleteRequest struct {
	Request
	ServiceList []*Service `json:"service_list"`
}

DeleteRequest request for delete gw services from concentrator cache

type DeleteResponse

type DeleteResponse struct {
	Response
}

DeleteResponse response for delete gw services

type ExclusiveSet

type ExclusiveSet struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

ExclusiveSet exclusive set parameter

type Interface

type Interface interface {
	Run() error
	Update(svcs []*Service) error
	Delete(svcs []*Service) error
}

Interface interface to call gw api

type Location

type Location struct {
	LocationID             string                      `json:"location_id,omitempty"`
	URL                    string                      `json:"url"`
	LocationCustomizedConf string                      `json:"location_customized_conf"`
	LocLimitRate           int                         `json:"loc_limit_rate"`
	LocLimitStatusCode     int                         `json:"loc_limit_status_code"`
	ForwardStrategy        *LocationForwardStrategy    `json:"forward_strategy,omitempty"`
	SessionPersistence     *LocationSessionPersistence `json:"session_persistence,omitempty"`
	HealthCheck            *LocationHealthCheck        `json:"health_check,omitempty"`
	RSList                 []*RealServer               `json:"rs_list,omitempty"`
	Rewrite                *LocationRewrite            `json:"rewrite,omitempty"`
}

Location location in request

func (*Location) Diff

func (l *Location) Diff(anotherL *Location) bool

Diff judge anotherL Location is the same with l Location

func (*Location) GetNewLocationWithExtraRS

func (l *Location) GetNewLocationWithExtraRS(newL *Location) *Location

GetNewLocationWithExtraRS get new location with extra real server of newL Location campared with l Location

func (*Location) Key

func (l *Location) Key() string

Key get key string of location

type LocationForwardStrategy

type LocationForwardStrategy struct {
	Type string `json:"type,omitempty"`
	//1.DEFAULT: detail默认为”wrr”,根据rs的权重转发请求数, detai:[“wrr”, “ip_hash”, “least_conn”]
	//2.REDIRECT: 无RS,将请求重定向到detail指定的url,
	//3.RETRUNFAIL:无RS,直接返回错误码,detail为错误码
	Detail string `json:"detail,omitempty"`
}

LocationForwardStrategy forward strategy for location

func (*LocationForwardStrategy) Diff

func (lfs *LocationForwardStrategy) Diff(anotherLfs *LocationForwardStrategy) bool

Diff judge if anotherLfs LocationForwardStrategy is the same with lfs LocationForwardStrategy

type LocationHealthCheck

type LocationHealthCheck struct {
	OP            string `json:"op"`       // set or del
	Protocol      string `json:"protocol"` // HTTP
	AliveNum      int    `json:"alive_num"`
	KickNum       int    `json:"kick_num"`
	ProbeInterval int    `json:"probe_interval"`
	AliveCode     int    `json:"alive_code"`
	ProbeURL      string `json:"probe_url"`
	Method        string `json:"method"`
	ServerName    string `json:"server_name"`
}

LocationHealthCheck health check for location

func (*LocationHealthCheck) Diff

func (lhc *LocationHealthCheck) Diff(anotherLhc *LocationHealthCheck) bool

Diff judge anotherLhc LocationHealthCheck is the same with lhc LocationHealthCheck

type LocationRewrite

type LocationRewrite struct {
	OP   string `json:"op,omitempty"`
	Type string `json:"type"`
	URL  string `json:"url"`
}

LocationRewrite rewrite config for location

func (*LocationRewrite) Diff

func (lr *LocationRewrite) Diff(anotherLr *LocationRewrite) bool

Diff judge anotherLr LocationRewrite is the same with lr LocationRewrite

type LocationSessionPersistence

type LocationSessionPersistence struct {
	Type           string `json:"type"`
	CookieTimeMode int    `json:"cookietime_mode"`
	Timeout        int    `json:"timeout"`
	CookieKey      string `json:"cookie_key"`
}

LocationSessionPersistence sesseion for location

func (*LocationSessionPersistence) Diff

Diff judge if anotherLsp LocationSessionPersistence is the same with lsp LocationSessionPersistence

type MockClient

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

MockClient mock gw client

func (*MockClient) Delete

func (mc *MockClient) Delete(svcs []*Service) error

Delete implements interface

func (*MockClient) List

func (mc *MockClient) List() ([]*Service, error)

List list services

func (*MockClient) Run

func (mc *MockClient) Run() error

Run implements interface

func (*MockClient) Update

func (mc *MockClient) Update(svcs []*Service) error

Update implements interface

type RealServer

type RealServer struct {
	IP     string `json:"rs_ip"`
	Port   int    `json:"rs_port"`
	VpcID  int    `json:"vpcid,omitempty"`
	HostIP string `json:"host_ip,omitempty"`
	Weight int    `json:"rs_weight"`
}

RealServer real server for location

func (*RealServer) Diff

func (rs *RealServer) Diff(anotherRs *RealServer) bool

Diff judge anotherRs RealServer is the same with rs RealServer

func (*RealServer) Key

func (rs *RealServer) Key() string

Key get key string of RealServer

type Request

type Request struct {
	Cluster string `json:"cluster"`
}

Request request

type Response

type Response struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Response response

type ServerInfo

type ServerInfo struct {
	IP         string `json:"ip"`
	Port       uint   `json:"port"`
	MetricPort uint   `json:"metric_port"`
	HostName   string `json:"hostname"`
	//http, https
	Scheme  string `json:"scheme"`
	Version string `json:"version"`
	Cluster string `json:"cluster"`
	Pid     int    `json:"pid"`
}

ServerInfo gw server information in zk path

type Service

type Service struct {
	BizID                   string      `json:"biz_id"`
	VIPList                 []string    `json:"vip_list"`
	Domain                  string      `json:"domain"`
	VPort                   int         `json:"vport"`
	VpcID                   int         `json:"vpcid,omitempty"`                    // optional, just for private network loadbalance
	Type                    string      `json:"type,omitempty"`                     // optional, HTTP default, HTTP or HTTPS
	SSLEnable               bool        `json:"ssl_enable,omitempty"`               // optional, must be true for HTTPS
	SSLVerifyClientEnable   bool        `json:"ssl_verify_client_enable,omitempty"` // optional
	CertID                  string      `json:"cert_id,omitempty"`
	DefaultServer           bool        `json:"default_server"`
	ServerCustomizedConf    string      `json:"server_customized_conf,omitempty"`
	VIPProtoLimitRate       int         `json:"vip_proto_limit_rate,omitempty"`        // speed limit value
	VIPProtoLimitStatusCode int         `json:"vip_proto_limit_status_code,omitempty"` // speed limit status code
	VSLimitRate             int         `json:"vs_limit_rate,omitempty"`
	VSLimitStatusCode       int         `json:"vs_limit_status_code,omitempty"`
	LocationList            []*Location `json:"location_list,omitempty"`
}

Service service list

func NewServiceWithoutLocationList

func NewServiceWithoutLocationList(svc *Service) *Service

NewServiceWithoutLocationList new Service obj with empty location list

func (*Service) Diff

func (s *Service) Diff(another *Service) bool

Diff judge another Service is the same with s Service

func (*Service) Key

func (s *Service) Key() string

Key get service key of domain and vport

type UpdateRequest

type UpdateRequest struct {
	Request
	ServiceList []*Service `json:"service_list"`
}

UpdateRequest request for sync gw services

type UpdateResponse

type UpdateResponse struct {
	Response
}

UpdateResponse response for sync gw services

Jump to

Keyboard shortcuts

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