1 karma · joined Jan 18, 2024 (2y ago) · 1 submissions
comment 3y ago · link · parent
Here's how a cron job implementation would look with Temporal -
` func Subscription(ctx [redacted].Context, userUUID string) error { free_trial_on := true
for {
if free_trial_on {
// Sleep until trial period passes
[redacted].Sleep(ctx, days(15))
free_trial_on = False
} else {
// Charge subscription fee
[redacted].ExecuteActivity(ctx, ChargeSubscriptionAndEmailReceipt, userUUID, frequency).Get(ctx, nil)
// Sleep until next payment is due
[redacted].Sleep(ctx, days(30))
}
}
}
`