Skip to content

Commit

Permalink
feat: add attributes to pub/sub context
Browse files Browse the repository at this point in the history
  • Loading branch information
vbshnsk committed Oct 17, 2022
1 parent bc2f216 commit e675473
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pubsub-transport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,18 @@ describe('PubSubTransport', () => {
{
a: 1,
},
{ deliveryAttempt: 1, id: 'messageId', pattern: 'operationId' }
{
deliveryAttempt: 1,
id: 'messageId',
pattern: 'operationId',
attributes: { operationId: 'operationId' },
}
);
expect(ackSpy).toBeCalled();
expect(logInfoSpy).toBeCalled();
});

it('handles incoming messages', async () => {
it('handles incoming messages if', async () => {
const message = new Message({} as any, {
ackId: 'ackId',
message: {
Expand Down
3 changes: 3 additions & 0 deletions src/pubsub-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface PubSubContext {
deliveryAttempt: number;

pattern: string;

attributes: Record<string, string>;
}
export const PubSubTransportConfig = Symbol('PubSubTransportConfig');
export type PubSubTransportConfig =
Expand Down Expand Up @@ -122,6 +124,7 @@ export class PubSubTransport extends Server implements CustomTransportStrategy {
id: message.id,
deliveryAttempt: message.deliveryAttempt,
pattern,
attributes: message.attributes,
};

const handler = this.getHandlerByPattern(pattern);
Expand Down

0 comments on commit e675473

Please sign in to comment.