move to a separate package instead and address comments

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-10-24 19:08:50 +02:00
parent 222793c849
commit e09bf604cd
25 changed files with 229 additions and 101 deletions
+36
View File
@@ -0,0 +1,36 @@
# @backstage/backend-tasks
Common distributed task management / locking library for Backstage backends.
## Usage
Add the library to your backend package:
```sh
# From your Backstage root directory
cd packages/backend
yarn add @backstage/backend-tasks
```
then make use of its facilities as necessary:
```typescript
import { TaskManager } from '@backstage/backend-tasks';
const manager = TaskManager.fromConfig(rootConfig).forPlugin('my-plugin');
const { unschedule } = await manager.scheduleTask(
'refresh-things',
{
frequency: Duration.fromObject({ minutes: 10 }),
},
async () => {
await entityProvider.run();
},
);
```
## Documentation
- [Backstage Readme](https://github.com/backstage/backstage/blob/master/README.md)
- [Backstage Documentation](https://github.com/backstage/backstage/blob/master/docs/README.md)