FS2 streams based on cron expressions
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
modules Update version in README Aug 29, 2018
project
scripts Update release script Aug 29, 2018
.gitignore Tweak build Aug 24, 2018
.scalafmt.conf
.travis.yml
LICENSE Tweak build Aug 24, 2018
README.md Setting version to 0.0.10 Oct 5, 2018
build.sbt Setting version to 0.0.7 Sep 8, 2018
latestVersion.sbt

README.md

fs2-cron

Build Status codecov Join the chat at https://gitter.im/fthomas/fs2-cron Scaladex Scaladoc

fs2-cron is a microlibrary that provides FS2 streams based on Cron4s cron expressions.

Quick example

import cats.effect.{IO, Timer}
import cron4s.Cron
import eu.timepit.fs2cron.awakeEveryCron
import fs2.Stream
import java.time.LocalTime
import scala.concurrent.ExecutionContext
implicit val timer: Timer[IO] = IO.timer(ExecutionContext.global)
// timer: cats.effect.Timer[cats.effect.IO] = cats.effect.internals.IOTimer@474619d9

val evenSeconds = Cron.unsafeParse("*/2 * * ? * *")
// evenSeconds: cron4s.expr.CronExpr = */2 * * ? * *

val printTime = Stream.eval(IO(println(LocalTime.now)))
// printTime: fs2.Stream[cats.effect.IO,Unit] = Stream(..)

val scheduled = awakeEveryCron[IO](evenSeconds) >> printTime
// scheduled: fs2.Stream[[x]cats.effect.IO[x],Unit] = Stream(..)

scheduled.take(3).compile.drain.unsafeRunSync
// 19:36:44.184
// 19:36:46.004
// 19:36:48.004

Using fs2-cron

The latest version of the library is available for Scala 2.12.

If you're using sbt, add the following to your build:

libraryDependencies ++= Seq(
  "eu.timepit" %% "fs2-cron-core" % "0.0.10"
)

License

fs2-cron is licensed under the Apache License, Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 and also in the LICENSE file.