-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
feature(microservice): decorator MessagePattern get new attribute 'transport' #4768
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
feature(microservice): decorator MessagePattern get new attribute 'transport' #4768
Conversation
Pull Request Test Coverage Report for Build 148a1380-0645-4cd5-95e8-98ad88b42fcc
💛 - Coveralls |
c244aa3
to
0845dab
Compare
Thanks @barbarosh. I'll review asap |
@@ -14,6 +19,7 @@ export enum GrpcMethodStreamingType { | |||
*/ | |||
export const MessagePattern = <T = PatternMetadata | string>( | |||
metadata?: T, | |||
transport?: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use Transport
enum here instead?
export const EventPattern = <T = string>(metadata?: T): MethodDecorator => { | ||
export const EventPattern = <T = string>( | ||
metadata?: T, | ||
transport?: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use Transport
enum here instead?
@@ -1,4 +1,5 @@ | |||
export interface CustomTransportStrategy { | |||
listen(callback: () => void): any; | |||
getTransport(): number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an abstract, optional method in the Server
class instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can we name it "getTransportId" instead? getTransport
sounds slightly ambiguous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an abstract, optional method in the
Server
class instead?
I not sure about optional method it is good idea, in my vision we need know which Transport using each server. If new servers not implement this method for this server we need bind all message patterns for all transports or only without transport?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this method required will introduce a breaking change.
If new servers not implement this method for this server
If one creates a new "custom strategy", we should allow him/her to decide whether it should be bound to all methods by default, or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, will make abstract optional method and bind all message patterns to server without getTransportId
@@ -18,6 +19,7 @@ export interface ClientProperties { | |||
|
|||
export interface PatternProperties { | |||
pattern: PatternMetadata; | |||
transport: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use Transport
enum here instead? + transport?
@@ -48,6 +49,10 @@ export class ServerGrpc extends Server implements CustomTransportStrategy { | |||
grpcProtoLoaderPackage = this.loadPackage(protoLoader, ServerGrpc.name); | |||
} | |||
|
|||
public getTransport(): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use Transport
enum here instead?
… transportId and make it optional
@kamilmysliwiec Please review again, I made changes move getTransport() function to variable transportId and updates in docs nestjs/docs.nestjs.com#1246 |
Added test |
Thank you! |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #4769
Docs changes: nestjs/docs.nestjs.com#1246
What is the new behavior?
Decorator MessagePattern get new attribute 'transport' for pass transport id and avoid bind patterns to wrong microservices in multiple microservices architecture
Does this PR introduce a breaking change?
Other information