generated from redhat-developer/new-project-template
-
Notifications
You must be signed in to change notification settings - Fork 58
RHIDP-6502 Modularize Overriding Core Backend Service Configuration #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a76425
RHIDP-6502 Overriding Core Backend Service Configuration
themr0c d6826b0
Update modules/dynamic-plugins/proc-overriding-core-backend-services.…
themr0c 5d5449c
Update modules/dynamic-plugins/proc-overriding-core-backend-services.…
themr0c 4c9bebf
Update modules/dynamic-plugins/proc-overriding-core-backend-services.…
themr0c a927a44
Update modules/dynamic-plugins/proc-overriding-core-backend-services.…
themr0c File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
101 changes: 0 additions & 101 deletions
101
modules/dynamic-plugins/con-overriding-core-backend-services.adoc
This file was deleted.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
modules/dynamic-plugins/proc-overriding-core-backend-services.adoc
This file contains hidden or 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,105 @@ | ||
| [id="overriding-core-backend-services_{context}"] | ||
| = Overriding Core Backend Service Configuration | ||
|
|
||
| The {product} ({product-very-short}) backend platform consists of a number of core services that are well encapsulated. | ||
| The {product-very-short} backend installs these default core services statically during initialization. | ||
|
|
||
| Customize a core service by installing it as a `BackendFeature` by using dynamic plugin functionality. | ||
|
|
||
| .Procedure | ||
| . Configure {product-short} to allow a core service override, by setting the corresponding core service ID environment variable set to `true` in the {product-short} `{my-app-config-file}` configuration file. | ||
themr0c marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| + | ||
| .Environment variables and core service IDs | ||
| [cols="50%,50%",frame="all",options="header"] | ||
| |=== | ||
| |Variable | ||
| |Overrides the related service | ||
|
|
||
| |`ENABLE_CORE_AUTH_OVERRIDE` | ||
| |`core.auth` | ||
|
|
||
| | `ENABLE_CORE_CACHE_OVERRIDE` | ||
| | `core.cache` | ||
|
|
||
| | `ENABLE_CORE_ROOTCONFIG_OVERRIDE` | ||
| | `core.rootConfig` | ||
|
|
||
| | `ENABLE_CORE_DATABASE_OVERRIDE` | ||
| | `core.database` | ||
|
|
||
| | `ENABLE_CORE_DISCOVERY_OVERRIDE` | ||
| | `core.discovery` | ||
|
|
||
| | `ENABLE_CORE_HTTPAUTH_OVERRIDE` | ||
| | `core.httpAuth` | ||
|
|
||
| | `ENABLE_CORE_HTTPROUTER_OVERRIDE` | ||
| | `core.httpRouter` | ||
|
|
||
| | `ENABLE_CORE_LIFECYCLE_OVERRIDE` | ||
| | `core.lifecycle` | ||
|
|
||
| | `ENABLE_CORE_LOGGER_OVERRIDE` | ||
| | `core.logger` | ||
|
|
||
| | `ENABLE_CORE_PERMISSIONS_OVERRIDE` | ||
| | `core.permissions` | ||
|
|
||
| | `ENABLE_CORE_ROOTHEALTH_OVERRIDE` | ||
| | `core.rootHealth` | ||
|
|
||
| | `ENABLE_CORE_ROOTHTTPROUTER_OVERRIDE` | ||
| | `core.rootHttpRouter` | ||
|
|
||
| | `ENABLE_CORE_ROOTLIFECYCLE_OVERRIDE` | ||
| | `core.rootLifecycle` | ||
|
|
||
| | `ENABLE_CORE_SCHEDULER_OVERRIDE` | ||
| | `core.scheduler` | ||
|
|
||
| | `ENABLE_CORE_USERINFO_OVERRIDE` | ||
| | `core.userInfo` | ||
|
|
||
| | `ENABLE_CORE_URLREADER_OVERRIDE` | ||
| | `core.urlReader` | ||
|
|
||
| | `ENABLE_EVENTS_SERVICE_OVERRIDE` | ||
| | `events.service` | ||
| |=== | ||
|
|
||
| . Install your custom core service as a `BackendFeature`. | ||
| + | ||
| For example, | ||
| adding a middleware function to handle all incoming requests can be done | ||
| by installing a custom `configure` function for the root `HTTP` router backend service | ||
| which allows access to the underlying Express application. | ||
| + | ||
| .Example of a `BackendFeature` middleware function to handle incoming `HTTP` requests | ||
themr0c marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [source,javascript] | ||
| ---- | ||
| // Create the BackendFeature | ||
| export const customRootHttpServerFactory: BackendFeature = | ||
| rootHttpRouterServiceFactory({ | ||
| configure: ({ app, routes, middleware, logger }) => { | ||
| logger.info( | ||
| 'Using custom root HttpRouterServiceFactory configure function', | ||
| ); | ||
| app.use(middleware.helmet()); | ||
| app.use(middleware.cors()); | ||
| app.use(middleware.compression()); | ||
| app.use(middleware.logging()); | ||
| // Add a the custom middleware function before all | ||
| // of the route handlers | ||
| app.use(addTestHeaderMiddleware({ logger })); | ||
| app.use(routes); | ||
| app.use(middleware.notFound()); | ||
| app.use(middleware.error()); | ||
| }, | ||
| }); | ||
|
|
||
| // Export the BackendFeature as the default entrypoint | ||
| export default customRootHttpServerFactory; | ||
| ---- | ||
| + | ||
| In the above example, as the `BackendFeature` overrides the default implementation of the HTTP router service, you must set the `ENABLE_CORE_ROOTHTTPROUTER_OVERRIDE` environment variable to `true` so that the {product-short} does not install the default implementation automatically. | ||
themr0c marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.