Documentation ¶
Index ¶
- Constants
- Variables
- func Close()
- func GetTotalCounts(ctx context.Context, q Querier, selectCountsSQL string) (int64, error)
- func Init(conf *conf.Config) (ok bool)
- func PingMySQL(ctx context.Context) error
- type Condition
- type Dao
- func (d *Dao) AllSendersCache(c context.Context, keywordID int64) ([]string, error)
- func (d *Dao) AreaSendersExpire(c context.Context, area string, senderID, dur int64) error
- func (d *Dao) Close()
- func (d *Dao) CntSendersCache(c context.Context, keywordID int64) (cnt int64, err error)
- func (d *Dao) DelCountRelatedCache(c context.Context, k *model.Keyword) error
- func (d *Dao) DelKeywordRelatedCache(c context.Context, ks []*model.Keyword) error
- func (d *Dao) DelRegexpCache(c context.Context) error
- func (d *Dao) DelRulesCache(c context.Context, area, limitType string) error
- func (d *Dao) GlobalLimitExpire(c context.Context, keywordID, dur int64) error
- func (d *Dao) GlobalLocalLimitCache(c context.Context, keywordID, oid int64) ([]int64, error)
- func (d *Dao) IncrAreaSendersCache(c context.Context, area string, senderID int64) (int64, error)
- func (d *Dao) IncrGlobalLimitCache(c context.Context, keywordID int64) (int64, error)
- func (d *Dao) IncrLocalLimitCache(c context.Context, keywordID, oid int64) (int64, error)
- func (d *Dao) IncrTotalLimitCache(c context.Context, keywordID int64) (int64, error)
- func (d *Dao) LocalLimitExpire(c context.Context, keywordID, oid, dur int64) error
- func (d *Dao) Ping(c context.Context) (err error)
- func (d *Dao) SendersCache(c context.Context, keywordID, limit, offset int64) ([]string, error)
- func (d *Dao) TotalLimitExpire(c context.Context, keywordID, dur int64) error
- func (d *Dao) ZaddSendersCache(c context.Context, keywordID, score, senderID int64) (int64, error)
- func (d *Dao) ZremSendersCache(c context.Context, keywordID int64, senderIDStr string) (int64, error)
- type Executer
- type Keyword
- type KeywordDao
- type KeywordDaoImpl
- func (kdi *KeywordDaoImpl) DeleteByIDs(ctx context.Context, ids []int64) ([]*Keyword, error)
- func (kdi *KeywordDaoImpl) GetByAreaAndContent(ctx context.Context, cond *Condition) (*Keyword, error)
- func (*KeywordDaoImpl) GetByAreaAndContents(ctx context.Context, cond *Condition) ([]*Keyword, error)
- func (*KeywordDaoImpl) GetByCond(ctx context.Context, cond *Condition) (keywords []*Keyword, totalCounts int64, err error)
- func (kdi *KeywordDaoImpl) GetByID(ctx context.Context, id int64) (*Keyword, error)
- func (*KeywordDaoImpl) GetByIDs(ctx context.Context, ids []int64) ([]*Keyword, error)
- func (*KeywordDaoImpl) GetByOffsetLimit(ctx context.Context, cond *Condition) (keywords []*Keyword, err error)
- func (*KeywordDaoImpl) GetRubbish(ctx context.Context, cond *Condition) (keywords []*Keyword, err error)
- func (kdi *KeywordDaoImpl) Insert(ctx context.Context, k *Keyword) (*Keyword, error)
- func (kdi *KeywordDaoImpl) Update(ctx context.Context, k *Keyword) (*Keyword, error)
- type KeywordTx
- type Querier
- type Regexp
- type RegexpDao
- type RegexpDaoImpl
- func (*RegexpDaoImpl) GetByAreaAndContent(ctx context.Context, cond *Condition) (*Regexp, error)
- func (*RegexpDaoImpl) GetByCond(ctx context.Context, cond *Condition) (regexps []*Regexp, totalCounts int64, err error)
- func (*RegexpDaoImpl) GetByContents(ctx context.Context, contents []string) ([]*Regexp, error)
- func (rdi *RegexpDaoImpl) GetByID(ctx context.Context, id int64) (*Regexp, error)
- func (*RegexpDaoImpl) GetByIDs(ctx context.Context, ids []int64) ([]*Regexp, error)
- func (rdi *RegexpDaoImpl) Insert(ctx context.Context, r *Regexp) (*Regexp, error)
- func (rdi *RegexpDaoImpl) Update(ctx context.Context, r *Regexp) (*Regexp, error)
- type RegexpTx
- type Rule
- type RuleDao
- type RuleDaoImpl
- func (*RuleDaoImpl) GetByArea(ctx context.Context, cond *Condition) ([]*Rule, error)
- func (*RuleDaoImpl) GetByAreaAndLimitType(ctx context.Context, cond *Condition) ([]*Rule, error)
- func (*RuleDaoImpl) GetByAreaAndTypeAndScope(ctx context.Context, cond *Condition) (*Rule, error)
- func (*RuleDaoImpl) GetByCond(ctx context.Context, cond *Condition) (rules []*Rule, totalCounts int64, err error)
- func (rdi *RuleDaoImpl) GetByID(ctx context.Context, id int64) (*Rule, error)
- func (*RuleDaoImpl) GetByIDs(ctx context.Context, ids []int64) ([]*Rule, error)
- func (rdi *RuleDaoImpl) Insert(ctx context.Context, r *Rule) (*Rule, error)
- func (rdi *RuleDaoImpl) Update(ctx context.Context, r *Rule) (*Rule, error)
- type RuleTx
- type Tx
Constants ¶
const ( // KeywordTagDefaultLimit . KeywordTagDefaultLimit int = iota // KeywordTagRestrictLimit . KeywordTagRestrictLimit // KeywordTagWhite . KeywordTagWhite // KeywordTagBlack . KeywordTagBlack )
const ( // AreaReply . AreaReply int = iota + 1 // AreaIMessage . AreaIMessage // AreaLiveDM . AreaLiveDM // AreaMainSiteDM . AreaMainSiteDM )
const ( // StateDefault . StateDefault int = iota // StateDeleted . StateDeleted )
const ( // OperationLimit . OperationLimit int = iota // OperationPutToWhiteList . OperationPutToWhiteList // OperationRestrictLimit . OperationRestrictLimit // OperationIgnore . OperationIgnore )
const ( // LimitTypeDefaultLimit . LimitTypeDefaultLimit int = iota // LimitTypeRestrictLimit . LimitTypeRestrictLimit // LimitTypeWhite . LimitTypeWhite // LimitTypeBlack . LimitTypeBlack )
const ( // LimitScopeGlobal . LimitScopeGlobal int = iota // LimitScopeLocal . LimitScopeLocal )
Variables ¶
Functions ¶
func GetTotalCounts ¶
GetTotalCounts .
Types ¶
type Condition ¶
type Condition struct { *util.Pagination Offset string Limit string Tags []string Contents []string Area string Search string State string HitCounts string Order, OrderBy string LimitType, LimitScope string StartTime, EndTime string LastModifiedTime string }
Condition .
type Dao ¶
type Dao struct {
// contains filtered or unexported fields
}
Dao .
func (*Dao) AllSendersCache ¶
AllSendersCache .
func (*Dao) AreaSendersExpire ¶
AreaSendersExpire .
func (*Dao) CntSendersCache ¶
CntSendersCache .
func (*Dao) DelCountRelatedCache ¶
DelCountRelatedCache .
func (*Dao) DelKeywordRelatedCache ¶
DelKeywordRelatedCache .
func (*Dao) DelRulesCache ¶
DelRulesCache .
func (*Dao) GlobalLimitExpire ¶
GlobalLimitExpire .
func (*Dao) GlobalLocalLimitCache ¶
GlobalLocalLimitCache .
func (*Dao) IncrAreaSendersCache ¶
IncrAreaSendersCache .
func (*Dao) IncrGlobalLimitCache ¶
IncrGlobalLimitCache .
func (*Dao) IncrLocalLimitCache ¶
IncrLocalLimitCache .
func (*Dao) IncrTotalLimitCache ¶
IncrTotalLimitCache .
func (*Dao) LocalLimitExpire ¶
LocalLimitExpire .
func (*Dao) SendersCache ¶
SendersCache .
func (*Dao) TotalLimitExpire ¶
TotalLimitExpire .
func (*Dao) ZaddSendersCache ¶
ZaddSendersCache insert into sortedset and return total counts of sorted set
type Executer ¶
type Executer interface {
Exec(ctx context.Context, SQL string, args ...interface{}) (sql.Result, error)
}
Executer .
type Keyword ¶
type Keyword struct { ID int64 `db:"id"` Area int `db:"area"` Tag int `db:"tag"` State int `db:"state"` HitCounts int64 `db:"hit_counts"` RegexpName string `db:"regexp_name"` Content string `db:"content"` OriginContent string `db:"origin_content"` CTime time.Time `db:"ctime"` MTime time.Time `db:"mtime"` }
Keyword .
type KeywordDao ¶
type KeywordDao interface { GetByID(context.Context, int64) (*Keyword, error) GetByIDs(context.Context, []int64) ([]*Keyword, error) GetByCond(context.Context, *Condition) ([]*Keyword, int64, error) GetByOffsetLimit(context.Context, *Condition) ([]*Keyword, error) GetByAreaAndContents(context.Context, *Condition) ([]*Keyword, error) GetByAreaAndContent(context.Context, *Condition) (*Keyword, error) GetRubbish(context.Context, *Condition) ([]*Keyword, error) Insert(context.Context, *Keyword) (*Keyword, error) Update(context.Context, *Keyword) (*Keyword, error) DeleteByIDs(context.Context, []int64) ([]*Keyword, error) }
KeywordDao .
type KeywordDaoImpl ¶
type KeywordDaoImpl struct{}
KeywordDaoImpl .
func (*KeywordDaoImpl) DeleteByIDs ¶
DeleteByIDs .
func (*KeywordDaoImpl) GetByAreaAndContent ¶
func (kdi *KeywordDaoImpl) GetByAreaAndContent(ctx context.Context, cond *Condition) (*Keyword, error)
GetByAreaAndContent .
func (*KeywordDaoImpl) GetByAreaAndContents ¶
func (*KeywordDaoImpl) GetByAreaAndContents(ctx context.Context, cond *Condition) ([]*Keyword, error)
GetByAreaAndContents .
func (*KeywordDaoImpl) GetByCond ¶
func (*KeywordDaoImpl) GetByCond(ctx context.Context, cond *Condition) (keywords []*Keyword, totalCounts int64, err error)
GetByCond .
func (*KeywordDaoImpl) GetByOffsetLimit ¶
func (*KeywordDaoImpl) GetByOffsetLimit(ctx context.Context, cond *Condition) (keywords []*Keyword, err error)
GetByOffsetLimit .
func (*KeywordDaoImpl) GetRubbish ¶
func (*KeywordDaoImpl) GetRubbish(ctx context.Context, cond *Condition) (keywords []*Keyword, err error)
GetRubbish .
type Querier ¶
type Querier interface { QueryRow(ctx context.Context, SQL string, args ...interface{}) *xsql.Row Query(ctx context.Context, SQL string, args ...interface{}) (*xsql.Rows, error) }
Querier .
type Regexp ¶
type Regexp struct { ID int64 `db:"id"` Area int `db:"area"` Name string `db:"name"` AdminID int64 `db:"admin_id"` Operation int `db:"operation"` Content string `db:"content"` State int `db:"state"` CTime time.Time `db:"ctime"` MTime time.Time `db:"mtime"` }
Regexp .
type RegexpDao ¶
type RegexpDao interface { GetByID(context.Context, int64) (*Regexp, error) GetByIDs(context.Context, []int64) ([]*Regexp, error) GetByCond(context.Context, *Condition) ([]*Regexp, int64, error) GetByAreaAndContent(context.Context, *Condition) (*Regexp, error) GetByContents(context.Context, []string) ([]*Regexp, error) Insert(context.Context, *Regexp) (*Regexp, error) Update(context.Context, *Regexp) (*Regexp, error) }
RegexpDao .
type RegexpDaoImpl ¶
type RegexpDaoImpl struct{}
RegexpDaoImpl .
func (*RegexpDaoImpl) GetByAreaAndContent ¶
GetByAreaAndContent .
func (*RegexpDaoImpl) GetByCond ¶
func (*RegexpDaoImpl) GetByCond(ctx context.Context, cond *Condition) (regexps []*Regexp, totalCounts int64, err error)
GetByCond .
func (*RegexpDaoImpl) GetByContents ¶
GetByContents .
type Rule ¶
type Rule struct { ID int64 `db:"id"` Area int `db:"area"` LimitType int `db:"limit_type"` LimitScope int `db:"limit_scope"` DurationSec int64 `db:"dur_sec"` AllowedCounts int64 `db:"allowed_counts"` CTime time.Time `db:"ctime"` MTime time.Time `db:"mtime"` }
Rule .
type RuleDao ¶
type RuleDao interface { GetByID(context.Context, int64) (*Rule, error) GetByIDs(context.Context, []int64) ([]*Rule, error) GetByCond(context.Context, *Condition) ([]*Rule, int64, error) GetByArea(context.Context, *Condition) ([]*Rule, error) GetByAreaAndTypeAndScope(context.Context, *Condition) (*Rule, error) GetByAreaAndLimitType(context.Context, *Condition) ([]*Rule, error) Insert(context.Context, *Rule) (*Rule, error) Update(context.Context, *Rule) (*Rule, error) }
RuleDao .
type RuleDaoImpl ¶
type RuleDaoImpl struct{}
RuleDaoImpl .
func (*RuleDaoImpl) GetByAreaAndLimitType ¶
GetByAreaAndLimitType .
func (*RuleDaoImpl) GetByAreaAndTypeAndScope ¶
GetByAreaAndTypeAndScope .
func (*RuleDaoImpl) GetByCond ¶
func (*RuleDaoImpl) GetByCond(ctx context.Context, cond *Condition) (rules []*Rule, totalCounts int64, err error)
GetByCond .