3.39.3 • Published 23 days ago

@eggjs/tegg-background-task v3.39.3

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

@eggjs/tegg-background-task

install

npm i --save @eggjs/tegg-background-task

Usage

import { BackgroundTaskHelper } from '@eggjs/tegg-background-task';

@ContextProto()
export default class BackgroundService {
  @Inject()
  private readonly backgroundTaskHelper:BackgroundTaskHelper

  async backgroundAdd() {
    this.backgroundTaskHelper.run(async () => {
      // do the background task
    });
  }
}

Background

tegg release the request context after request is done. So use the process.nextTick, setTimeout, setInterval in request is not safe. Please use the backgroundTaskHelper, the release process will wait all the background tasks are done.

Timeout

The release process will wait tasks done, but not forever. The default timeout is 5s, if task will cost more than 5s, two ways to resolve

  • use the SingletonProto to do the work, SingletonProto never release
  • set longer timeout to backgroundTaskHelper.timeout
3.39.1

24 days ago

3.39.2

23 days ago

3.39.3

23 days ago

3.38.0

1 month ago

3.39.0

1 month ago

3.37.3

1 month ago

3.37.0

1 month ago

3.37.1

1 month ago

3.36.3

1 month ago

3.36.2

1 month ago

3.36.1

1 month ago

3.36.0

2 months ago

3.35.0

2 months ago

3.35.1

2 months ago

3.33.0

2 months ago

3.33.1

2 months ago

3.34.0

2 months ago

3.32.0

3 months ago

3.31.0

4 months ago

3.30.1

4 months ago

3.30.0

4 months ago

3.29.0

5 months ago

3.28.2

5 months ago

3.28.1

5 months ago

3.28.0

5 months ago

3.20.0

9 months ago

3.22.0

8 months ago

3.15.0

9 months ago

3.17.0

9 months ago

3.19.0

9 months ago

3.12.0

10 months ago

3.21.0

8 months ago

3.23.0

8 months ago

3.14.1

9 months ago

3.14.0

10 months ago

3.14.3

9 months ago

3.16.0

9 months ago

3.14.2

9 months ago

3.18.1

9 months ago

3.18.0

9 months ago

3.14.4

9 months ago

3.13.0

10 months ago

3.25.1

7 months ago

3.27.0

6 months ago

3.25.2

7 months ago

3.11.0

11 months ago

3.10.0

11 months ago

3.11.1

11 months ago

3.6.3

1 year ago

3.8.0

12 months ago

3.7.0

1 year ago

3.6.0

1 year ago

3.5.0

1 year ago

1.4.3

1 year ago

3.0.0-alpha.0

1 year ago

3.3.1

1 year ago

3.2.2

1 year ago

3.2.1

1 year ago

3.1.0

1 year ago

3.2.4

1 year ago

3.4.1

1 year ago

3.2.3

1 year ago

3.0.0

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.3.0

2 years ago

1.0.0

2 years ago

0.2.0

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.1.13

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago