CronScheduler

peloton.scheduling.cron.CronScheduler
See theCronScheduler companion class
object CronScheduler

Attributes

Companion
class
Graph
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

object syntax

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
syntax.type

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

Inherited from:
Mirror

Value members

Concrete methods

def make: Resource[IO, CronScheduler]
def use[A](f: CronScheduler ?=> IO[A]): IO[A]

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