Documentation ¶
Index ¶
- Constants
- func ClientActivator() *di.Activator
- func GetServerMux(ctx context.Context, c ...di.Container) (*asynq.ServeMux, error)
- func LoggingMiddleware(log *slog.Logger) asynq.MiddlewareFunc
- func MetricsActivator() *di.Activator
- func SchedulerActivator() *di.Activator
- func ServerActivator() *di.Activator
- func ServerMuxActivator() *di.Activator
- 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 ClientKey
- type HandlerJobFeed
- type HandlerJobSitemap
- type HandlerTgChat
- type HandlerTgCmdOff
- type HandlerTgCmdOn
- type HandlerTgCmdRumors
- type HandlerTgCmdSites
- type HandlerTgCmdSub
- type Meta
- type Metrics
- type MetricsKey
- type PostEnqueueFunc
- type PreEnqueueFunc
- type Scheduler
- type SchedulerConfig
- type SchedulerKey
- type SchedulerOption
- type Server
- type ServerConfig
- type ServerKey
- type ServerMuxKey
- 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 errs.Op = "task.client: enqueue" OpMetricsRegister errs.Op = "task.metrics: register" OpMetricsClose errs.Op = "task.metrics: close" OpServerStart errs.Op = "task.server: start" OpServerProcessTask errs.Op = "task.server: process task" OpServerParseFeed errs.Op = "task.server: parse feed link" OpServerParseSitemap errs.Op = "task.server: parse sitemap link" OpServerParseArticle errs.Op = "task.server: parse article link" OpSchedulerStart errs.Op = "task.scheduler: start" OpSchedulerSync errs.Op = "task.scheduler: sync" OpSchedulerAdd errs.Op = "task.scheduler: add" OpSchedulerRemove errs.Op = "task.scheduler: remove" OpMarshal errs.Op = "task: marshal payload" OpUnmarshal errs.Op = "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 ConfigSchedulerKey = "task.scheduler"
View Source
const ConfigServerKey = "task.server"
View Source
const DefaultQueue = "default"
Variables ¶
This section is empty.
Functions ¶
func ClientActivator ¶
func GetServerMux ¶
func LoggingMiddleware ¶
func LoggingMiddleware(log *slog.Logger) asynq.MiddlewareFunc
func MetricsActivator ¶
func SchedulerActivator ¶
func ServerActivator ¶
func ServerMuxActivator ¶
func TgCmdMiddleware ¶
func TgCmdMiddleware( siteRepo repository.ReadRepository[*entity.Site], chatRepo repository.ReadWriteRepository[*entity.Chat], publisher *pubsub.Publisher, logger *slog.Logger, ) asynq.MiddlewareFunc
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(rdbMaker *rdb.UniversalClientMaker) *Client
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(rdbMaker *rdb.UniversalClientMaker) *Metrics
func (*Metrics) Unregister ¶
func (m *Metrics) Unregister()
type MetricsKey ¶
type MetricsKey struct{}
type PostEnqueueFunc ¶
type Scheduler ¶
func NewScheduler ¶
func NewScheduler(repo repository.ReadRepository[*entity.Job], rdbMaker *rdb.UniversalClientMaker, options ...SchedulerOption) *Scheduler
type SchedulerConfig ¶
func (*SchedulerConfig) Init ¶
func (cfg *SchedulerConfig) Init()
type SchedulerKey ¶
type SchedulerKey struct{}
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, rdbMaker *rdb.UniversalClientMaker, 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 ServerMuxKey ¶
type ServerMuxKey struct{}
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
- client_di.go
- handler_di.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
- metrics.go
- metrics_di.go
- scheduler.go
- scheduler_config.go
- scheduler_di.go
- server.go
- server_config.go
- server_di.go
- task.go
- util.go
Click to show internal directories.
Click to hide internal directories.