Help us shape the future of Go! Take the 2026 Go Developer Survey

notification

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish

func Publish(ctx context.Context, message Message) (int64, error)

Publish 调用当前进程注册的消息发布方。

func SetDefaultPublisher

func SetDefaultPublisher(publisher Publisher)

SetDefaultPublisher 设置当前进程默认站内信发布方。

func ValidateProviderConfig added in v0.0.64

func ValidateProviderConfig(provider *models.BaseMessageProvider, sharedCache cache.Cache) error

ValidateProviderConfig 校验消息 Provider 配置是否可以创建发送器。

Types

type Audience

type Audience struct {
	// Type 是受众类型。
	Type basev1.MessageAudienceType
	// ID 是受众编号,租户全员时为 0。
	ID int64
	// IncludeChildren 表示部门受众是否包含子部门。
	IncludeChildren bool
}

Audience 描述站内信的单项受众规则。

type Message

type Message struct {
	// TenantID 是消息所属租户编号。
	TenantID int64
	// CategoryCode 是消息分类稳定编码。
	CategoryCode string
	// Title 是消息标题。
	Title string
	// Content 是消息正文。
	Content string
	// ContentFormat 是消息正文格式。
	ContentFormat basev1.MessageContentFormat
	// Priority 是消息优先级。
	Priority basev1.MessagePriority
	// ActionType 是消息动作类型。
	ActionType basev1.MessageActionType
	// ActionTarget 是消息动作目标。
	ActionTarget string
	// ActionParams 是消息动作参数 JSON。
	ActionParams string
	// Audiences 是消息受众规则。
	Audiences []Audience
	// Source 是业务来源标识。
	Source string
	// IdempotencyKey 是租户内来源幂等键。
	IdempotencyKey string
	// SenderName 是发送者显示名称。
	SenderName string
	// ExpiresAt 是消息过期时间戳,单位为毫秒。
	ExpiresAt int64
}

Message 描述业务模块发布消息所需的内容和受众。

type ProviderManager added in v0.0.64

type ProviderManager struct {
	// contains filtered or unexported fields
}

ProviderManager 管理从数据库加载的消息 Provider 发送器。

func NewProviderManager added in v0.0.64

func NewProviderManager(baseCase *biz.BaseCase) *ProviderManager

NewProviderManager 创建消息 Provider 运行时管理器。

func (*ProviderManager) Send added in v0.0.64

Send 按数据库 Provider ID 发送一条外部通知。

type Publisher

type Publisher interface {
	Publish(context.Context, Message) (int64, error)
}

Publisher 定义业务模块发布消息的能力。

type PublisherFunc

type PublisherFunc func(context.Context, Message) (int64, error)

PublisherFunc 将函数适配为 Publisher。

func (PublisherFunc) Publish

func (f PublisherFunc) Publish(ctx context.Context, message Message) (int64, error)

Publish 调用适配的发布函数。

Jump to

Keyboard shortcuts

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