Skip to content
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

new backend system: events service #22344

Conversation

pjungermann
Copy link
Contributor

@pjungermann pjungermann commented Jan 18, 2024

Hey, I just made a Pull Request!

✔️ Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)
  • All your commits have a Signed-off-by line in the message. (more info)

@backstage-goalie
Copy link
Contributor

backstage-goalie bot commented Jan 18, 2024

Changed Packages

Package Name Package Path Changeset Bump Current Version
@backstage/backend-dynamic-feature-service packages/backend-dynamic-feature-service patch v0.2.0
example-backend packages/backend none v0.2.92
@backstage/plugin-catalog-backend-module-bitbucket-cloud plugins/catalog-backend-module-bitbucket-cloud minor v0.1.25
@backstage/plugin-events-backend-module-aws-sqs plugins/events-backend-module-aws-sqs minor v0.2.13
@backstage/plugin-events-backend-module-azure plugins/events-backend-module-azure minor v0.1.20
@backstage/plugin-events-backend-module-bitbucket-cloud plugins/events-backend-module-bitbucket-cloud minor v0.1.20
@backstage/plugin-events-backend-module-gerrit plugins/events-backend-module-gerrit minor v0.1.20
@backstage/plugin-events-backend-module-github plugins/events-backend-module-github minor v0.1.20
@backstage/plugin-events-backend-module-gitlab plugins/events-backend-module-gitlab minor v0.1.20
@backstage/plugin-events-backend-test-utils plugins/events-backend-test-utils patch v0.1.20
@backstage/plugin-events-backend plugins/events-backend minor v0.2.19
@backstage/plugin-events-node plugins/events-node minor v0.2.19

Copy link
Contributor

github-actions bot commented Jan 18, 2024

Uffizzi Cluster pr-22344 was deleted.

@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch 3 times, most recently from 6beb1f8 to 21cca84 Compare January 21, 2024 21:54
@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch 2 times, most recently from fad74bc to 071915e Compare January 21, 2024 23:51
@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch 7 times, most recently from 4a211f3 to dc41b08 Compare January 23, 2024 20:11
@pjungermann pjungermann changed the title WIP - new backend: event service WIP - new backend system: event service Jan 23, 2024
@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch from dc41b08 to ef78082 Compare January 23, 2024 21:45
@github-actions github-actions bot added documentation Improvements or additions to documentation area:catalog Related to the Catalog Project Area labels Jan 23, 2024
@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch from ef78082 to 31fc74c Compare January 24, 2024 02:11
@pjungermann
Copy link
Contributor Author

The "Microsite" check is failing with out of memory. I tried retriggering it a couple of times already.

@pjungermann pjungermann marked this pull request as ready for review January 24, 2024 10:59
@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch from 31b307a to 4c01b21 Compare February 19, 2024 03:06
@pjungermann
Copy link
Contributor Author

pjungermann commented Feb 19, 2024

@freben I tried to make use of version-bridge. However, it is not permitted to use it at such a package. Maybe, that wasn't really what you meant, though.

Package '@backstage/plugin-events-node' with backend role 'node-library' has a dependency on package '@backstage/version-bridge' with frontend role 'web-library', which is not permitted

@pjungermann
Copy link
Contributor Author

I will remove version-bridge for now.

@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch 4 times, most recently from 8c91817 to 043add7 Compare February 19, 2024 18:28
import { Duration } from 'luxon';
import { catalogModuleBitbucketCloudEntityProvider } from './catalogModuleBitbucketCloudEntityProvider';
import { BitbucketCloudEntityProvider } from '../providers/BitbucketCloudEntityProvider';

describe('catalogModuleBitbucketCloudEntityProvider', () => {
it('should register provider at the catalog extension point', async () => {
const events = new TestEventsService();
const eventsServiceFactory = createServiceFactory({
Copy link
Member

@freben freben Feb 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test utils package could export a mockEventsServiceFactory in the first place as well, or (structured similarly to mockServices) a mockEventsService.factory(), mockEventsService.service etc or so. No need to look into that at this point though, that can be deferred

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't take care of that one.

Currently, the helper functions are not exported at backstage-test-utils. Rebuilding the same seems not right either.

  • I could put it into backstage-test-utils. However, that would add the dependency to events-node to it.
  • I could keep them separate and (a) copy or (b) export the helpers to achieve a similar setup.
  • I could just add a factory implementation similar to how it was done at this test to make it simpler.
  • ...

What do you think?

plugins/events-backend-module-github/README.md Outdated Show resolved Hide resolved
plugins/events-backend-module-github/README.md Outdated Show resolved Hide resolved
plugins/events-backend-module-github/README.md Outdated Show resolved Hide resolved
plugins/events-backend-module-github/README.md Outdated Show resolved Hide resolved
plugins/events-backend-module-github/README.md Outdated Show resolved Hide resolved
plugins/events-backend-module-github/README.md Outdated Show resolved Hide resolved
plugins/events-backend-module-gitlab/README.md Outdated Show resolved Hide resolved
*/
export const eventsServiceRef = createServiceRef<EventsService>({
id: 'events.service',
scope: 'root',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were looking into merging this for the mainline release, but I'm sorry we think there's one thing that still should be settled.

We were wondering if we could

  • make this one plugin scoped instead
  • make it depend on the plugin metadata service and prefixing subscription IDs with <pluginId>.

Then we could possibly introduce a rootEventsServiceRef as well in the future but only if strictly needed (and reimplement the plugin scoped one in terms of the root scoped one). This also makes the naming pattern of this one more aligned.

Does that make sense? We usually add the root ones only if necessary since they kind of by definition are less "powerful". Do you have any particular reason to have a root scoped events service already at this point?

Happy to hear your feedback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@freben The events service is supposed to create an event-based communication across plugin boundaries. Hence, I fail to see how it can be plugin-scoped.

If just the instance itself is plugin-scoped the actual underlying communication is still root-scoped/global, it could work. Even though the benefits might be limited (e.g., the prefixing of subscription IDs).

I guess the version-bridge was an idea to create this shared state/context, despite being plugin-scoped. However, this package is limited to web-library roles.

We could have both, root-scoped and plugin-scoped, and the root-scoped service is used within the plugin-scoped implementations. Not sure if this would help with what you intend to achieve.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you create the shared state with createRootContext if you need one.

This choice isn't really based on what communication pattern it implements under the hood. It's based on the potential capabilities and whether it might want to contextually be aware of which plugin is using it. And you often do in the end; imagine wanting to emit plugin-tagged metrics based on their events activity for just one example among many.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer, forgot about that one. I will have a look at how I can change the setup further.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched to plugin-scope. Please let me know if this version works for you.

@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch from 043add7 to 155f921 Compare February 21, 2024 14:52
@pjungermann
Copy link
Contributor Author

I will take care of the merge conflicts

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
…r` to `EventsService`

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
…gin` to use `EventsService`

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
…ervice`

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
…d module to use `EventsService`

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
…end system

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
… migrates to `EventsService`

- Fixes the support for the new backend system that was broken entirely
  (with and without events support).
- Migrates the `BitbucketCloudEntityProvider` to use the `EventsService`.

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
@pjungermann pjungermann force-pushed the pjungermann/new-backend/events-service branch from 155f921 to 9e527c9 Compare February 26, 2024 11:52
Copy link
Member

@Rugvip Rugvip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, I think it's time to! :shipit: 🎉

Awesome work @pjungermann 👏

@Rugvip Rugvip merged commit e7a5501 into backstage:master Feb 26, 2024
38 checks passed
Copy link
Contributor

Thank you for contributing to Backstage! The changes in this pull request will be part of the 1.24.0 release, scheduled for Tue, 19 Mar 2024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:catalog Related to the Catalog Project Area documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants