Documentation
¶
Overview ¶
Package taskqueue carries OpenTelemetry trace context across the asynq boundary. asynq has no message headers, so the producer wraps the task payload in an envelope holding the W3C trace context, and the worker-side middleware unwraps it, resumes the producer's trace and opens a consumer span around the handler. Payloads without an envelope (older in-flight tasks, traceless producers, scheduler ticks) pass through untouched and get a root span, so every task execution logs a trace id either way.
Index ¶
- Constants
- func ActivationTaskID(orderNo string) string
- func EventTaskID(id int64) string
- func Middleware() asynq.MiddlewareFunc
- func Wrap(ctx context.Context, task *asynq.Task) *asynq.Task
- type Client
- type DeferCloseOrderPayload
- type EventDeliverPayload
- type ForthwithActivateOrderPayload
- type NodeStatus
- type OnlineUser
- type SendEmailPayload
- type SendSmsPayload
- type ServerStatus
- type ServerTrafficCount
- type TrafficStatistics
- type UserTraffic
Constants ¶
const ( EmailTypeVerify = "verify" EmailTypeMaintenance = "maintenance" EmailTypeExpiration = "expiration" EmailTypeTrafficExceed = "traffic_exceed" EmailTypeCustom = "custom" )
const ( DeferCloseOrder = "defer:order:close" ForthwithActivateOrder = "forthwith:order:activate" SchedulerReconcilePaidOrders = "scheduler:order:reconcile-paid" SchedulerReconcilePendingOrders = "scheduler:order:reconcile-pending" SchedulerPublishOrderEvents = "scheduler:order:publish-events" SchedulerCleanupOrderEvents = "scheduler:order:cleanup-events" // SchedulerDailyOrderReport pushes the previous day's settlement summary // to the administrators bound on Telegram. SchedulerDailyOrderReport = "scheduler:order:daily-report" )
const ( SchedulerCheckSubscription = "scheduler:check:subscription" // SchedulerRemindExpiringSubscriptions warns owners whose subscription // expires soon. Daily, at a civil hour. SchedulerRemindExpiringSubscriptions = "scheduler:subscription:remind-expiring" // SchedulerDispatchDomainEvents pumps the generic domain-event outbox // onto the asynq queue as events:deliver tasks. SchedulerDispatchDomainEvents = "scheduler:events:dispatch" SchedulerTotalServerData = "scheduler:total:server" SchedulerResetTraffic = "scheduler:reset:traffic" SchedulerTrafficStat = "scheduler:traffic:stat" SchedulerLogCleanup = "scheduler:log:cleanup" SchedulerFlushTraffic = "scheduler:flush:traffic" )
const ( // ScheduledBatchSendEmail scheduled batch send email ScheduledBatchSendEmail = "scheduled:email:batch" // ForthwithQuotaTask create quota task immediately ForthwithQuotaTask = "forthwith:quota:task" // SchedulerExchangeRate fetch exchange rate task SchedulerExchangeRate = "scheduler:exchange:rate" )
const ( // EventDeliver carries one domain event from the outbox to its topic // subscribers; asynq is the broker (retry, backoff, dead-letter archive). EventDeliver = "events:deliver" )
const (
// ForthwithSendEmail forthwith send email
ForthwithSendEmail = "forthwith:email:send"
)
const (
// ForthwithSendSms forthwith send email
ForthwithSendSms = "forthwith:sms:send"
)
const ForthwithTrafficStatistics = "forthwith:traffic:statistics"
Variables ¶
This section is empty.
Functions ¶
func ActivationTaskID ¶
func EventTaskID ¶
EventTaskID deduplicates enqueues of the same outbox event: the publish pump may replay an enqueue when marking the event published fails, and the task-id conflict turns that replay into a no-op.
func Middleware ¶
func Middleware() asynq.MiddlewareFunc
Middleware resumes the producer's trace from the payload envelope (when present), hands the handler the unwrapped payload, and records the task execution as a consumer span.
Types ¶
type Client ¶
Client wraps *asynq.Client so EnqueueContext stamps the caller's trace context onto the task. Wrapping rebuilds the task, which drops options embedded at NewTask time — pass options to EnqueueContext instead. The plain Enqueue promotes from the inner client untraced (it has no context to read).
type DeferCloseOrderPayload ¶
type DeferCloseOrderPayload struct {
OrderNo string `json:"order_no"`
}
type EventDeliverPayload ¶
type EventDeliverPayload struct {
ID int64 `json:"id"`
Topic string `json:"topic"`
Key string `json:"key"`
Payload string `json:"payload"`
}
EventDeliverPayload is the broker representation of one outbox event.
type ForthwithActivateOrderPayload ¶
type ForthwithActivateOrderPayload struct {
OrderNo string `json:"order_no"`
}
type NodeStatus ¶
type NodeStatus struct {
OnlineUsers []OnlineUser `json:"online_users"`
Status ServerStatus `json:"status"`
LastAt int64 `json:"last_at"`
}
type OnlineUser ¶
type SendEmailPayload ¶
type SendSmsPayload ¶
type ServerStatus ¶
type ServerTrafficCount ¶
type TrafficStatistics ¶
type TrafficStatistics struct {
ServerId int64 `json:"server_id"`
Protocol string `json:"protocol"`
Logs []UserTraffic `json:"logs"`
}