dao

package
v0.0.0-...-83adff0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

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

func NewFanGroups(config *conf.Config) (grp map[string]*FanGroup)

NewFanGroups 实例化,验证配置, 若配置错误,则panic

func PromChanLen

func PromChanLen(name string, length int64)

PromChanLen channel length

func PromError

func PromError(name string)

PromError prom error

func PromInfo

func PromInfo(name string)

PromInfo add prom info

func PromInfoAdd

func PromInfoAdd(name string, value int64)

PromInfoAdd add prom info by value

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 New

func New(c *conf.Config) *Dao

New creates a push-service DAO instance.

func (*Dao) AddFanLimitCache

func (d *Dao) AddFanLimitCache(c context.Context, fan int64, relationType int, value int, expire int32) (err error)

AddFanLimitCache 添加粉丝限制的缓存

func (*Dao) AddFans

func (d *Dao) AddFans(c context.Context, upper, fans int64, tp int) (err error)

AddFans add upper's fans.

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

func (d *Dao) AddStatisticsCache(c context.Context, ps *model.PushStatistic) (err error)

AddStatisticsCache 添加统计数据到redis

func (*Dao) AddUpperLimitCache

func (d *Dao) AddUpperLimitCache(c context.Context, upper int64) (err error)

AddUpperLimitCache sets upper push limit cache.

func (*Dao) BeginTx

func (d *Dao) BeginTx(c context.Context) (*xsql.Tx, error)

BeginTx begin transaction.

func (*Dao) Close

func (d *Dao) Close() (err error)

Close dao.

func (*Dao) DelFans

func (d *Dao) DelFans(c context.Context, upper, fans int64) (err error)

DelFans del fans.

func (*Dao) DelSpecialAttention

func (d *Dao) DelSpecialAttention(c context.Context, upper, fans int64) (err error)

DelSpecialAttention del special attention.

func (*Dao) DelStatisticsByID

func (d *Dao) DelStatisticsByID(ctx context.Context, min, max int64) (rows int64, err error)

DelStatisticsByID delete by id range

func (*Dao) ExistUpperLimitCache

func (d *Dao) ExistUpperLimitCache(c context.Context, upper int64) (exist bool, err error)

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) Fans

func (d *Dao) Fans(c context.Context, upper int64, isPGC bool) (res map[int64]int, err error)

Fans gets the upper's fans.

func (*Dao) FansByActiveTime

func (d *Dao) FansByActiveTime(hour int, fans *[]int64) (result []int64, excluded []int64)

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

func (d *Dao) FilterFans(fans *[]int64, params map[string]interface{}) (err error)

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

func (d *Dao) GetStatisticsCache(c context.Context) (ps *model.PushStatistic, err error)

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

func (d *Dao) NoticeFans(fans *[]int64, params map[string]interface{}) (err error)

NoticeFans pushs the notification to fans.

func (*Dao) Ping

func (d *Dao) Ping(c context.Context) (err error)

Ping check connection status.

func (*Dao) SetSetting

func (d *Dao) SetSetting(c context.Context, mid int64, st *model.Setting) (err error)

SetSetting saves the setting.

func (*Dao) SetStatistics

func (d *Dao) SetStatistics(ctx context.Context, st *model.PushStatistic) (rows int64, err error)

SetStatistics 插入一条记录

func (*Dao) Setting

func (d *Dao) Setting(c context.Context, mid int64) (st *model.Setting, err error)

Setting gets the setting.

func (*Dao) Settings

func (d *Dao) Settings(c context.Context, mids []int64) (res map[int64]*model.Setting, err error)

Settings gets the settings.

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

func (d *Dao) SettingsMaxID(c context.Context) (mx int64, err error)

SettingsMaxID get settings' total number by max(id)

func (*Dao) WechatMessage

func (d *Dao) WechatMessage(content string) (err error)

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

type Proportion struct {
	// 粉丝的后2位的最值
	MinValue int
	MaxValue int
}

Proportion 普通关注粉丝的灰度比例

func NewProportion

func NewProportion(config []conf.Proportion) (ps []Proportion)

NewProportion new

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL