Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
LisiLisenok committed Mar 16, 2016
2 parents 107c1b1 + 5ad873a commit a6af553
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 52 deletions.
1 change: 1 addition & 0 deletions .ceylon/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[compiler]
source=source
resource=resource
source=test
source=examples

[defaults]
Expand Down
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="source"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="examples"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="com.redhat.ceylon.eclipse.ui.cpcontainer.RUNTIME_CONTAINER/default"/>
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.exploded/
/test/
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions examples/herd/examples/schedule/chime/module.ceylon
Original file line number Diff line number Diff line change
@@ -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";
}
21 changes: 12 additions & 9 deletions examples/herd/examples/schedule/chime/run.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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();
Expand All @@ -45,12 +44,12 @@ class Scheduler( Vertx v, String address = "chime" )
address,
JSON {
"operation" -> "create",
"name" -> "schedule manager",
"name" -> "scheduler",
"state" -> "running"
},
( Throwable | Message<JSON> msg ) {
if ( is Message<JSON> msg ) {
managerCreated( msg );
schedulerCreated( msg );
}
else {
print( "error in onConnect ``msg``" );
Expand Down Expand Up @@ -80,22 +79,26 @@ class Scheduler( Vertx v, String address = "chime" )
}


void managerCreated( Message<JSON> msg ) {
void schedulerCreated( Message<JSON> msg ) {

eventBus.consumer( "schedule manager:timer", printMessage );
eventBus.consumer( "scheduler:timer", printMessage );

eventBus.send<JSON>(
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",
Expand Down
2 changes: 1 addition & 1 deletion source/herd/schedule/chime/TimeScheduler.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions source/herd/schedule/chime/errorMessages.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
34 changes: 23 additions & 11 deletions source/herd/schedule/chime/module.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
...
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -256,6 +258,7 @@
##### Timer example.
// creat new Scheduler with name \"schedule manager\" at first and then the timer
eventBus.send<JSON> (
\"chime\",
JSON {
Expand All @@ -265,13 +268,14 @@
},
(Throwable|Message<JSON> msg) {
if (is Message<JSON> msg) {
// create timer
eventBus.send<JSON>(
\"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 {
Expand All @@ -286,7 +290,7 @@
}
},
(Throwable|Message<JSON> msg) {
print(msg);
print(msg); // Chime replies if timer successfully created or some error occured
}
);
}
Expand All @@ -295,6 +299,14 @@
}
}
);
// listen timer
eventBus.consumer (
\"schedule manager:scheduled timer\",
(Throwable | Message<JSON> msg) {
...
}
);
### Error messages.
Expand Down Expand Up @@ -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\"
Expand Down Expand Up @@ -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";
}
14 changes: 7 additions & 7 deletions source/herd/schedule/chime/timer/StandardTimerFactory.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

}
2 changes: 1 addition & 1 deletion source/herd/schedule/chime/timer/TimerInterval.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
7 changes: 7 additions & 0 deletions source/herd/schedule/chime/timer/definitions.ceylon
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 0 additions & 15 deletions source/herd/schedule/chime/timer/timerDefinitions.ceylon

This file was deleted.

0 comments on commit a6af553

Please sign in to comment.