peloton.scheduling.cron.CronScheduler
See theCronScheduler companion class
object CronScheduler
Attributes
- Companion
- class
- Graph
-
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
CronScheduler.type
Members list
Type members
Inherited types
The names of the product elements
The names of the product elements
Attributes
- Inherited from:
- Mirror
The name of the type
The name of the type
Attributes
- Inherited from:
- Mirror
Value members
Concrete methods
Creates a resource bracket for a CronScheduler resource.
Creates a resource bracket for a CronScheduler resource.
Within the lifetime of this resource, the scheduler can be used to asynchronously start effects by Quartz cron expresiions. After the scheduler resource is released, all cron jobs started by this scheduler will be stopped and also released.
The following example will print a message every 10 seconds for 5 minutes:
CronScheduler.use { _ ?=>
for {
_ <- IO.println("Hello out there!").scheduled("*\/10 * * ? * *")
_ <- IO.sleep(5.minutes)
} yield ()
}
You can also provide a specific timezone, start and end date:
CronScheduler.use { _ ?=>
for {
_ <- IO.println("Hello out there!")
.scheduled(
cron = "*\/10 * * ? * *",
timezone = TimeZone.getTimeZone("PST"), // defaults to the system TZ
startDate = Some(myStartDate),
startDate = Some(myEndDate),
)
...
} yield ()
}
Attributes
In this article