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

feat: event emitter durable listener #1248

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

firmbase-tal
Copy link

@firmbase-tal firmbase-tal commented Aug 5, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number:
#1247

What is the new behavior?

Durable injectable with declared subscribers will be loaded as durable.
Context strategy will use the event payload as the request object for the context strategy.

Does this PR introduce a breaking change?

  • Yes
  • No

Existing request subscribers within durable injectables will now fail to load unless the context strategy can resolve based on the payload, unlike before, where they simply behaved as non-durable.

Other information

@@ -128,9 +130,10 @@ export class EventSubscribersLoader
listenerMethod(
event,
async (...args: unknown[]) => {
const contextId = ContextIdFactory.create();
const request = this.getRequestFromEventPayload(args);
const contextId = ContextIdFactory.getByRequest({ payload: request });
Copy link
Author

@firmbase-tal firmbase-tal Aug 5, 2024

Choose a reason for hiding this comment

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

This change is a conscious choice I have made.
There is no access to the original request object at this time, so in order to decide the request object for the strategy, I decided to use the event payload.
I prefixed with the payload key, since the request object is of expected type Record<string, any>, while payload can also be any non-object or array.

@firmbase-tal
Copy link
Author

There are probably some document fixes which are required, specifically in: https://docs.nestjs.com/techniques/events
Let me know what you think.

@kamilmysliwiec kamilmysliwiec mentioned this pull request Aug 6, 2024
1 task
@kamilmysliwiec kamilmysliwiec added enhancement New feature or request blocked labels Oct 21, 2024
@firmbase-tal firmbase-tal force-pushed the feature-event-emitter-durable-listener branch from cde4a7c to 1290ad2 Compare November 18, 2024 16:20
@firmbase-tal
Copy link
Author

Currently stuck due to typescript-eslint/typescript-eslint#10338
Waiting for upgrade or downgrade for eslint version to proceed.

@firmbase-tal firmbase-tal force-pushed the feature-event-emitter-durable-listener branch from 1290ad2 to cde4a7c Compare November 25, 2024 15:02
@firmbase-tal firmbase-tal force-pushed the feature-event-emitter-durable-listener branch from a6a64e3 to 0fd62e4 Compare November 25, 2024 15:08
@firmbase-tal firmbase-tal force-pushed the feature-event-emitter-durable-listener branch from 0fd62e4 to 7aaef61 Compare November 25, 2024 15:11
@firmbase-tal
Copy link
Author

firmbase-tal commented Nov 25, 2024

Managed to commit by undoing the rebase, committing, and rebasing anew.
eslint will probably still fail when merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants