po

package
v0.0.0-...-2828958 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID        int64     `db:"id"`
	Qps       int64     `db:"qps"`
	Qpd       int64     `db:"qpd"`
	AppID     string    `db:"app_id"`
	Name      string    `db:"name"`
	Secret    string    `db:"secret"`
	WhiteIPs  string    `db:"white_ips"`
	CreatedAt time.Time `db:"create_at"`
	UpdatedAt time.Time `db:"update_at"`
	IsDelete  int       `db:"is_delete"`
}

func GetAppDetailByID

func GetAppDetailByID(ID int64, c *gin.Context) (appDetail *App, err error)

type AppManager

type AppManager struct {
	AppMap   map[string]*App
	AppSlice []*App
	Locker   sync.RWMutex
	// contains filtered or unexported fields
}
var AppManagerHandler *AppManager

func NewAppManagerHandler

func NewAppManagerHandler() *AppManager

func (*AppManager) GetAppList

func (a *AppManager) GetAppList() []*App

func (*AppManager) LoadOnce

func (a *AppManager) LoadOnce() error

LoadOnce 服务加载到内存

type LoadBalancer

type LoadBalancer struct {
	// 当服务多的时候使用map方便,但是需要加锁
	LoadBalanceMap map[string]*LoadBalancerItem
	// 当服务比较少的时候使用 slice 便利,减少锁的开销
	LoadBalanceSlice []*LoadBalancerItem
	Locker           sync.RWMutex
}
var LoadBalancerHandler *LoadBalancer

func NewLoadBalancer

func NewLoadBalancer() *LoadBalancer

func (*LoadBalancer) GetLoadBalancer

func (lbr *LoadBalancer) GetLoadBalancer(service *ServiceDetail) (loadbalance.LoadBalance, error)

type LoadBalancerItem

type LoadBalancerItem struct {
	LoadBalance loadbalance.LoadBalance
	ServiceName string
}

type ServiceAccessControl

type ServiceAccessControl struct {
	ID                int64  `db:"id" json:"id"`
	ServiceID         int64  `db:"service_id" json:"service_id"`
	BlackList         string `db:"black_list" json:"black_list"`
	WhiteList         string `db:"white_list" json:"white_list"`
	WhiteHostName     string `db:"white_host_name" json:"white_host_name"`
	OpenAuth          int    `db:"open_auth" json:"open_auth"`
	ClientIPFlowLimit int    `db:"clientip_flow_limit" json:"clientip_flow_limit"`
	ServiceFlowLimit  int    `db:"service_flow_limit" json:"service_flow_limit"`
}

func GetServiceAccessControllerByID

func GetServiceAccessControllerByID(ID int64, c *gin.Context,
) (accessController *ServiceAccessControl, err error)

type ServiceDetail

type ServiceDetail struct {
	Info          *ServiceInfo          `json:"info" description:"基本信息"`
	HTTPRule      *ServiceHTTPRule      `json:"http_rule" description:"http_rule"`
	TCPRule       *ServiceTCPRule       `json:"tcp_rule" description:"tcp_rule"`
	GRPCRule      *ServiceGRPCRule      `json:"grpc_rule" description:"grpc_rule"`
	LoadBalance   *ServiceLoadBalance   `json:"load_balance" description:"load_balance"`
	AccessControl *ServiceAccessControl `json:"access_control" description:"access_control"`
}

ServiceDetail 查询服务列表 Do

func GetServiceDetail

func GetServiceDetail(serviceInfo *ServiceInfo, c *gin.Context) (detail *ServiceDetail, err error)

type ServiceGRPCRule

type ServiceGRPCRule struct {
	ID             int64  `db:"id" json:"id"`
	ServiceID      int64  `db:"service_id" json:"service_id"`
	Port           int    `db:"port" json:"port"`
	HeaderTransfor string `db:"header_transfor" json:"header_transfor"`
}

func GetServiceGRPCRuleByID

func GetServiceGRPCRuleByID(ID int64, c *gin.Context,
) (grpcRule *ServiceGRPCRule, err error)

type ServiceHTTPRule

type ServiceHTTPRule struct {
	ID             int64  `db:"id" json:"id"`
	ServiceID      int64  `db:"service_id" json:"service_id"`
	RuleType       int    `db:"rule_type" json:"rule_type"`
	NeedHTTPs      int    `db:"need_https" json:"need_https"`
	NeedStripUri   int    `db:"need_strip_uri" json:"need_strip_uri"`
	NeedWebsocket  int    `db:"need_websocket" json:"need_websocket"`
	Rule           string `db:"rule" json:"rule"`
	UrlRewrite     string `db:"url_rewrite" json:"url_rewrite"`
	HeaderTransfor string `db:"header_transfor" json:"header_transfor"`
}

func GetServiceHTTPRuleByID

func GetServiceHTTPRuleByID(ID int64, c *gin.Context,
) (httpRule *ServiceHTTPRule, err error)

type ServiceInfo

type ServiceInfo struct {
	ID          int64     `db:"id" json:"id"`
	LoadType    int       `db:"load_type" json:"load_type"`
	IsDelete    int       `db:"is_delete" json:"is_delete"`
	ServiceName string    `db:"service_name" json:"service_name"`
	ServiceDesc string    `db:"service_desc" json:"service_desc"`
	CreatedAt   time.Time `db:"create_at" json:"create_at"'`
	UpdatedAt   time.Time `db:"update_at" json:"update_at"`
}

func GetServiceInfoList

func GetServiceInfoList(page, size int, c *gin.Context,
) (serviceInfoList []*ServiceInfo, total int64, err error)

type ServiceListInput

type ServiceListInput struct {
	Info     string // 关键词
	PageNo   int    // 页数
	PageSize int    // 每页条数
}

ServiceListInput 查询信息 Do

type ServiceLoadBalance

type ServiceLoadBalance struct {
	ID                     int64  `db:"id" json:"id"`
	ServiceID              int64  `db:"service_id" json:"service_id"`
	CheckMethod            int    `db:"check_method" json:"check_method"`
	CheckTimeout           int    `db:"check_timeout" json:"check_timeout"`
	CheckInterval          int    `db:"check_interval" json:"check_interval"`
	RoundType              int    `db:"round_type" json:"round_type"`
	IPList                 string `db:"ip_list" json:"ip_list"`
	WeightList             string `db:"weight_list" json:"weight_list"`
	ForbidList             string `db:"forbid_list" json:"forbid_list"`
	UpStreamConnectTimeout int    `db:"upstream_connect_timeout" json:"upstream_connect_timeout"`
	UpStreamHeaderTimeout  int    `db:"upstream_header_timeout" json:"upstream_header_timeout"`
	UpStreamIdleTimeout    int    `db:"upstream_idle_timeout" json:"upstream_idle_timeout"`
	UpStreamMaxIdle        int    `db:"upstream_max_idle" json:"upstream_max_idle"`
}

func GetServiceLoadBalanceByID

func GetServiceLoadBalanceByID(ID int64, c *gin.Context,
) (loadBalance *ServiceLoadBalance, err error)

func (*ServiceLoadBalance) GetIpListByModel

func (l *ServiceLoadBalance) GetIpListByModel() []string

func (*ServiceLoadBalance) GetWeightListByModel

func (l *ServiceLoadBalance) GetWeightListByModel() []string

type ServiceManager

type ServiceManager struct {
	ServiceMap   map[string]*ServiceDetail
	ServiceSlice []*ServiceDetail
	Locker       sync.RWMutex // 锁
	// contains filtered or unexported fields
}
var ServiceManagerHandler *ServiceManager

func NewServiceManager

func NewServiceManager() *ServiceManager

NewServiceManager xx

func (*ServiceManager) GetGRPCServiceList

func (s *ServiceManager) GetGRPCServiceList() []*ServiceDetail

func (*ServiceManager) GetTCPServiceList

func (s *ServiceManager) GetTCPServiceList() []*ServiceDetail

func (*ServiceManager) HTTPAccessMode

func (s *ServiceManager) HTTPAccessMode(c *gin.Context) (*ServiceDetail, error)

HTTPAccessMode 匹配接入

func (*ServiceManager) LoadOnce

func (s *ServiceManager) LoadOnce() error

LoadOnce 服务加载到内存

type ServiceTCPRule

type ServiceTCPRule struct {
	ID        int64 `db:"id" json:"id"`
	ServiceID int64 `db:"service_id" json:"service_id"`
	Port      int   `db:"port" json:"port"`
}

func GetServiceTCPRuleByID

func GetServiceTCPRuleByID(ID int64, c *gin.Context,
) (tcpRule *ServiceTCPRule, err error)

type Transport

type Transport struct {
	TransportMap   map[string]*TransportItem
	TransportSlice []*TransportItem
	Locker         sync.RWMutex
}
var TransportHandler *Transport

func NewTransport

func NewTransport() *Transport

func (*Transport) GetTransport

func (t *Transport) GetTransport(service *ServiceDetail) (*http.Transport, error)

type TransportItem

type TransportItem struct {
	Transport   *http.Transport
	ServiceName string
}

Jump to

Keyboard shortcuts

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