forked from backstage/backstage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move to a separate package instead and address comments
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
- Loading branch information
Showing
25 changed files
with
229 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: [require.resolve('@backstage/cli/config/eslint.backend')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
## API Report File for "@backstage/backend-tasks" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
import { Config } from '@backstage/config'; | ||
import { DatabaseManager } from '@backstage/backend-common'; | ||
import { Duration } from 'luxon'; | ||
import { Logger as Logger_2 } from 'winston'; | ||
|
||
// @public | ||
export interface LockOptions { | ||
timeout: Duration; | ||
} | ||
|
||
// @public | ||
export interface PluginTaskManager { | ||
acquireLock( | ||
id: string, | ||
options: LockOptions, | ||
): Promise< | ||
| { | ||
acquired: false; | ||
} | ||
| { | ||
acquired: true; | ||
release(): Promise<void>; | ||
} | ||
>; | ||
scheduleTask( | ||
id: string, | ||
options: TaskOptions, | ||
fn: () => void | Promise<void>, | ||
): Promise<{ | ||
unschedule: () => Promise<void>; | ||
}>; | ||
} | ||
|
||
// @public | ||
export class TaskManager { | ||
constructor(databaseManager: DatabaseManager, logger: Logger_2); | ||
forPlugin(pluginId: string): PluginTaskManager; | ||
// (undocumented) | ||
static fromConfig( | ||
config: Config, | ||
options?: { | ||
databaseManager?: DatabaseManager; | ||
logger?: Logger_2; | ||
}, | ||
): TaskManager; | ||
} | ||
|
||
// @public | ||
export interface TaskOptions { | ||
frequency?: Duration; | ||
initialDelay?: Duration; | ||
timeout?: Duration; | ||
} | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@backstage/backend-tasks", | ||
"description": "Common distributed task management / locking library for Backstage backends", | ||
"version": "0.1.0", | ||
"main": "src/index.ts", | ||
"types": "src/index.ts", | ||
"private": false, | ||
"publishConfig": { | ||
"access": "public", | ||
"main": "dist/index.cjs.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"homepage": "https://backstage.io", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/backstage/backstage", | ||
"directory": "packages/backend-tasks" | ||
}, | ||
"keywords": [ | ||
"backstage" | ||
], | ||
"license": "Apache-2.0", | ||
"scripts": { | ||
"build": "backstage-cli build --outputs cjs,types", | ||
"lint": "backstage-cli lint", | ||
"test": "backstage-cli test", | ||
"prepack": "backstage-cli prepack", | ||
"postpack": "backstage-cli postpack", | ||
"clean": "backstage-cli clean" | ||
}, | ||
"dependencies": { | ||
"@backstage/backend-common": "^0.9.7", | ||
"@backstage/config": "^0.1.10", | ||
"@backstage/errors": "^0.1.3", | ||
"@backstage/types": "^0.1.1", | ||
"@types/luxon": "^2.0.4", | ||
"knex": "^0.95.1", | ||
"lodash": "^4.17.21", | ||
"luxon": "^2.0.2", | ||
"uuid": "^8.0.0", | ||
"winston": "^3.2.1", | ||
"zod": "^3.9.5" | ||
}, | ||
"devDependencies": { | ||
"@backstage/backend-test-utils": "^0.1.7", | ||
"@backstage/cli": "^0.8.0", | ||
"jest": "^26.0.1", | ||
"wait-for-expect": "^3.0.2" | ||
}, | ||
"files": [ | ||
"dist", | ||
"migrations/**/*.{js,d.ts}" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.