Documentation ¶
Index ¶
- Constants
- func LoggingMiddleware(log *slog.Logger) asynq.MiddlewareFunc
- func TgCmdMiddleware(siteRepo repository.ReadRepository[*entity.Site], ...) asynq.MiddlewareFunc
- type Client
- func (c *Client) Close() error
- func (c *Client) Enqueue(ctx context.Context, name string, data any, opts ...asynq.Option) error
- func (c *Client) EnqueueTgCmd(ctx context.Context, message *tgbotapi.Message, updateID int)
- func (c *Client) EnqueueTgMemberEdit(ctx context.Context, member *tgbotapi.ChatMemberUpdated, updateID int)
- func (c *Client) EnqueueTgMemberNew(ctx context.Context, member *tgbotapi.Chat, updateID int)
- type HandlerJobFeed
- type HandlerJobSitemap
- type HandlerTgChat
- type HandlerTgCmdOff
- type HandlerTgCmdOn
- type HandlerTgCmdRumors
- type HandlerTgCmdSites
- type HandlerTgCmdSub
- type Meta
- type Metrics
- type Plugin
- func (p *Plugin) Client() common.Client
- func (p *Plugin) Init(cfg config.Configurer, uow common.UnitOfWork, redisConnOpt asynq.RedisConnOpt, ...) error
- func (p *Plugin) Name() string
- func (p *Plugin) Provides() []*dep.Out
- func (p *Plugin) Serve() chan error
- func (p *Plugin) Stop(ctx context.Context) (err error)
- type PostEnqueueFunc
- type PreEnqueueFunc
- type Scheduler
- type SchedulerConfig
- type SchedulerOption
- type Server
- type ServerConfig
- type ServerOption
Constants ¶
View Source
const ( TgSuccessMsgSubscribed = "Subscribed successfully." TgSuccessMsgUnsubscribed = "Unsubscribed successfully." TgErrMsgRequiredSite = "Site (domain) is required." TgErrMsgNotFoundSite = "Site `%s` not found." )
View Source
const ( OpClientEnqueue = "task.client: enqueue ->" OpMetricsRegister = "task.metrics: register ->" OpMetricsClose = "task.metrics: close ->" OpServerStart = "task.server: start ->" OpServerProcessTask = "task.server: process task ->" OpServerParseFeed = "task.server: parse feed link ->" OpServerParseSitemap = "task.server: parse sitemap link ->" OpServerParseArticle = "task.server: parse article link ->" OpSchedulerStart = "task.scheduler: start ->" OpSchedulerSync = "task.scheduler: sync ->" OpSchedulerAdd = "task.scheduler: add ->" OpSchedulerRemove = "task.scheduler: remove ->" OpMarshal = "task: marshal payload ->" OpUnmarshal = "task: unmarshal payload ->" )
View Source
const ( TgCmdStart = "start" TgCmdRumors = "rumors" TgCmdSites = "sites" TgCmdSub = "sub" TgCmdOn = "on" TgCmdOff = "off" )
View Source
const ( TelegramPrefix = "telegram:" TelegramCmd = TelegramPrefix + "cmd:" TelegramCmdRumors = TelegramCmd + TgCmdRumors TelegramCmdSites = TelegramCmd + TgCmdSites TelegramCmdSub = TelegramCmd + TgCmdSub TelegramCmdOn = TelegramCmd + TgCmdOn TelegramCmdOff = TelegramCmd + TgCmdOff TelegramChat = TelegramPrefix + "chat:" TelegramChatNew = TelegramChat + "new" TelegramChatEdit = TelegramChat + "edit" )
View Source
const DefaultQueue = "default"
View Source
const (
PluginName = "task"
)
Variables ¶
This section is empty.
Functions ¶
func LoggingMiddleware ¶
func LoggingMiddleware(log *slog.Logger) asynq.MiddlewareFunc
func TgCmdMiddleware ¶
func TgCmdMiddleware( siteRepo repository.ReadRepository[*entity.Site], chatRepo repository.ReadWriteRepository[*entity.Chat], publisher common.Pub, logger *slog.Logger, ) asynq.MiddlewareFunc
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) EnqueueTgCmd ¶
func (*Client) EnqueueTgMemberEdit ¶
type HandlerJobFeed ¶
type HandlerJobFeed struct {
// contains filtered or unexported fields
}
func (*HandlerJobFeed) ProcessTask ¶
type HandlerJobSitemap ¶
type HandlerJobSitemap struct {
// contains filtered or unexported fields
}
func (*HandlerJobSitemap) ProcessTask ¶
type HandlerTgChat ¶
type HandlerTgChat struct {
// contains filtered or unexported fields
}
func (*HandlerTgChat) ProcessTask ¶
type HandlerTgCmdOff ¶
type HandlerTgCmdOff struct {
// contains filtered or unexported fields
}
func (*HandlerTgCmdOff) ProcessTask ¶
type HandlerTgCmdOn ¶
type HandlerTgCmdOn struct {
// contains filtered or unexported fields
}
func (*HandlerTgCmdOn) ProcessTask ¶
type HandlerTgCmdRumors ¶
type HandlerTgCmdRumors struct {
// contains filtered or unexported fields
}
func (*HandlerTgCmdRumors) ProcessTask ¶
type HandlerTgCmdSites ¶
type HandlerTgCmdSites struct {
// contains filtered or unexported fields
}
func (*HandlerTgCmdSites) ProcessTask ¶
type HandlerTgCmdSub ¶
type HandlerTgCmdSub struct {
// contains filtered or unexported fields
}
func (*HandlerTgCmdSub) ProcessTask ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics(redisConnOpt asynq.RedisConnOpt, logger *slog.Logger) *Metrics
func (*Metrics) Unregister ¶
func (m *Metrics) Unregister()
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func (*Plugin) Init ¶
func (p *Plugin) Init( cfg config.Configurer, uow common.UnitOfWork, redisConnOpt asynq.RedisConnOpt, pub common.Pub, log logger.Logger, ) error
type PostEnqueueFunc ¶
type Scheduler ¶
func NewScheduler ¶
func NewScheduler(repo repository.ReadRepository[*entity.Job], redisConnOpt asynq.RedisConnOpt, logger *slog.Logger, options ...SchedulerOption) *Scheduler
type SchedulerConfig ¶
func (*SchedulerConfig) Init ¶
func (cfg *SchedulerConfig) Init()
type SchedulerOption ¶
type SchedulerOption func(*Scheduler)
func WithInterval ¶
func WithInterval(interval time.Duration) SchedulerOption
func WithPostEnqueueFunc ¶
func WithPostEnqueueFunc(fn PostEnqueueFunc) SchedulerOption
func WithPreEnqueueFunc ¶
func WithPreEnqueueFunc(fn PreEnqueueFunc) SchedulerOption
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(cfg *ServerConfig, redisConnOpt asynq.RedisConnOpt, logger *slog.Logger, options ...ServerOption) *Server
type ServerConfig ¶
type ServerConfig struct { Concurrency int `mapstructure:"concurrency"` Queues map[string]int `mapstructure:"queues"` StrictPriority bool `mapstructure:"strict_priority"` HealthCheckInterval time.Duration `mapstructure:"health_check_interval"` DelayedTaskCheckInterval time.Duration `mapstructure:"delayed_task_check_interval"` GroupGracePeriod time.Duration `mapstructure:"group_grace_period"` GroupMaxDelay time.Duration `mapstructure:"group_max_delay"` GroupMaxSize int `mapstructure:"group_max_size"` GracefulTimeout time.Duration `mapstructure:"graceful_timeout"` }
func (*ServerConfig) Init ¶
func (cfg *ServerConfig) Init()
type ServerOption ¶
type ServerOption func(s *Server)
func WithErrorHandler ¶
func WithErrorHandler(errorHandler asynq.ErrorHandler) ServerOption
func WithGroupAggregator ¶
func WithGroupAggregator(groupAggregator asynq.GroupAggregator) ServerOption
Source Files ¶
- client.go
- handler_job_feed.go
- handler_job_sitemap.go
- handler_middleware.go
- handler_tg_chat.go
- handler_tg_cmd_off.go
- handler_tg_cmd_on.go
- handler_tg_cmd_rumors.go
- handler_tg_cmd_sites.go
- handler_tg_cmd_sub.go
- logger.go
- metrics.go
- plugin.go
- scheduler.go
- scheduler_config.go
- server.go
- server_config.go
- util.go
Click to show internal directories.
Click to hide internal directories.