-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce TaskScheduler into backends
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
- Loading branch information
Showing
9 changed files
with
71 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
'@backstage/create-app': patch | ||
--- | ||
|
||
Add a `scheduler` to the plugin environment, which can schedule collaborative tasks across backends. To apply the same change in your backend, follow the steps below. | ||
|
||
First install the package: | ||
|
||
```shell | ||
# From the Backstage repository root | ||
cd packages/backend | ||
yarn add @backstage/backend-tasks | ||
``` | ||
|
||
Add the scheduler to your plugin environment type: | ||
|
||
```diff | ||
// In packages/backend/src/types.ts | ||
+import { PluginTaskScheduler } from '@backstage/backend-tasks'; | ||
|
||
export type PluginEnvironment = { | ||
+ scheduler: PluginTaskScheduler; | ||
``` | ||
|
||
And finally make sure to add such an instance to each plugin's environment: | ||
|
||
```diff | ||
// In packages/backend/src/index.ts | ||
+import { TaskScheduler } from '@backstage/backend-tasks'; | ||
|
||
function makeCreateEnv(config: Config) { | ||
// ... | ||
+ const taskScheduler = TaskScheduler.fromConfig(config); | ||
|
||
return (plugin: string): PluginEnvironment => { | ||
// ... | ||
+ const scheduler = taskScheduler.forPlugin(plugin); | ||
return { | ||
+ scheduler, | ||
// ... | ||
``` |
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
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