Documentation ¶
Index ¶
- func Batch(list *[]int64, batchSize int, retry int, params *model.BatchParam, ...)
- func NewFanGroups(config *conf.Config) (grp map[string]*FanGroup)
- func PromChanLen(name string, length int64)
- func PromError(name string)
- func PromInfo(name string)
- func PromInfoAdd(name string, value int64)
- type Dao
- func (d *Dao) AddFanLimitCache(c context.Context, fan int64, relationType int, value int, expire int32) (err error)
- func (d *Dao) AddFans(c context.Context, upper, fans int64, tp int) (err error)
- func (d *Dao) AddPerUpperLimitCache(c context.Context, fan int64, upper int64, value int, expire int32) (err error)
- func (d *Dao) AddStatisticsCache(c context.Context, ps *model.PushStatistic) (err error)
- func (d *Dao) AddUpperLimitCache(c context.Context, upper int64) (err error)
- func (d *Dao) BeginTx(c context.Context) (*xsql.Tx, error)
- func (d *Dao) Close() (err error)
- func (d *Dao) DelFans(c context.Context, upper, fans int64) (err error)
- func (d *Dao) DelSpecialAttention(c context.Context, upper, fans int64) (err error)
- func (d *Dao) DelStatisticsByID(ctx context.Context, min, max int64) (rows int64, err error)
- func (d *Dao) ExistUpperLimitCache(c context.Context, upper int64) (exist bool, err error)
- func (d *Dao) ExistsInBlacklist(ctx context.Context, upper int64, mids []int64) (exists, notExists []int64)
- func (d *Dao) ExistsInWhitelist(ctx context.Context, upper int64, mids []int64) (exists, notExists []int64)
- func (d *Dao) Fans(c context.Context, upper int64, isPGC bool) (res map[int64]int, err error)
- func (d *Dao) FansByActiveTime(hour int, fans *[]int64) (result []int64, excluded []int64)
- func (d *Dao) FansByHBase(upper int64, fanGroupKey string, fans *[]int64) (result []int64, excluded []int64)
- func (d *Dao) FansByProportion(upper int64, fans map[int64]int) (attentions []int64, specials []int64)
- func (d *Dao) FilterFans(fans *[]int64, params map[string]interface{}) (err error)
- func (d *Dao) GetFanLimitCache(c context.Context, fan int64, relationType int) (limit int, err error)
- func (d *Dao) GetPerUpperLimitCache(c context.Context, fan int64, upper int64) (limit int, err error)
- func (d *Dao) GetStatisticsCache(c context.Context) (ps *model.PushStatistic, err error)
- func (d *Dao) GetStatisticsIDRange(ctx context.Context, deadline time.Time) (min int64, max int64, err error)
- func (d *Dao) NoticeFans(fans *[]int64, params map[string]interface{}) (err error)
- func (d *Dao) Ping(c context.Context) (err error)
- func (d *Dao) SetSetting(c context.Context, mid int64, st *model.Setting) (err error)
- func (d *Dao) SetStatistics(ctx context.Context, st *model.PushStatistic) (rows int64, err error)
- func (d *Dao) Setting(c context.Context, mid int64) (st *model.Setting, err error)
- func (d *Dao) Settings(c context.Context, mids []int64) (res map[int64]*model.Setting, err error)
- func (d *Dao) SettingsAll(c context.Context, startID int64, endID int64, res *map[int64]*model.Setting) (err error)
- func (d *Dao) SettingsMaxID(c context.Context) (mx int64, err error)
- func (d *Dao) WechatMessage(content string) (err error)
- type FanGroup
- type Proportion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Batch ¶
func Batch(list *[]int64, batchSize int, retry int, params *model.BatchParam, f func(fans *[]int64, params map[string]interface{}) error)
Batch 批量处理
func NewFanGroups ¶
NewFanGroups 实例化,验证配置, 若配置错误,则panic
Types ¶
type Dao ¶
type Dao struct { UpperLimitExpire int32 FanGroups map[string]*FanGroup GroupOrder []string Proportions []Proportion ActiveDefaultTime map[int]int PushBusinessID string PushAuth string // contains filtered or unexported fields }
Dao .
func (*Dao) AddFanLimitCache ¶
func (d *Dao) AddFanLimitCache(c context.Context, fan int64, relationType int, value int, expire int32) (err error)
AddFanLimitCache 添加粉丝限制的缓存
func (*Dao) AddPerUpperLimitCache ¶
func (d *Dao) AddPerUpperLimitCache(c context.Context, fan int64, upper int64, value int, expire int32) (err error)
AddPerUpperLimitCache 添加粉丝每个up主的推送次数
func (*Dao) AddStatisticsCache ¶
AddStatisticsCache 添加统计数据到redis
func (*Dao) AddUpperLimitCache ¶
AddUpperLimitCache sets upper push limit cache.
func (*Dao) DelSpecialAttention ¶
DelSpecialAttention del special attention.
func (*Dao) DelStatisticsByID ¶
DelStatisticsByID delete by id range
func (*Dao) ExistUpperLimitCache ¶
ExistUpperLimitCache judge that whether upper push limit cache exists.
func (*Dao) ExistsInBlacklist ¶
func (d *Dao) ExistsInBlacklist(ctx context.Context, upper int64, mids []int64) (exists, notExists []int64)
ExistsInBlacklist 按黑名单过滤用户
func (*Dao) ExistsInWhitelist ¶
func (d *Dao) ExistsInWhitelist(ctx context.Context, upper int64, mids []int64) (exists, notExists []int64)
ExistsInWhitelist 按白名单过滤用户
func (*Dao) FansByActiveTime ¶
FansByActiveTime 配置了默认活跃时间,则批量过滤粉丝是否在活跃时间段内,否则不推送;未配置则不过滤活跃时间;若希望没有默认活跃时间但希望过滤活跃时间,配置成[0]
func (*Dao) FansByHBase ¶
func (d *Dao) FansByHBase(upper int64, fanGroupKey string, fans *[]int64) (result []int64, excluded []int64)
FansByHBase hbase表中查询粉丝所关联的up主,过滤up不在hbase结果中的粉丝
func (*Dao) FansByProportion ¶
func (d *Dao) FansByProportion(upper int64, fans map[int64]int) (attentions []int64, specials []int64)
FansByProportion 根据比例分配该关注类型的粉丝, 以全站所有用户作为分母
func (*Dao) FilterFans ¶
FilterFans 批量筛选
func (*Dao) GetFanLimitCache ¶
func (d *Dao) GetFanLimitCache(c context.Context, fan int64, relationType int) (limit int, err error)
GetFanLimitCache 读取粉丝限制的当前值
func (*Dao) GetPerUpperLimitCache ¶
func (d *Dao) GetPerUpperLimitCache(c context.Context, fan int64, upper int64) (limit int, err error)
GetPerUpperLimitCache 粉丝每个upper主的已推送次数
func (*Dao) GetStatisticsCache ¶
GetStatisticsCache 读取一条统计数据
func (*Dao) GetStatisticsIDRange ¶
func (d *Dao) GetStatisticsIDRange(ctx context.Context, deadline time.Time) (min int64, max int64, err error)
GetStatisticsIDRange get id range
func (*Dao) NoticeFans ¶
NoticeFans pushs the notification to fans.
func (*Dao) SetSetting ¶
SetSetting saves the setting.
func (*Dao) SetStatistics ¶
SetStatistics 插入一条记录
func (*Dao) SettingsAll ¶
func (d *Dao) SettingsAll(c context.Context, startID int64, endID int64, res *map[int64]*model.Setting) (err error)
SettingsAll gets all settings.
func (*Dao) SettingsMaxID ¶
SettingsMaxID get settings' total number by max(id)
func (*Dao) WechatMessage ¶
WechatMessage 发送企业微信消息
type FanGroup ¶
type FanGroup struct { // 组名 Name string // 粉丝与up主的关注关系 RelationType int Hitby string // 限制条数 Limit int PerUpperLimit int LimitExpire int32 // 本组获取粉丝的hbase信息 HBaseTable string HBaseFamily []string MsgTemplateDesc string MsgTemplate string }
FanGroup 粉丝分组
type Proportion ¶
Proportion 普通关注粉丝的灰度比例
func NewProportion ¶
func NewProportion(config []conf.Proportion) (ps []Proportion)
NewProportion new