diff --git a/.ceylon/config b/.ceylon/config index cdad7f4..8b635c1 100644 --- a/.ceylon/config +++ b/.ceylon/config @@ -2,6 +2,7 @@ [compiler] source=source resource=resource +source=test source=examples [defaults] diff --git a/.classpath b/.classpath index 4cab939..07929cc 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,7 @@ + diff --git a/.gitignore b/.gitignore index 8b6f86a..9ad4615 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* /.exploded/ +/test/ diff --git a/README.md b/README.md index 411cc6e..d2e3060 100644 --- a/README.md +++ b/README.md @@ -7,19 +7,24 @@ _Chime_ is time scheduler which works on _Vert.x_ event bus and provides: Available on [Ceylon Herd](https://herd.ceylon-lang.org/modules/herd.schedule.chime) ->Runs with Ceylon 1.2.0 and Vert.x 3.2.1 +>Runs with Ceylon 1.2.2 and Vert.x 3.2.2 ## Dependences. -* ceylon.language/1.2.0 -* ceylon.time/1.2.0 -* io.vertx.ceylon.core/3.2.1 +* ceylon.language/1.2.2 +* ceylon.time/1.2.2 +* io.vertx.ceylon.core/3.2.2 ## Usage and documentation. +<<<<<<< HEAD 1. Deploy _Chime_ verticle programmatically using `Vertx.deployVerticle("ceylon:herd.schedule.chime/0.1.0")` in any language Vert.x supports. Vert.x downloads the module from [Ceylon Herd](https://herd.ceylon-lang.org) and deploys it. The other way is to deploy _Chime_ with Vert.x CLI, see details in [Vert.x documentation](http://vertx.io/docs/) 2. Create and listen timers on _EventBus_, see details in [API docs](https://modules.ceylon-lang.org/repo/1/herd/schedule/chime/0.1.0/module-doc/api/index.html) +======= +1. Deploy _Chime_ verticle programmatically using `Vertx.deployVerticle("ceylon:herd.schedule.chime/0.1.1")` in any language Vert.x supports. Vert.x downloads the module from [Ceylon Herd](https://herd.ceylon-lang.org) and deploys it. The other way is to deploy _Chime_ with Vert.x CLI, see details in [Vert.x documentation](http://vertx.io/docs/) +2. Create and listen timers on _EventBus_, see details in [API docs](https://modules.ceylon-lang.org/repo/1/herd/schedule/chime/0.1.1/module-doc/api/index.html) +>>>>>>> refs/remotes/origin/develop Also, see [example](examples/herd/examples/schedule/chime) diff --git a/examples/herd/examples/schedule/chime/module.ceylon b/examples/herd/examples/schedule/chime/module.ceylon index d539bb6..57fd1a2 100644 --- a/examples/herd/examples/schedule/chime/module.ceylon +++ b/examples/herd/examples/schedule/chime/module.ceylon @@ -1,4 +1,4 @@ native("jvm") -module herd.examples.schedule.chime "0.1.0" { - shared import io.vertx.ceylon.core "3.2.1"; +module herd.examples.schedule.chime "0.1.1" { + shared import io.vertx.ceylon.core "3.2.2"; } diff --git a/examples/herd/examples/schedule/chime/run.ceylon b/examples/herd/examples/schedule/chime/run.ceylon index c8d9267..027a82f 100644 --- a/examples/herd/examples/schedule/chime/run.ceylon +++ b/examples/herd/examples/schedule/chime/run.ceylon @@ -18,7 +18,7 @@ import io.vertx.ceylon.core { shared void run() { value v = vertx.vertx(); v.deployVerticle ( - "ceylon:herd.schedule.chime/0.1.0", + "ceylon:herd.schedule.chime/0.1.1", ( String|Throwable res ) { if ( is String res ) { value scheduler = Scheduler( v ); @@ -32,8 +32,7 @@ shared void run() { } -"Performs scheduler run. Creates cron-style timer and listens it. - " +"Performs scheduler run. Creates cron-style timer and listens it." class Scheduler( Vertx v, String address = "chime" ) { EventBus eventBus = v.eventBus(); @@ -45,12 +44,12 @@ class Scheduler( Vertx v, String address = "chime" ) address, JSON { "operation" -> "create", - "name" -> "schedule manager", + "name" -> "scheduler", "state" -> "running" }, ( Throwable | Message msg ) { if ( is Message msg ) { - managerCreated( msg ); + schedulerCreated( msg ); } else { print( "error in onConnect ``msg``" ); @@ -80,22 +79,26 @@ class Scheduler( Vertx v, String address = "chime" ) } - void managerCreated( Message msg ) { + void schedulerCreated( Message msg ) { - eventBus.consumer( "schedule manager:timer", printMessage ); + eventBus.consumer( "scheduler:timer", printMessage ); eventBus.send( address, JSON { "operation" -> "create", - "name" -> "schedule manager:timer", + "name" -> "scheduler:timer", "state" -> "running", "publish" -> false, "max count" -> 3, "time zone" -> "Europe/Paris", + /*"descirption" -> JSON { + "type" -> "interval", + "delay" -> 10 + }*/ "descirption" -> JSON { "type" -> "cron", - "seconds" -> "27/30", + "seconds" -> "20/15", "minutes" -> "*", "hours" -> "0-23", "days of month" -> "1-31", diff --git a/source/herd/schedule/chime/TimeScheduler.ceylon b/source/herd/schedule/chime/TimeScheduler.ceylon index f40c01f..d9fbae3 100644 --- a/source/herd/schedule/chime/TimeScheduler.ceylon +++ b/source/herd/schedule/chime/TimeScheduler.ceylon @@ -110,7 +110,7 @@ import herd.schedule.chime.cron { * interval timer description: { \"type\" -> String // timer type, mandatory - \"increment seconds\" -> Integer // increment in seconds, if <= 0 timer fires only once, mandatory + \"delay\" -> Integer // timer delay in seconds, if <= 0 timer fires only once, mandatory } diff --git a/source/herd/schedule/chime/errorMessages.ceylon b/source/herd/schedule/chime/errorMessages.ceylon index 7d8c9a8..0a253b4 100644 --- a/source/herd/schedule/chime/errorMessages.ceylon +++ b/source/herd/schedule/chime/errorMessages.ceylon @@ -39,9 +39,9 @@ shared object errorMessages { shared String incorrectTimerState = "timer state has to be one of - 'get', 'paused', 'running'"; - shared String intervalHasToBeSpecified = "interval has to be specified"; + shared String delayHasToBeSpecified = "delay has to be specified"; - shared String intervalHasToBeGreaterThanZero = "interval has to be greater than zero"; + shared String delayHasToBeGreaterThanZero = "delay has to be greater than zero"; shared String incorrectCronTimerDescription = "incorrect cron timer description"; diff --git a/source/herd/schedule/chime/module.ceylon b/source/herd/schedule/chime/module.ceylon index 1109f61..a355f26 100644 --- a/source/herd/schedule/chime/module.ceylon +++ b/source/herd/schedule/chime/module.ceylon @@ -4,7 +4,7 @@ * scheduling with _cron-style_ and _interval_ timers * applying time zones available on _JVM_ - >Compiled for Ceylon 1.2.0 and Vert.x 3.2.1 + >Compiled for Ceylon 1.2.2 and Vert.x 3.2.2 ## Running. @@ -14,7 +14,7 @@ import io.vertx.ceylon.core { vertx } vertx.vertx().deployVerticle ( - \"ceylon:herd.schedule.chime/0.1.0\", + \"ceylon:herd.schedule.chime/0.1.1\", (String|Throwable res) { ... } @@ -199,9 +199,11 @@ * __Interval timer__. Timer which fires after each given time period (minimum 1 second) { \"type\" -> \"interval\" // timer type, mandatory - \"increment seconds\" -> Integer // increment in seconds, if <= 0 timer fires only once, mandatory + \"delay\" -> Integer // timer delay in seconds, if <= 0 timer fires only once, mandatory } + >Interval timer delay is in _seconds_ + ##### Scheduler response on timer request. @@ -256,6 +258,7 @@ ##### Timer example. + // creat new Scheduler with name \"schedule manager\" at first and then the timer eventBus.send ( \"chime\", JSON { @@ -265,13 +268,14 @@ }, (Throwable|Message msg) { if (is Message msg) { + // create timer eventBus.send( \"chime\", JSON { \"operation\" -> \"create\", - \"name\" -> \"schedule manager:schedule timer\", + \"name\" -> \"schedule manager:scheduled timer\", // full timer name == address to listen timer \"state\" -> \"running\", - \"publish\" -> false, + \"publish\" -> false, // timer will send messages \"max count\" -> 3, \"time zone\" -> \"Europe/Paris\", \"descirption\" -> JSON { @@ -286,7 +290,7 @@ } }, (Throwable|Message msg) { - print(msg); + print(msg); // Chime replies if timer successfully created or some error occured } ); } @@ -295,6 +299,14 @@ } } ); + + // listen timer + eventBus.consumer ( + \"schedule manager:scheduled timer\", + (Throwable | Message msg) { + ... + } + ); ### Error messages. @@ -323,8 +335,8 @@ * \"unsupported time zone\" * \"timer description has to be specified\" * \"timer state has to be one of - 'get', 'paused', 'running'\" - * \"interval has to be specified\" - * \"interval has to be greater than zero\" + * \"delay has to be specified\" + * \"delay has to be greater than zero\" * \"incorrect cron timer description\" @@ -395,7 +407,7 @@ license ( ) by( "Lis" ) native( "jvm" ) -module herd.schedule.chime "0.1.0" { - shared import io.vertx.ceylon.core "3.2.1"; - import ceylon.time "1.2.0"; +module herd.schedule.chime "0.1.1" { + shared import io.vertx.ceylon.core "3.2.2"; + import ceylon.time "1.2.2"; } diff --git a/source/herd/schedule/chime/timer/StandardTimerFactory.ceylon b/source/herd/schedule/chime/timer/StandardTimerFactory.ceylon index 799f0c6..75ca24a 100644 --- a/source/herd/schedule/chime/timer/StandardTimerFactory.ceylon +++ b/source/herd/schedule/chime/timer/StandardTimerFactory.ceylon @@ -24,8 +24,8 @@ shared class StandardTimerFactory( "max year limitation" Integer maxYearPeriod = "Initializes factory - to be called before using (creators adding is performed here)." shared TimerFactory initialize() { - addCreator( timerDefinitions.typeCronStyle, createCronTimer ); - addCreator( timerDefinitions.typeInterval, createIntervalTimer ); + addCreator( definitions.typeCronStyle, createCronTimer ); + addCreator( definitions.typeInterval, createIntervalTimer ); return this; } @@ -74,16 +74,16 @@ shared class StandardTimerFactory( "max year limitation" Integer maxYearPeriod = "Creates interval timer." Timer|String createIntervalTimer( "Timer description." JSON description ) { - if ( is Integer interval = description.get( timerDefinitions.intervalSeconds ) ) { + if ( is Integer delay = description.get( definitions.delay ) ) { - if ( interval > 0 ) { - return TimerInterval( interval * 1000 ); + if ( delay > 0 ) { + return TimerInterval( delay * 1000 ); } else { - return errorMessages.intervalHasToBeGreaterThanZero; + return errorMessages.delayHasToBeGreaterThanZero; } } - return errorMessages.intervalHasToBeSpecified; + return errorMessages.delayHasToBeSpecified; } } diff --git a/source/herd/schedule/chime/timer/TimerInterval.ceylon b/source/herd/schedule/chime/timer/TimerInterval.ceylon index 1f6c98b..68216e1 100644 --- a/source/herd/schedule/chime/timer/TimerInterval.ceylon +++ b/source/herd/schedule/chime/timer/TimerInterval.ceylon @@ -11,7 +11,7 @@ import ceylon.time { " by( "Lis" ) class TimerInterval ( - "Timing interval in miliseconds, to be >= 0." shared Integer intervalMilliseconds + "Timing delay in miliseconds, to be >= 0." shared Integer intervalMilliseconds ) satisfies Timer { diff --git a/source/herd/schedule/chime/timer/definitions.ceylon b/source/herd/schedule/chime/timer/definitions.ceylon index acd5622..62953f7 100644 --- a/source/herd/schedule/chime/timer/definitions.ceylon +++ b/source/herd/schedule/chime/timer/definitions.ceylon @@ -77,6 +77,13 @@ shared object definitions shared String timeZoneID = "time zone"; + // delay in seconds + shared String delay = "delay"; + + // timer types + shared String typeCronStyle = "cron"; + shared String typeInterval = "interval"; + // operation codes "create timer" diff --git a/source/herd/schedule/chime/timer/timerDefinitions.ceylon b/source/herd/schedule/chime/timer/timerDefinitions.ceylon deleted file mode 100644 index fdb541b..0000000 --- a/source/herd/schedule/chime/timer/timerDefinitions.ceylon +++ /dev/null @@ -1,15 +0,0 @@ - - -"defines timer constants" -by( "Lis" ) -object timerDefinitions -{ - - // increment in seconds - shared String intervalSeconds = "interval seconds"; - - // timer types - shared String typeCronStyle = "cron"; - shared String typeInterval = "interval"; - -}