concern_manager

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists  = errors.New("already exists")
	ErrLengthMismatch = errors.New("length mismatch")
)
View Source
var ErrEmitQNotInit = errors.New("emit queue not enabled")

Functions

This section is empty.

Types

type AtSomeone added in v0.0.10

type AtSomeone struct {
	Ctype  concern.Type `json:"ctype"`
	AtList []int64      `json:"at_list"`
}

type GroupConcernAtConfig added in v0.0.10

type GroupConcernAtConfig struct {
	AtAll     concern.Type `json:"at_all"`
	AtSomeone []*AtSomeone `json:"at_someone"`
}

func (*GroupConcernAtConfig) CheckAtAll added in v0.0.10

func (g *GroupConcernAtConfig) CheckAtAll(ctype concern.Type) bool

func (*GroupConcernAtConfig) ClearAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) ClearAtSomeoneList(ctype concern.Type)

func (*GroupConcernAtConfig) GetAtSomeoneList added in v0.0.10

func (g *GroupConcernAtConfig) GetAtSomeoneList(ctype concern.Type) []int64

func (*GroupConcernAtConfig) MergeAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) MergeAtSomeoneList(ctype concern.Type, ids []int64)

func (*GroupConcernAtConfig) RemoveAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) RemoveAtSomeoneList(ctype concern.Type, ids []int64)

func (*GroupConcernAtConfig) SetAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) SetAtSomeoneList(ctype concern.Type, ids []int64)

type GroupConcernConfig added in v0.0.10

type GroupConcernConfig struct {
	GroupConcernAt     GroupConcernAtConfig     `json:"group_concern_at"`
	GroupConcernNotify GroupConcernNotifyConfig `json:"group_concern_notify"`
	// contains filtered or unexported fields
}

func NewGroupConcernConfigFromString added in v0.0.10

func NewGroupConcernConfigFromString(s string) (*GroupConcernConfig, error)

func (GroupConcernConfig) AtBeforeHook added in v0.0.13

func (d GroupConcernConfig) AtBeforeHook(notify concern.Notify) *HookResult

func (GroupConcernConfig) ShouldSendHook added in v0.0.13

func (d GroupConcernConfig) ShouldSendHook(notify concern.Notify) *HookResult

func (*GroupConcernConfig) ToString added in v0.0.10

func (g *GroupConcernConfig) ToString() string

type GroupConcernNotifyConfig added in v0.0.13

type GroupConcernNotifyConfig struct {
	TitleChangeNotify concern.Type `json:"title_change_notify"`
	OfflineNotify     concern.Type `json:"offline_notify"`
}

func (*GroupConcernNotifyConfig) CheckOfflineNotify added in v0.0.13

func (g *GroupConcernNotifyConfig) CheckOfflineNotify(ctype concern.Type) bool

func (*GroupConcernNotifyConfig) CheckTitleChangeNotify added in v0.0.13

func (g *GroupConcernNotifyConfig) CheckTitleChangeNotify(ctype concern.Type) bool

type Hook added in v0.0.13

type Hook interface {
	AtBeforeHook(notify concern.Notify) *HookResult
	ShouldSendHook(notify concern.Notify) *HookResult
}

type HookResult added in v0.0.13

type HookResult struct {
	Pass   bool
	Reason string
}

HookResult Pass是false的时候,要把具体失败的地方填入Reason

func (*HookResult) PassOrReason added in v0.0.13

func (h *HookResult) PassOrReason(pass bool, reason string)

type KeySet

type KeySet interface {
	GroupConcernStateKey(keys ...interface{}) string
	GroupConcernConfigKey(keys ...interface{}) string
	FreshKey(keys ...interface{}) string
	GroupAtAllMarkKey(keys ...interface{}) string
	ParseGroupConcernStateKey(key string) (groupCode int64, id interface{}, err error)
}

type StateManager

type StateManager struct {
	*localdb.ShortCut
	KeySet
	// contains filtered or unexported fields
}

func NewStateManager

func NewStateManager(keySet KeySet, useEmit bool) *StateManager

func (*StateManager) AddGroupConcern

func (c *StateManager) AddGroupConcern(groupCode int64, id interface{}, ctype concern.Type) (newCtype concern.Type, err error)

func (*StateManager) CheckAndSetAtAllMark added in v0.0.10

func (c *StateManager) CheckAndSetAtAllMark(groupCode int64, id interface{}) (result bool)

CheckAndSetAtAllMark 检查@全体标记是否过期,已过期返回true,并重置标记,否则返回false。 因为@全体有次数限制,并且较为恼人,故设置标记,两次@全体之间必须有间隔。

func (*StateManager) CheckConcern

func (c *StateManager) CheckConcern(id interface{}, ctype concern.Type) error

func (*StateManager) CheckGroupConcern

func (c *StateManager) CheckGroupConcern(groupCode int64, id interface{}, ctype concern.Type) error

func (*StateManager) EmitFreshCore

func (c *StateManager) EmitFreshCore(name string, fresher func(ctype concern.Type, id interface{}) error)

func (*StateManager) FreshAll

func (c *StateManager) FreshAll()

func (*StateManager) FreshCheck

func (c *StateManager) FreshCheck(id interface{}, setTTL bool) (result bool, err error)

func (*StateManager) FreshIndex

func (c *StateManager) FreshIndex(groups ...int64)

func (*StateManager) GetConcern

func (c *StateManager) GetConcern(id interface{}) (result concern.Type, err error)

GetConcern return the concern.Type combined from all group for a id

func (*StateManager) GetGroupConcern

func (c *StateManager) GetGroupConcern(groupCode int64, id interface{}) (result concern.Type, err error)

GetGroupConcern return the concern.Type in specific group for a id

func (*StateManager) GetGroupConcernConfig added in v0.0.10

func (c *StateManager) GetGroupConcernConfig(groupCode int64, id interface{}) (concernConfig *GroupConcernConfig)

GetGroupConcernConfig always return non-nil

func (*StateManager) GroupTypeById

func (c *StateManager) GroupTypeById(ids []interface{}, types []concern.Type) ([]interface{}, []concern.Type, error)

func (*StateManager) List

func (c *StateManager) List(filter func(groupCode int64, id interface{}, p concern.Type) bool) (idGroups []int64, ids []interface{}, idTypes []concern.Type, err error)

func (*StateManager) ListByGroup

func (c *StateManager) ListByGroup(groupCode int64, filter func(id interface{}, p concern.Type) bool) (ids []interface{}, idTypes []concern.Type, err error)

func (*StateManager) ListIds added in v0.0.8

func (c *StateManager) ListIds() (ids []interface{}, err error)

func (*StateManager) OperateGroupConcernConfig added in v0.0.10

func (c *StateManager) OperateGroupConcernConfig(groupCode int64, id interface{}, f func(concernConfig *GroupConcernConfig) bool) error

OperateGroupConcernConfig 在一个rw事务中获取GroupConcernConfig并交给函数,如果返回true,就保存GroupConcernConfig,否则就回滚。

func (*StateManager) RemoveAllByGroupCode

func (c *StateManager) RemoveAllByGroupCode(groupCode int64) (err error)

func (*StateManager) RemoveAllById

func (c *StateManager) RemoveAllById(_id interface{}) (err error)

func (*StateManager) RemoveGroupConcern

func (c *StateManager) RemoveGroupConcern(groupCode int64, id interface{}, ctype concern.Type) (newCtype concern.Type, err error)

func (*StateManager) Start

func (c *StateManager) Start() error

Jump to

Keyboard shortcuts

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