Documentation ¶
Index ¶
- Constants
- Variables
- func Average(dataSet []int64)
- func CheckIfIPValid(ip string) bool
- func IsValidIP(ip string) bool
- func IsValidIPAddressV1(ip string) bool
- func IsValidIPAddressV2(ip string) bool
- func IsValidIPAddressV3(ip string) bool
- func KMP(a, b []byte, n, m int) int
- func Max(dataSet []int64)
- func Min(dataSet []int64)
- type Alert
- type AlertHandler
- type AlertRule
- type AlertRuleV3
- type AlertV3
- type ApiStatInfo
- type ApolloConfigSource
- type ApplicationContext
- type BaseHandler
- type ConfigServer
- type ConfigSource
- type Customer
- type CustomerRepo
- type CustomerRepoV2
- type CustomerService
- type CustomerServiceV2
- type DefaultSerialization
- type Demo
- type Deserializer
- type Deserializers
- type Document
- type DocumentFactory
- type ErrorAlertHandler
- type HTML
- type HtmlDownloader
- type InboxSender
- type Infos
- type JsonMessageFormatter
- type KafkaConfig
- type KafkaMessageQueue
- type MessageFormatter
- type MessageQueue
- type MessageSender
- type MsgSender
- type MySQLConfig
- type NetworkTransporter
- type Notification
- type NotificationDI
- type NotificationDIV2
- type NotificationEmergencyLevel
- type NotificationNoDI
- type NotificationV3
- type ProtoBufMessageFormatter
- type RedisConfig
- type RestrictedUserService
- type RestrictedUserServiceImpl
- type RocketMQMessageQueue
- type SMSSender
- type ScheduledUpdater
- type SecurityTransporter
- type Serialization
- type Serializations
- type Serializer
- type Serializers
- type Stage1UserInfo
- type Stage2UserAddress
- type Stage2UserInfo
- type Stage3Account
- type Stage3UserAddress
- type Stage3UserInfo
- type Statistics
- type TimeoutAlertHandler
- type TpsAlertHandler
- type Transport
- type Transporter
- type Updater
- type UserAuthenticator
- type UserAuthenticatorV2
- type UserInfo
- type UserService
- type UserServiceImpl
- type UserServiceTest
- type Viewer
- type ZookeeperConfigSource
Constants ¶
View Source
const IdentifierString = "UEUEUE;"
Variables ¶
View Source
var ( InvalidUsernameErr = errors.New("invalid username") InvalidPasswordErr = errors.New("invalid password") )
View Source
var ( InvalidEmailErr = errors.New("invalid email") AuthorizationFailureErr = errors.New("authorization failure") )
View Source
var NoAuthorizationErr = errors.New("no authorization runtime error")
Functions ¶
func CheckIfIPValid ¶
func IsValidIPAddressV2 ¶
IsValidIPAddressV2 使用 net 库中的 ParseIP 函数
func IsValidIPAddressV3 ¶
IsValidIPAddressV3 手写,只实现了解析以点分割的 IPv4
Types ¶
type Alert ¶
type Alert struct {
// contains filtered or unexported fields
}
func NewAlert ¶
func NewAlert(rule AlertRule, notification Notification) *Alert
type AlertHandler ¶
type AlertHandler interface {
Check(info *ApiStatInfo)
}
type AlertRule ¶
type AlertRule struct {
// contains filtered or unexported fields
}
AlertRule 存储告警规则
func (*AlertRule) GetMatchedRule ¶
func (*AlertRule) GetMaxErrorCount ¶
func (*AlertRule) GetMaxTimeoutTps ¶
type AlertRuleV3 ¶
type AlertRuleV3 struct {
// contains filtered or unexported fields
}
func NewAlertRuleV3 ¶
func NewAlertRuleV3(maxTps int, maxErrorCount int, maxTimeoutTps int) *AlertRuleV3
func (*AlertRuleV3) GetMatchedRule ¶
func (a *AlertRuleV3) GetMatchedRule(api string) *AlertRuleV3
func (*AlertRuleV3) GetMaxErrorCount ¶
func (a *AlertRuleV3) GetMaxErrorCount() int
func (*AlertRuleV3) GetMaxTimeoutTps ¶
func (a *AlertRuleV3) GetMaxTimeoutTps() int
func (*AlertRuleV3) GetMaxTps ¶
func (a *AlertRuleV3) GetMaxTps() int
type AlertV3 ¶
type AlertV3 struct {
// contains filtered or unexported fields
}
func NewAlertV3 ¶
func NewAlertV3() *AlertV3
func (*AlertV3) AddAlertHandler ¶
func (a *AlertV3) AddAlertHandler(handler ...AlertHandler)
func (*AlertV3) Check ¶
func (a *AlertV3) Check(info *ApiStatInfo)
type ApiStatInfo ¶
type ApiStatInfo struct {
// contains filtered or unexported fields
}
func NewDefaultApiStatInfo ¶
func NewDefaultApiStatInfo() *ApiStatInfo
func (*ApiStatInfo) GetApi ¶
func (i *ApiStatInfo) GetApi() string
func (*ApiStatInfo) GetDurationOfSeconds ¶
func (i *ApiStatInfo) GetDurationOfSeconds() int
func (*ApiStatInfo) GetErrorCount ¶
func (i *ApiStatInfo) GetErrorCount() int
func (*ApiStatInfo) GetRequestCount ¶
func (i *ApiStatInfo) GetRequestCount() int
func (*ApiStatInfo) GetTimeoutCount ¶
func (i *ApiStatInfo) GetTimeoutCount() int
type ApolloConfigSource ¶
type ApolloConfigSource struct{}
func NewApolloConfigSource ¶
func NewApolloConfigSource() *ApolloConfigSource
type ApplicationContext ¶
type ApplicationContext struct {
// contains filtered or unexported fields
}
ApplicationContext 负责 Alert 的创建、组装(alertRule 和 notification 的依赖注入)、初始化(添加 handlers)工作
var (
ApplicationContextInstance *ApplicationContext // 单例
)
func GetApplicationContextInstance ¶
func GetApplicationContextInstance() *ApplicationContext
func NewApplicationContext ¶
func NewApplicationContext() *ApplicationContext
func (*ApplicationContext) GetAlert ¶
func (a *ApplicationContext) GetAlert() *AlertV3
type BaseHandler ¶
type BaseHandler struct {
// contains filtered or unexported fields
}
func NewBaseHandler ¶
func NewBaseHandler(rule *AlertRuleV3, notification *NotificationV3) *BaseHandler
type ConfigServer ¶
ConfigServer 对外暴露配置信息的类
func NewConfigServer ¶
func NewConfigServer(host string, port int) *ConfigServer
func (*ConfigServer) AddViewer ¶
func (c *ConfigServer) AddViewer(urlDirectory string, viewer Viewer)
func (*ConfigServer) Run ¶
func (c *ConfigServer) Run()
type ConfigSource ¶
type ConfigSource interface {
// contains filtered or unexported methods
}
ConfigSource 配置中心,如 Zookeeper/Apollo
type CustomerRepo ¶
type CustomerRepo struct {
// contains filtered or unexported fields
}
func (*CustomerRepo) CheckIfUserExisted ¶
func (r *CustomerRepo) CheckIfUserExisted(email, password string) (bool, error)
func (*CustomerRepo) GetUserByEmail ¶
func (r *CustomerRepo) GetUserByEmail(email string) (*Customer, error)
type CustomerRepoV2 ¶
type CustomerRepoV2 struct {
// contains filtered or unexported fields
}
func (*CustomerRepoV2) CheckIfUserExisted ¶
func (r *CustomerRepoV2) CheckIfUserExisted(email, password string) (bool, error)
func (CustomerRepoV2) GetUserByEmail ¶
func (r CustomerRepoV2) GetUserByEmail(email string) (*Customer, error)
type CustomerService ¶
type CustomerService struct {
CustomerRepo
}
func NewCustomerService ¶
func NewCustomerService(customerRepo CustomerRepo) *CustomerService
type CustomerServiceV2 ¶
type CustomerServiceV2 struct {
CustomerRepoV2
}
func NewCustomerServiceV2 ¶
func NewCustomerServiceV2(customerRepoV2 CustomerRepoV2) *CustomerServiceV2
type DefaultSerialization ¶
type DefaultSerialization struct{}
func (*DefaultSerialization) Deserialize ¶
func (d *DefaultSerialization) Deserialize(str string) interface{}
func (*DefaultSerialization) Serialize ¶
func (s *DefaultSerialization) Serialize(obj interface{}) string
type Demo ¶
type Demo struct {
MessageQueue // 基于接口而非实现编程
}
func NewDemo ¶
func NewDemo(messageQueue MessageQueue) *Demo
func (*Demo) SendNotification ¶
func (d *Demo) SendNotification(info Infos, formatter MessageFormatter)
type Deserializer ¶
type Deserializer struct{}
func (*Deserializer) Deserialize ¶
func (d *Deserializer) Deserialize(str string) interface{}
type Deserializers ¶
type Deserializers interface {
Deserialize(str string) interface{}
}
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
func NewDocument ¶
type DocumentFactory ¶
type DocumentFactory struct {
// contains filtered or unexported fields
}
DocumentFactory 通过工厂方法来创建Document
func NewDocumentFactory ¶
func NewDocumentFactory(downloader HtmlDownloader) *DocumentFactory
func (*DocumentFactory) CreateDocument ¶
func (f *DocumentFactory) CreateDocument(url string) (*Document, error)
type ErrorAlertHandler ¶
type ErrorAlertHandler struct {
*BaseHandler
}
func NewErrorAlertHandler ¶
func NewErrorAlertHandler(rule *AlertRuleV3, notification *NotificationV3) *ErrorAlertHandler
func (*ErrorAlertHandler) Check ¶
func (e *ErrorAlertHandler) Check(info *ApiStatInfo)
type HtmlDownloader ¶
type HtmlDownloader struct {
// contains filtered or unexported fields
}
func NewHtmlDownloader ¶
func NewHtmlDownloader(networkTransporter *NetworkTransporter) *HtmlDownloader
func (*HtmlDownloader) DownloadHTML ¶
func (d *HtmlDownloader) DownloadHTML(url string) (*HTML, error)
type InboxSender ¶
type InboxSender struct{}
InboxSender 站内信发送类
func NewInboxSender ¶
func NewInboxSender() *InboxSender
func (*InboxSender) Send ¶
func (i *InboxSender) Send(cellphone, message string)
type JsonMessageFormatter ¶
type JsonMessageFormatter struct{}
func (JsonMessageFormatter) Format ¶
func (j JsonMessageFormatter) Format()
type KafkaConfig ¶
type KafkaConfig struct {
ConfigSource
}
KafkaConfig Kafka配置类
func NewKafkaConfig ¶
func NewKafkaConfig(configSource ConfigSource) *KafkaConfig
type KafkaMessageQueue ¶
type KafkaMessageQueue struct{}
func (KafkaMessageQueue) Receive ¶
func (k KafkaMessageQueue) Receive()
func (KafkaMessageQueue) Send ¶
func (k KafkaMessageQueue) Send(formatter MessageFormatter)
type MessageFormatter ¶
type MessageFormatter interface {
Format()
}
type MessageQueue ¶
type MessageQueue interface { Receive() Send(formatter MessageFormatter) }
type MessageSender ¶
type MessageSender struct{}
func NewMessageSender ¶
func NewMessageSender() *MessageSender
func (MessageSender) Send ¶
func (m MessageSender) Send(cellphone, message string)
type MySQLConfig ¶
type MySQLConfig struct {
ConfigSource
}
MySQLConfig MySQL 配置类
func NewMySQLConfig ¶
func NewMySQLConfig(configSource ConfigSource) *MySQLConfig
func (*MySQLConfig) Output ¶
func (m *MySQLConfig) Output() map[string]string
func (*MySQLConfig) OutputInPlainText ¶
func (m *MySQLConfig) OutputInPlainText() string
type NetworkTransporter ¶
type NetworkTransporter struct{}
func NewNetworkTransporter ¶
func NewNetworkTransporter() *NetworkTransporter
type Notification ¶
type Notification struct{}
Notification 告警通知类,支持多种通知渠道:邮件,短信,微信,手机
func (*Notification) Notify ¶
func (n *Notification) Notify(level NotificationEmergencyLevel, info string)
type NotificationDI ¶
type NotificationDI struct {
*MessageSender
}
func NewNotificationDI ¶
func NewNotificationDI(messageSender *MessageSender) *NotificationDI
func (*NotificationDI) Notification ¶
func (n *NotificationDI) Notification(cellphone, message string)
type NotificationDIV2 ¶
type NotificationDIV2 struct {
MsgSender
}
func NewNotificationDIV2 ¶
func NewNotificationDIV2(msgSender MsgSender) *NotificationDIV2
func (*NotificationDIV2) Notification ¶
func (n *NotificationDIV2) Notification(cellphone, message string)
type NotificationEmergencyLevel ¶
type NotificationEmergencyLevel int
const ( SEVERE NotificationEmergencyLevel = iota // 严重 URGENCY // 紧急 NORMAL // 普通 TRIVIAL // 无关紧要 )
API 接口监控告警
type NotificationNoDI ¶
type NotificationNoDI struct {
*MessageSender
}
func NewNotificationNoDI ¶
func NewNotificationNoDI() *NotificationNoDI
func (*NotificationNoDI) SendMessage ¶
func (n *NotificationNoDI) SendMessage(cellphone, message string)
type NotificationV3 ¶
type NotificationV3 struct{}
func NewNotificationV3 ¶
func NewNotificationV3() *NotificationV3
func (NotificationV3) Notify ¶
func (n NotificationV3) Notify(level NotificationEmergencyLevel, info string)
type ProtoBufMessageFormatter ¶
type ProtoBufMessageFormatter struct{}
func (ProtoBufMessageFormatter) Format ¶
func (p ProtoBufMessageFormatter) Format()
type RedisConfig ¶
type RedisConfig struct { ConfigSource // contains filtered or unexported fields }
RedisConfig 配置类
func NewRedisConfig ¶
func NewRedisConfig(configSource ConfigSource) *RedisConfig
func (RedisConfig) Address ¶
func (r RedisConfig) Address() string
func (*RedisConfig) Output ¶
func (r *RedisConfig) Output() map[string]string
func (*RedisConfig) OutputInPlainText ¶
func (r *RedisConfig) OutputInPlainText() string
type RestrictedUserService ¶
type RestrictedUserServiceImpl ¶
type RestrictedUserServiceImpl struct{}
func (*RestrictedUserServiceImpl) DeleteUserByCellphone ¶
func (r *RestrictedUserServiceImpl) DeleteUserByCellphone(cellphone string)
func (*RestrictedUserServiceImpl) DeleteUserById ¶
func (r *RestrictedUserServiceImpl) DeleteUserById(id int64)
type RocketMQMessageQueue ¶
type RocketMQMessageQueue struct{}
func (RocketMQMessageQueue) Receive ¶
func (r RocketMQMessageQueue) Receive()
func (RocketMQMessageQueue) Send ¶
func (r RocketMQMessageQueue) Send(formatter MessageFormatter)
type SMSSender ¶
type SMSSender struct{}
SMSSender 短信发送类
func NewSMSSender ¶
func NewSMSSender() *SMSSender
type ScheduledUpdater ¶
type ScheduledUpdater struct { Updater // contains filtered or unexported fields }
ScheduledUpdater 代码热更新类
func NewScheduledUpdater ¶
type SecurityTransporter ¶
type SecurityTransporter struct { *Transporter // contains filtered or unexported fields }
func NewSecurityTransporter ¶
func NewSecurityTransporter(appId string, appToken string, transporter *Transporter) *SecurityTransporter
func (*SecurityTransporter) SendRequest ¶
func (s *SecurityTransporter) SendRequest(r *http.Request) error
SendRequest
- 修改前,如果 appId 或者 appToken 没有设置,不做校验 - 修改后,如果 appId 或者 appToken 没有设置,则直接抛出 NoAuthorizationRuntimeException 未授权异常
type Serialization ¶
type Serialization struct {
// contains filtered or unexported fields
}
func NewSerialization ¶
func NewSerialization() *Serialization
func (*Serialization) Deserialize ¶
func (s *Serialization) Deserialize(text string) map[string]string
type Serializations ¶
type Serializations struct { }
func (*Serializations) Deserialize ¶
func (s *Serializations) Deserialize(str string) interface{}
func (*Serializations) Serialize ¶
func (s *Serializations) Serialize(obj interface{}) string
type Serializer ¶
type Serializer struct{}
func (*Serializer) Serialize ¶
func (s *Serializer) Serialize(obj interface{}) string
type Serializers ¶
type Serializers interface {
Serialize(obj interface{}) string
}
type Stage1UserInfo ¶
type Stage1UserInfo struct {
// contains filtered or unexported fields
}
type Stage2UserAddress ¶
type Stage2UserAddress struct {
// contains filtered or unexported fields
}
type Stage2UserInfo ¶
type Stage2UserInfo struct {
// contains filtered or unexported fields
}
type Stage3Account ¶
type Stage3Account struct {
// contains filtered or unexported fields
}
type Stage3UserAddress ¶
type Stage3UserAddress struct {
// contains filtered or unexported fields
}
type Stage3UserInfo ¶
type Stage3UserInfo struct {
// contains filtered or unexported fields
}
type Statistics ¶
type Statistics struct {
// contains filtered or unexported fields
}
func Count ¶
func Count(dataSet []int64) *Statistics
type TimeoutAlertHandler ¶
type TimeoutAlertHandler struct {
*BaseHandler
}
func NewTimeoutAlertHandler ¶
func NewTimeoutAlertHandler(rule *AlertRuleV3, notification *NotificationV3) *TimeoutAlertHandler
func (*TimeoutAlertHandler) Check ¶
func (t *TimeoutAlertHandler) Check(info *ApiStatInfo)
type TpsAlertHandler ¶
type TpsAlertHandler struct {
*BaseHandler
}
func NewTpsAlertHandler ¶
func NewTpsAlertHandler(rule *AlertRuleV3, notification *NotificationV3) *TpsAlertHandler
func (*TpsAlertHandler) Check ¶
func (t *TpsAlertHandler) Check(info *ApiStatInfo)
type Transporter ¶
type Transporter struct {
// contains filtered or unexported fields
}
func NewTransporter ¶
func NewTransporter(httpClient *http.Client) *Transporter
func (*Transporter) SendRequest ¶
func (t *Transporter) SendRequest(r *http.Request) error
type UserAuthenticator ¶
type UserAuthenticator struct{}
func (*UserAuthenticator) Authenticate ¶
func (u *UserAuthenticator) Authenticate(username, password string) error
type UserAuthenticatorV2 ¶
type UserAuthenticatorV2 struct{}
func (*UserAuthenticatorV2) Authenticate ¶
func (u *UserAuthenticatorV2) Authenticate(username, password string) error
type UserService ¶
type UserServiceImpl ¶
type UserServiceImpl struct{}
func (*UserServiceImpl) GetUserInfoByCellphone ¶
func (u *UserServiceImpl) GetUserInfoByCellphone(cellphone string) UserInfo
func (*UserServiceImpl) GetUserInfoById ¶
func (u *UserServiceImpl) GetUserInfoById(id int64) UserInfo
func (*UserServiceImpl) Login ¶
func (u *UserServiceImpl) Login(cellphone, password string)
func (*UserServiceImpl) Register ¶
func (u *UserServiceImpl) Register(cellphone, password string)
type UserServiceTest ¶
type UserServiceTest struct{}
func (UserServiceTest) DoTest ¶
func (u UserServiceTest) DoTest() bool
type ZookeeperConfigSource ¶
type ZookeeperConfigSource struct{}
func NewZookeeperConfigSource ¶
func NewZookeeperConfigSource() *ZookeeperConfigSource
Source Files ¶
- dip-di.go
- dip-ioc.go
- dry-example-1.go
- dry-example-2.go
- dry-example-3.go
- isp-example-1.go
- isp-example-2.go
- isp-example-3.go
- kiss-example-1.go
- kiss-example-2.go
- lod-example-1.go
- lod-example-2.go
- lsp-example-1.go
- ocp-example-1.go
- ocp-example-2.go
- ocp-example-3.go
- ocp-example-4.go
- srp-example-1.go
- srp-example-2.go
Click to show internal directories.
Click to hide internal directories.