Documentation ¶
Overview ¶
Package events implements channel based pubsub pattern. The design goals are:
- fully functional and safety
- simple to understand and use
- make the code readable, maintainable and minimalistic
Index ¶
- Constants
- func Close(e *Event)
- func ClusterCreatedLogWriter(e *Event)
- func ClusterCreatedStatisticsUpdater(e *Event)
- func ClusterGrantedLogWriter(e *Event)
- func ClusterRemovedLogWriter(e *Event)
- func ClusterRemovedStatisticsUpdater(e *Event)
- func ClusterRevokedLogWriter(e *Event)
- func ClusterStatusPatchedLogWriter(e *Event)
- func ClusterUpdatedLogWriter(e *Event)
- func CommentCreatedLogWriter(e *Event)
- func CommentCreatedMailSender(e *Event)
- func CommentCreatedStatisticsUpdater(e *Event)
- func CronCancelledLogWriter(e *Event)
- func CronCancelledMailSender(e *Event)
- func EmailUpdatedLogWriter(e *Event)
- func EmailUpdatedMailSender(e *Event)
- func Fire(topic string, args interface{})
- func FireSync(topic string, args interface{})
- func LogWriter(userID uint, operation string) error
- func MailSender(args MailSendArgs)
- func Once(e *Event)
- func OptionValuePatchedLogWriter(e *Event)
- func PasswordUpdatedLogWriter(e *Event)
- func PasswordUpdatedMailSender(e *Event)
- func ProfileUpdatedLogWriter(e *Event)
- func ProfileUpdatedMailSender(e *Event)
- func QueryAnalyzedLogWriter(e *Event)
- func QueryAnalyzedStatisticsUpdater(e *Event)
- func QueryCreatedLogWriter(e *Event)
- func QueryCreatedStatisticsUpdater(e *Event)
- func QueryRewritedLogWriter(e *Event)
- func QueryRewritedStatisticsUpdater(e *Event)
- func Reset(e *Event)
- func ReviewerGrantedLogWriter(e *Event)
- func ReviewerRevokedLogWriter(e *Event)
- func RoleGrantedLogWriter(e *Event)
- func RoleRevokedLogWriter(e *Event)
- func RuleBitwisePatchedLogWriter(e *Event)
- func RuleValuesPatchedLogWriter(e *Event)
- func Skip(e *Event)
- func Sync(e *Event)
- func TicketCreatedLogWriter(e *Event)
- func TicketCreatedMailSender(e *Event)
- func TicketCreatedStatisticUpdater(e *Event)
- func TicketExecutedLogWriter(e *Event)
- func TicketExecutedMailSender(e *Event)
- func TicketFailedLogWriter(e *Event)
- func TicketFailedMailSender(e *Event)
- func TicketRemovedLogWriter(e *Event)
- func TicketRemovedMailSender(e *Event)
- func TicketRemovedStatisticsUpdater(e *Event)
- func TicketScheduledLogWriter(e *Event)
- func TicketScheduledMailSender(e *Event)
- func TicketStatusPatchedLogWriter(e *Event)
- func TicketStatusPatchedMailSender(e *Event)
- func TicketUpdatedLogWriter(e *Event)
- func TicketUpdatedMailSender(e *Event)
- func UpdateStatistics(group string, key string, value float64) error
- func UserCreatedLogWriter(e *Event)
- func UserCreatedMailSender(e *Event)
- func UserCreatedStatisticsUpdater(e *Event)
- func UserLogoutLogWriter(e *Event)
- func UserRegisteredLogWriter(e *Event)
- func UserRegisteredMailSender(e *Event)
- func UserRegisteredStatisticsUpdater(e *Event)
- func UserSignedInLogWriter(e *Event)
- func UserSignedInStatisticsUpdater(e *Event)
- func UserStatusPatchedLogWriter(e *Event)
- func UserUpdatedLogWriter(e *Event)
- func Void(e *Event)
- type ClusterCreatedArgs
- type ClusterGrantedArgs
- type ClusterRemovedArgs
- type ClusterRevokedArgs
- type ClusterStatusPatchedArgs
- type ClusterUpdatedArgs
- type CommentCreatedArgs
- type CronCancelledArgs
- type EmailUpdatedArgs
- type Emitter
- func (e *Emitter) Emit(topic string, args interface{}) chan struct{}
- func (e *Emitter) Listeners(topic string) []<-chan Event
- func (e *Emitter) Off(topic string, channels ...<-chan Event)
- func (e *Emitter) On(topic string, middlewares ...func(*Event)) <-chan Event
- func (e *Emitter) Once(topic string, middlewares ...func(*Event)) <-chan Event
- func (e *Emitter) Topics() []string
- func (e *Emitter) Use(pattern string, middlewares ...func(*Event))
- type Event
- type Flag
- type Group
- type MailSendArgs
- type Matcher
- type OptionValuePatchedArgs
- type PasswordUpdatedArgs
- type PathMatch
- type ProfileUpdatedArgs
- type QueryAnalyzedArgs
- type QueryCreatedArgs
- type QueryRewritedArgs
- type ReviewerGrantedArgs
- type ReviewerRevokedArgs
- type RoleGrantedArgs
- type RoleRevokedArgs
- type RuleBitwisePatchedArgs
- type RuleValuesPatchedArgs
- type TicketCreatedArgs
- type TicketExecutedArgs
- type TicketFailedArgs
- type TicketRemovedArgs
- type TicketScheduledArgs
- type TicketStatusPatchedArgs
- type TicketUpdatedArgs
- type UserCreatedArgs
- type UserLogoutArgs
- type UserRegisteredArgs
- type UserSignedInArgs
- type UserStatusPatchedArgs
- type UserUpdatedArgs
Constants ¶
const ( EventTicketCreated = "OnTicketCreated" // 工单创建成功 - PASS EventTicketUpdated = "OnTicketUpdated" // 工单修改成功 - PASS EventTicketRemoved = "OnTicketRemoved" // 工单删除成功 - PASS EventTicketExecuted = "OnTicketExecuted" // 工单执行成功 EventTicketFailed = "OnTicketFailed" // 工单执行失败 EventTicketScheduled = "OnTicketScheduled" // 工单预约成功 EventTicketStatusPatched = "OnTicketStatusPatched" // 工单状态修改成功 EventQueryCreated = "OnQueryCreated" // 创建执行查询 - PASS EventQueryAnalyzed = "OnQueryAnalyzed" // 查询分析成功 - PASS EventQueryRewrited = "OnQueryRewrited" // 查询重写成功 - PASS EventUserRegistered = "OnUserReigstered" // 用户注册成功 - PASS EventUserSignedIn = "OnUserSignedIn" // 用户登录成功 - PASS EventPasswordUpdated = "OnPasswordUpdated" // 用户修改密码成功 - PASS EventEmailUpdated = "OnEmailUpdated" // 用户修改账号成功 - PASS EventProfileUpdated = "OnProfileUpdated" // 用户修改个人资料成功 - PASS EventUserLogout = "OnUserLogout" // 用户退出登录 - PASS EventUserCreated = "OnUserCreated" // 用户创建成功 - PASS EventUserUpdated = "OnUserUpdated" // 用户更新成功 - PASS EventUserStatusPatched = "OnUserStatusPatched" // 用户状态修改成功 - PASS EventRuleValuesPatched = "OnRuleValuesPatched" // 规则取值修改成功 - PASS EventRuleBitwisePatched = "OnRuleBitwisePatched" // 规则执行标志修改成功 - PASS EventOptionValuePatched = "OnOptionValuePatched" // 系统选项修改成功 - PASS EventCommentCreated = "OnCommentCreated" // 添加审核意见成功 - PASS EventCronCancelled = "OnCronCancelled" // 计划任务取消成功 EventClusterStatusPatched = "OnClusterStatusPatched" // 群集状态修改成功 - PASS EventClusterRemoved = "OnClusterRemoved" // 群集移除成功 - PASS EventClusterUpdated = "OnClusterUpdated" // 群集修改成功 - PASS EventClusterCreated = "OnClusterCreated" // 群集创建成功 - PASS EventReviewerGranted = "OnReviewerGranted" // 授权审核人成功 - PASS EventReviewerRevoked = "OnReviewerRevoked" // 收回审核人成功 - PASS EventClusterGranted = "OnClusterGranted" // 授权群集成功 - PASS EventClusterRevoked = "OnClusterRevoked" // 收回群集成功 - PASS EventRoleGranted = "OnRoleGranted" // 授权角色成功 - PASS EventRoleRevoked = "OnRoleRevoked" // 收回角色成功 - PASS )
事件列表
Variables ¶
This section is empty.
Functions ¶
func ClusterCreatedLogWriter ¶
func ClusterCreatedLogWriter(e *Event)
ClusterCreatedLogWriter 群集创建日志记录
func ClusterCreatedStatisticsUpdater ¶
func ClusterCreatedStatisticsUpdater(e *Event)
ClusterCreatedStatisticsUpdater 群集创建统计更新
func ClusterGrantedLogWriter ¶
func ClusterGrantedLogWriter(e *Event)
ClusterGrantedLogWriter 授权群集日志记录
func ClusterRemovedLogWriter ¶
func ClusterRemovedLogWriter(e *Event)
ClusterRemovedLogWriter 群集移除日志记录
func ClusterRemovedStatisticsUpdater ¶
func ClusterRemovedStatisticsUpdater(e *Event)
ClusterRemovedStatisticsUpdater 群集移除统计更新
func ClusterRevokedLogWriter ¶
func ClusterRevokedLogWriter(e *Event)
ClusterRevokedLogWriter 收回群集日志记录
func ClusterStatusPatchedLogWriter ¶
func ClusterStatusPatchedLogWriter(e *Event)
ClusterStatusPatchedLogWriter 群集状态更新日志记录
func ClusterUpdatedLogWriter ¶
func ClusterUpdatedLogWriter(e *Event)
ClusterUpdatedLogWriter 群集更新日志记录
func CommentCreatedLogWriter ¶
func CommentCreatedLogWriter(e *Event)
CommentCreatedLogWriter 审核意见添加成功日记记录
func CommentCreatedMailSender ¶
func CommentCreatedMailSender(e *Event)
CommentCreatedMailSender 审核意见添加成功邮件通知
func CommentCreatedStatisticsUpdater ¶
func CommentCreatedStatisticsUpdater(e *Event)
CommentCreatedStatisticsUpdater 审核意见添加成功统计更新
func CronCancelledLogWriter ¶
func CronCancelledLogWriter(e *Event)
CronCancelledLogWriter 工单预约取消日志记录
func CronCancelledMailSender ¶
func CronCancelledMailSender(e *Event)
CronCancelledMailSender 工单预约取消邮件通知
func OptionValuePatchedLogWriter ¶
func OptionValuePatchedLogWriter(e *Event)
OptionValuePatchedLogWriter 系统选项更新日志记录
func PasswordUpdatedLogWriter ¶
func PasswordUpdatedLogWriter(e *Event)
PasswordUpdatedLogWriter 密码更新日志记录
func PasswordUpdatedMailSender ¶
func PasswordUpdatedMailSender(e *Event)
PasswordUpdatedMailSender 密码更新邮件通知
func ProfileUpdatedLogWriter ¶
func ProfileUpdatedLogWriter(e *Event)
ProfileUpdatedLogWriter 用户信息更新日志记录
func ProfileUpdatedMailSender ¶
func ProfileUpdatedMailSender(e *Event)
ProfileUpdatedMailSender 用户信息更新邮件通知
func QueryAnalyzedLogWriter ¶
func QueryAnalyzedLogWriter(e *Event)
QueryAnalyzedLogWriter 查询分析的日志记录
func QueryAnalyzedStatisticsUpdater ¶
func QueryAnalyzedStatisticsUpdater(e *Event)
QueryAnalyzedStatisticsUpdater 查询分析的统计更新
func QueryCreatedStatisticsUpdater ¶
func QueryCreatedStatisticsUpdater(e *Event)
QueryCreatedStatisticsUpdater 创建查询的统计更新
func QueryRewritedLogWriter ¶
func QueryRewritedLogWriter(e *Event)
QueryRewritedLogWriter 查询重写的日志记录
func QueryRewritedStatisticsUpdater ¶
func QueryRewritedStatisticsUpdater(e *Event)
QueryRewritedStatisticsUpdater 查询重写的统计更新
func ReviewerGrantedLogWriter ¶
func ReviewerGrantedLogWriter(e *Event)
ReviewerGrantedLogWriter 授权审核人日志记录
func ReviewerRevokedLogWriter ¶
func ReviewerRevokedLogWriter(e *Event)
ReviewerRevokedLogWriter 收回审核人日志记录
func RuleBitwisePatchedLogWriter ¶
func RuleBitwisePatchedLogWriter(e *Event)
RuleBitwisePatchedLogWriter 规则状态位更新成功日志记录
func RuleValuesPatchedLogWriter ¶
func RuleValuesPatchedLogWriter(e *Event)
RuleValuesPatchedLogWriter 规则值更新成功日志记录
func TicketCreatedLogWriter ¶
func TicketCreatedLogWriter(e *Event)
TicketCreatedLogWriter 创建工单的日志记录
func TicketCreatedMailSender ¶
func TicketCreatedMailSender(e *Event)
TicketCreatedMailSender 创建工单的邮件通知
func TicketCreatedStatisticUpdater ¶
func TicketCreatedStatisticUpdater(e *Event)
TicketCreatedStatisticUpdater 创建工单的统计更新
func TicketExecutedLogWriter ¶
func TicketExecutedLogWriter(e *Event)
TicketExecutedLogWriter 工单执行成功的日志记录
func TicketExecutedMailSender ¶
func TicketExecutedMailSender(e *Event)
TicketExecutedMailSender 工单执行成功的邮件通知
func TicketFailedMailSender ¶
func TicketFailedMailSender(e *Event)
TicketFailedMailSender 工单执行失败的邮件通知
func TicketRemovedLogWriter ¶
func TicketRemovedLogWriter(e *Event)
TicketRemovedLogWriter 删除工单的日志记录
func TicketRemovedMailSender ¶
func TicketRemovedMailSender(e *Event)
TicketRemovedMailSender 删除工单的邮件通知
func TicketRemovedStatisticsUpdater ¶
func TicketRemovedStatisticsUpdater(e *Event)
TicketRemovedStatisticsUpdater 删除工单的统计更新
func TicketScheduledLogWriter ¶
func TicketScheduledLogWriter(e *Event)
TicketScheduledLogWriter 工单预约成功的日志记录
func TicketScheduledMailSender ¶
func TicketScheduledMailSender(e *Event)
TicketScheduledMailSender 工单预约成功的邮件通知
func TicketStatusPatchedLogWriter ¶
func TicketStatusPatchedLogWriter(e *Event)
TicketStatusPatchedLogWriter 工单状态更新成功日志记录
func TicketStatusPatchedMailSender ¶
func TicketStatusPatchedMailSender(e *Event)
TicketStatusPatchedMailSender 工单状态更新成功邮件通知
func TicketUpdatedMailSender ¶
func TicketUpdatedMailSender(e *Event)
TicketUpdatedMailSender 更新工单的邮件通知
func UpdateStatistics ¶
UpdateStatistics 统计信息更新
func UserCreatedStatisticsUpdater ¶
func UserCreatedStatisticsUpdater(e *Event)
UserCreatedStatisticsUpdater 用户创建成功统计更新
func UserRegisteredLogWriter ¶
func UserRegisteredLogWriter(e *Event)
UserRegisteredLogWriter 用户注册的日志记录
func UserRegisteredMailSender ¶
func UserRegisteredMailSender(e *Event)
UserRegisteredMailSender 用户注册的邮件通知(激活)
func UserRegisteredStatisticsUpdater ¶
func UserRegisteredStatisticsUpdater(e *Event)
UserRegisteredStatisticsUpdater 用户注册的统计更新
func UserSignedInStatisticsUpdater ¶
func UserSignedInStatisticsUpdater(e *Event)
UserSignedInStatisticsUpdater 用户登录的统计更新
func UserStatusPatchedLogWriter ¶
func UserStatusPatchedLogWriter(e *Event)
UserStatusPatchedLogWriter 用户状态更新成功日志记录
Types ¶
type ClusterCreatedArgs ¶
ClusterCreatedArgs 群集创建事件参数
type ClusterGrantedArgs ¶
ClusterGrantedArgs 授权群集事件参数
type ClusterRemovedArgs ¶
ClusterRemovedArgs 群集移除事件参数
type ClusterRevokedArgs ¶
ClusterRevokedArgs 收回群集事件参数
type ClusterStatusPatchedArgs ¶
ClusterStatusPatchedArgs 群集状态更新事件参数
type ClusterUpdatedArgs ¶
ClusterUpdatedArgs 群集更新事件参数
type CommentCreatedArgs ¶
CommentCreatedArgs 审核意见添加成功事件参数
type CronCancelledArgs ¶
CronCancelledArgs 工单预约取消事件参数
type EmailUpdatedArgs ¶
EmailUpdatedArgs 账号更新成功事件参数
type Emitter ¶
Emitter is a struct that allows to emit, receive event, close receiver channel, get info about topics and listeners
func New ¶
New returns just created Emitter struct. Capacity argument will be used to create channels with given capacity optionally include a matcher to use or nil to use the default which implements path.Match() from the system library
func (*Emitter) Emit ¶
Emit emits an event with the rest arguments to all listeners which were covered by topic(it can be pattern).
func (*Emitter) Listeners ¶
Listeners returns slice of listeners which were covered by topic(it can be pattern) and error if pattern is invalid.
func (*Emitter) Off ¶
Off unsubscribes all listeners which were covered by topic, it can be pattern as well.
func (*Emitter) On ¶
On returns a channel that will receive events. As optional second argument it takes middlewares.
type Event ¶
Event is a structure to send events contains some helpers to cast primitive types easily.
type Flag ¶
type Flag int
Flag used to describe what behavior do you expect.
const ( // FlagReset only to clear previously defined flags. // Example: // ee.Use("*", Reset) // clears flags for this pattern FlagReset Flag = 0 // FlagOnce indicates to remove the listener after first sending. FlagOnce Flag = 1 << iota // FlagVoid indicates to skip sending. FlagVoid // FlagSkip indicates to skip sending if channel is blocked. FlagSkip // FlagClose indicates to drop listener if channel is blocked. FlagClose // FlagSync indicates to send an event synchronously. FlagSync )
type Group ¶
type Group struct { // Cap is capacity to create new channel Cap uint // contains filtered or unexported fields }
Group marges given subscribed channels into on subscribed channel
func (*Group) Flush ¶
func (g *Group) Flush()
Flush reset the group to the initial state. All references will dropped.
type MailSendArgs ¶
MailSendArgs 邮件发送事件参数
type Matcher ¶
Matcher interface describes a pattern matcher that determines if the name is included as a subset of the pattern returns true,nil upon success
func DefaultMatcher ¶
func DefaultMatcher() Matcher
DefaultMatcher returns the standard Matcher (PathMatcher)
type OptionValuePatchedArgs ¶
OptionValuePatchedArgs 系统选项更新事件参数
type PasswordUpdatedArgs ¶
PasswordUpdatedArgs 密码更新成功事件参数
type PathMatch ¶
type PathMatch struct { }
PathMatch is a Matcher implementation of the system path.Match function
type ProfileUpdatedArgs ¶
ProfileUpdatedArgs 用户信息更新成功事件参数
type QueryAnalyzedArgs ¶
QueryAnalyzedArgs 查询分析成功事件参数
type QueryCreatedArgs ¶
QueryCreatedArgs 查询创建成功事件参数
type QueryRewritedArgs ¶
QueryRewritedArgs 查询分析成功事件参数
type ReviewerGrantedArgs ¶
ReviewerGrantedArgs 授权审核人事件参数
type ReviewerRevokedArgs ¶
ReviewerRevokedArgs 收回审核人事件参数
type RoleGrantedArgs ¶
RoleGrantedArgs 授权角色事件参数
type RoleRevokedArgs ¶
RoleRevokedArgs 收回角色事件参数
type RuleBitwisePatchedArgs ¶
RuleBitwisePatchedArgs 规则状态位更新成功事件参数
type RuleValuesPatchedArgs ¶
RuleValuesPatchedArgs 规则值更新成功事件参数
type TicketCreatedArgs ¶
TicketCreatedArgs 工单创建成功事件参数
type TicketExecutedArgs ¶
TicketExecutedArgs 工单执行成功事件参数
type TicketFailedArgs ¶
TicketFailedArgs 工单执行失败事件参数
type TicketRemovedArgs ¶
TicketRemovedArgs 工单删除成功事件参数
type TicketScheduledArgs ¶
type TicketScheduledArgs struct { User models.User Ticket models.Ticket Cluster models.Cluster Cron models.Cron }
TicketScheduledArgs 工单预约成功事件参数
type TicketStatusPatchedArgs ¶
type TicketStatusPatchedArgs struct { User models.User Ticket models.Ticket Cluster models.Cluster }
TicketStatusPatchedArgs 工单状态更新成功事件参数
type TicketUpdatedArgs ¶
TicketUpdatedArgs 工单更新成功事件参数
type UserCreatedArgs ¶
UserCreatedArgs 用户创建成功事件参数
type UserRegisteredArgs ¶
UserRegisteredArgs 用户注册成功事件参数
type UserSignedInArgs ¶
UserSignedInArgs 用户登录成功事件参数
type UserStatusPatchedArgs ¶
UserStatusPatchedArgs 用户状态更新成功事件参数