Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
popomore committed Jun 9, 2015
1 parent 34b94ff commit d5327af
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
5 changes: 5 additions & 0 deletions 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
Expand Down
57 changes: 55 additions & 2 deletions README.md
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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.
2 changes: 1 addition & 1 deletion 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",
Expand Down

0 comments on commit d5327af

Please sign in to comment.