Documentation ¶
Index ¶
- Constants
- func CleanupLimiters()
- func RedisScript(script string, args ...interface{}) (interface{}, error)
- func ServiceManagerInit()
- type AppEvent
- type AppManager
- type AppObserver
- type AppSubject
- type DistributedCountService
- func (o *DistributedCountService) Close()
- func (o *DistributedCountService) GetDayData(t time.Time) (int64, error)
- func (o *DistributedCountService) GetDayKey(t time.Time) string
- func (o *DistributedCountService) GetHourData(t time.Time) (int64, error)
- func (o *DistributedCountService) GetHourKey(t time.Time) string
- func (o *DistributedCountService) Increase()
- type DistributedLimiter
- type FlowAppCounter
- type FlowCounter
- type FlowLimiter
- type FlowLimiterItem
- type Limiter
- type LoadBalancer
- type LoadBalancerItem
- type ServiceEvent
- type ServiceManager
- func (s *ServiceManager) Deregist(ob ServiceObserver)
- func (s *ServiceManager) GetGrpcServiceList() []*model.ServiceDetail
- func (s *ServiceManager) GetTcpServiceList() []*model.ServiceDetail
- func (s *ServiceManager) HTTPAccessMode(c *gin.Context) (*model.ServiceDetail, error)
- func (s *ServiceManager) Load() error
- func (s *ServiceManager) LoadAndWatch() error
- func (s *ServiceManager) LoadService() *ServiceManager
- func (s *ServiceManager) Notify(e *ServiceEvent)
- func (s *ServiceManager) Regist(ob ServiceObserver)
- type ServiceObserver
- type ServiceSubject
- type TransportItem
- type Transportor
Constants ¶
View Source
const ( DataTypeSecond = iota DataTypeMinute DataTypeHour )
Variables ¶
This section is empty.
Functions ¶
func CleanupLimiters ¶
func CleanupLimiters()
func RedisScript ¶
func ServiceManagerInit ¶
func ServiceManagerInit()
Types ¶
type AppManager ¶
type AppManager struct { AppMap map[string]*model.App AppSlice []*model.App UpdateAt time.Time Observers map[AppObserver]bool // contains filtered or unexported fields }
var AppManagerHandler *AppManager
func NewAppManager ¶
func NewAppManager() *AppManager
func (*AppManager) Deregist ¶
func (s *AppManager) Deregist(ob AppObserver)
func (*AppManager) GetAppList ¶
func (s *AppManager) GetAppList() []*model.App
func (*AppManager) LoadAndWatch ¶
func (s *AppManager) LoadAndWatch() error
func (*AppManager) LoadApp ¶
func (s *AppManager) LoadApp() *AppManager
func (*AppManager) Notify ¶
func (s *AppManager) Notify(e *AppEvent)
func (*AppManager) Regist ¶
func (s *AppManager) Regist(ob AppObserver)
type AppSubject ¶
type AppSubject interface { Regist(ServiceObserver) Deregist(ServiceObserver) Notify(*AppEvent) }
被观察者接口
type DistributedCountService ¶
type DistributedCountService struct { Name string Interval time.Duration QPS int64 Unix int64 TickerCount int64 TotalCount int64 // contains filtered or unexported fields }
func NewDistributedCountService ¶
func NewDistributedCountService(name string, interval time.Duration) *DistributedCountService
func (*DistributedCountService) Close ¶
func (o *DistributedCountService) Close()
func (*DistributedCountService) GetDayData ¶
func (o *DistributedCountService) GetDayData(t time.Time) (int64, error)
func (*DistributedCountService) GetDayKey ¶
func (o *DistributedCountService) GetDayKey(t time.Time) string
func (*DistributedCountService) GetHourData ¶
func (o *DistributedCountService) GetHourData(t time.Time) (int64, error)
func (*DistributedCountService) GetHourKey ¶
func (o *DistributedCountService) GetHourKey(t time.Time) string
func (*DistributedCountService) Increase ¶
func (o *DistributedCountService) Increase()
type DistributedLimiter ¶
type DistributedLimiter struct { Name string Dtype int //0=qps 1=qpm 2=qph Rate int64 Capacity int64 }
func NewDistributedLimiter ¶
func NewDistributedLimiter(name string, dtype int, rate, capacity int64) *DistributedLimiter
func (*DistributedLimiter) Allow ¶
func (d *DistributedLimiter) Allow() bool
func (*DistributedLimiter) AllowV1 ¶
func (d *DistributedLimiter) AllowV1() bool
type FlowAppCounter ¶
type FlowAppCounter struct {
FlowCounter
}
var AppCounterHandler *FlowAppCounter
func NewFlowAppCounter ¶
func NewFlowAppCounter() *FlowAppCounter
func (*FlowAppCounter) Update ¶
func (counter *FlowAppCounter) Update(e *AppEvent)
type FlowCounter ¶
type FlowCounter struct { RedisFlowCountMap map[string]*DistributedCountService Locker sync.RWMutex }
var ServiceCounterHandler *FlowCounter
func NewFlowCounter ¶
func NewFlowCounter() *FlowCounter
func (*FlowCounter) GetCounter ¶
func (counter *FlowCounter) GetCounter(name string) (*DistributedCountService, error)
func (*FlowCounter) Update ¶
func (counter *FlowCounter) Update(e *ServiceEvent)
type FlowLimiter ¶
type FlowLimiter struct { FlowLimiterMap map[string]*FlowLimiterItem Locker sync.RWMutex }
var FlowLimiterHandler *FlowLimiter
func NewFlowLimiter ¶
func NewFlowLimiter() *FlowLimiter
func (*FlowLimiter) GetLimiter ¶
func (counter *FlowLimiter) GetLimiter(serverName string, val float64, ltype int, isDistributed bool) (Limiter, error)
一个服务,可能设置多种限流策略
type FlowLimiterItem ¶
type LoadBalancer ¶
type LoadBalancer struct { LoadBanlanceMap map[string]*LoadBalancerItem LoadBanlanceSlice []*LoadBalancerItem Locker sync.RWMutex }
var LoadBalancerHandler *LoadBalancer
func NewLoadBalancer ¶
func NewLoadBalancer() *LoadBalancer
func (*LoadBalancer) GetLoadBalancer ¶
func (lbr *LoadBalancer) GetLoadBalancer(service *model.ServiceDetail) (*load_balance.LoadBalance, error)
func (*LoadBalancer) Update ¶
func (lbr *LoadBalancer) Update(e *ServiceEvent)
type LoadBalancerItem ¶
type LoadBalancerItem struct { LoadBanlance *load_balance.LoadBalance ServiceName string UpdatedAt time.Time }
type ServiceEvent ¶
type ServiceEvent struct { DeleteService []*model.ServiceDetail AddService []*model.ServiceDetail UpdateService []*model.ServiceDetail }
通知事件
type ServiceManager ¶
type ServiceManager struct { ServiceMap map[string]*model.ServiceDetail ServiceSlice []*model.ServiceDetail UpdateAt time.Time Observers map[ServiceObserver]bool sync.RWMutex // contains filtered or unexported fields }
var ServiceManagerHandler *ServiceManager = NewServiceManager()
func NewServiceManager ¶
func NewServiceManager() *ServiceManager
func (*ServiceManager) Deregist ¶
func (s *ServiceManager) Deregist(ob ServiceObserver)
func (*ServiceManager) GetGrpcServiceList ¶
func (s *ServiceManager) GetGrpcServiceList() []*model.ServiceDetail
func (*ServiceManager) GetTcpServiceList ¶
func (s *ServiceManager) GetTcpServiceList() []*model.ServiceDetail
func (*ServiceManager) HTTPAccessMode ¶
func (s *ServiceManager) HTTPAccessMode(c *gin.Context) (*model.ServiceDetail, error)
func (*ServiceManager) Load ¶
func (s *ServiceManager) Load() error
func (*ServiceManager) LoadAndWatch ¶
func (s *ServiceManager) LoadAndWatch() error
func (*ServiceManager) LoadService ¶
func (s *ServiceManager) LoadService() *ServiceManager
func (*ServiceManager) Notify ¶
func (s *ServiceManager) Notify(e *ServiceEvent)
func (*ServiceManager) Regist ¶
func (s *ServiceManager) Regist(ob ServiceObserver)
type ServiceSubject ¶
type ServiceSubject interface { Regist(ServiceObserver) Deregist(ServiceObserver) Notify(*ServiceEvent) }
被观察者接口
type TransportItem ¶
type Transportor ¶
type Transportor struct { TransportMap map[string]*TransportItem TransportSlice []*TransportItem Locker sync.RWMutex }
var TransportorHandler *Transportor
func NewTransportor ¶
func NewTransportor() *Transportor
func (*Transportor) GetTrans ¶
func (t *Transportor) GetTrans(service *model.ServiceDetail) (*http.Transport, error)
func (*Transportor) Update ¶
func (t *Transportor) Update(e *ServiceEvent)
Click to show internal directories.
Click to hide internal directories.