From d5327af0e4baf91d2b1bc4045fde0b402de0f5a3 Mon Sep 17 00:00:00 2001 From: popomore Date: Wed, 10 Jun 2015 01:45:14 +0800 Subject: [PATCH] Release 1.0.0 --- HISTORY.md | 5 +++++ README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 47ee5f6..8a71011 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,8 @@ +## 1.0.0 / 2015-06-09 + +- feat: set timeout when init +- feat: add an option to set timeout when create a service + ## 0.2.0 / 2015-03-17 - chore: add appveyor and use npm scrips diff --git a/README.md b/README.md index 165f6f7..be8a19d 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,9 @@ app.ready(function() { }); ``` -Handle error +### Error Handle + +If task is called with error, `error` event will be emit, `ready` will never be called. ``` // register a service that will emit error @@ -48,7 +50,29 @@ app.on('error', function(err) { }); ``` -Get data every task end +### Weak Dependency + +If you set a task weak dependency, task will be done without emit `error`. + +``` +var done = app.async('service', {isWeakDep: true}); +serviceLaunch(function(err) { + done(err); +}); + +// will be ready +app.ready(function() { + app.listen(); +}); + +app.on('error', function(err) { + // never be called +}); +``` + +### Ready Status + +You can get status every task end. ``` app.on('ready_stat', function(data) { @@ -57,6 +81,35 @@ app.on('ready_stat', function(data) { }); ``` +### Timeout + +You can set timeout when a task run a long time. + +``` +ready(app, {timeout: 1000}); +app.on('ready_timeout', function(id) { + // this will be called after 1s that `service` task don't complete +}); + +var done = app.async('service'); +serviceLaunch(function() { + // run a long time + done(); +}); +``` + +You can also set timeout for every task + +``` +ready(app); +app.on('ready_timeout', function(id) { + // this will be called after 1s that `service` task don't complete +}); + +var done = app.async('service1', {timeout: 1000}); +serviceLaunch(done); +``` + ## LISENCE Copyright (c) 2015 popomore. Licensed under the MIT license. diff --git a/package.json b/package.json index 36352e4..70fac36 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "koa-ready", - "version": "0.2.1", + "version": "1.0.0", "description": "Launch server after all async task ready", "keywords": [ "koa",