by _u24h · 3y ago · 0 comments
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))
}
}
}
`They are two very different concepts which I see very often used interchangeably. Temporal is clearly about orchestration.