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

Implement PublisherManager convenience wrapper #136

Merged
merged 5 commits into from
May 4, 2024

Conversation

kibertoad
Copy link
Owner

  • Automatically spawn publishers on demand
  • Automatically fill metadata fields

@kibertoad kibertoad requested review from dariacm and CarlosGamero May 3, 2024 16:47

constructor(options: MetadataFillerOptions) {
this.serviceId = options.serviceId
this.defaultVersion = options.defaultVersion ?? '1.0.0'
Copy link
Collaborator

@CarlosGamero CarlosGamero May 3, 2024

Choose a reason for hiding this comment

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

Do we want to migrate to SemVer for the schemaVersion field? to me, it sounds like the best approach but asking just to confirm

Copy link
Collaborator

@CarlosGamero CarlosGamero May 3, 2024

Choose a reason for hiding this comment

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

Wondering if could be beneficial, on consumer, to differentiate between schemaVersion to use one handler or the other 🤔 (definitely not part of this PR, sorry for raising things not relevant here)

Copy link
Owner Author

Choose a reason for hiding this comment

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

hmmm, interesting idea! and yes, that would be awesome for the compatibility. will implement in a separate PR


import { AbstractSnsSqsConsumer } from '../../lib/sns/AbstractSnsSqsConsumer'

export class FakeConsumer<T extends BaseMessageType> extends AbstractSnsSqsConsumer<T, unknown> {
Copy link
Collaborator

@CarlosGamero CarlosGamero May 3, 2024

Choose a reason for hiding this comment

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

Could make sense to expose this class to provide an easy way to replace real consumers on tests? I am not sure tbh

Copy link
Owner Author

Choose a reason for hiding this comment

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

will do!

Comment on lines 19 to 20
handlers: new MessageHandlerConfigBuilder<T, unknown>()
.addConfig(messageSchema, (message) => this._processMessage(message))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This could be simplified with

.addConfig(messageSchema, (message) => Promise.resolve({result: 'success'}))

@CarlosGamero
Copy link
Collaborator

Outstanding work 🚀!

@kibertoad kibertoad merged commit e171b72 into main May 4, 2024
5 checks passed
@kibertoad kibertoad deleted the feat/publisher-manager branch May 4, 2024 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants