Git Product home page Git Product logo

vertx-scheduler's Introduction

vertx-scheduler

A module to implement scheduling on top of Vertx timers.

Initially this includes a weekly schedule with configurable behavior on DST changes.

Installation

...
dependencies {
  ...
  compile "com.sendgrid.labs:vertx-scheduler:$schedulerVersion"
}

repositories {
  mavenCentral()
}
...

Use

Create a new scheduler

Scheduler scheduler = Scheduler.create(vertx);

Create a time of week

// Tuesday at 2:30 AM UTC
TimeOfWeek time1 = TimeOfWeek.create(Day.TUE, 2, 30, 0, 0);

// Tuesday at 2:30 AM localtime
TimeOfWeek time2 = TimeOfWeek.create(TimeZone.getTimeZone("America/New_York"), Day.TUE, 2, 30, 0, 0);

// Sunday at 01:01 AM UTC
TimeOfWeek time3 = TimeOfWeek.create(60*60*1000 + 60*1000);

// Sunday at 01:01 AM localtime
TimeOfWeek time4 = TimeOfWeek.create(TimeZone.getTimeZone("America/New_York"), 60*60*1000 + 60*1000);

Set a one shot timer on next occurrence of time

Timer timer1 = scheduler.setTimer(time1, new Handler<Timer>() {
    public void handle(Timer t) {
        // ...
    }
});

Set a periodic timer to fire on every occurrence of time

Timer timer2 = scheduler.setPeriodic(time2, new Handler<Timer>() {
    public void handle(Timer t) {
        // ...
    }
});

Cancel a timer

scheduler.cancelTimer(timer1);

Daylight Saving Time

Behavior on DST changes is configurable. Default is to skip when time changes ahead and to run both when time changes back.

TimeOfWeek time1 = TimeOfWeek.create(TimeZone.getTime("America/New_York", Day.TUE, 2, 30, 0, 0, DstAheadBehavior.DST_AHEAD_SKIP, DstBackBehavior.DST_BACK_BOTH_HOURS);

Time change ahead

The scheduler can either skip any events during the missing hour (DST_AHEAD_SKIP), or run them on the next hour (DST_AHEAD_NEXT_HOUR).

Time change back

The scheduler can callback on the first occurrence of the duplicated hour (DST_BACK_FIRST_HOUR), just the second (DST_BACK_SECOND_HOUR), or both (DST_BACK_BOTH_HOURS).

Dispose of scheduler

scheduler.stop();

vertx-scheduler's People

Contributors

bedonath avatar heryandi avatar hugocrd avatar hugomfernandes avatar jonathan-short avatar jpmeyer avatar normanmaurer avatar purplefox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vertx-scheduler's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.