-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[DO-NOT-MERGE] spike - gRPC support #571
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# gRPC transport for Controllers (a spike) | ||
|
||
This directory contains a very basic implementation of gRPC transport. The real implementation would live in its own packages directory, e.g. `packages/grpc`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright IBM Corp. 2017. All Rights Reserved. | ||
// Node module: @loopback/core | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
// tslint:disable:no-any | ||
|
||
// TODO(bajtos) serviceSpec needs to be typed | ||
export function service(serviceSpec: any) { | ||
return function(controllerCtor: Function) { | ||
(controllerCtor as any).grpcService = serviceSpec; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it a good practice to mutate the class directly instead of Reflector? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see two issues with Reflector:
Creating a static property on the constructor class solves both issues and it's the same approach we are already using for Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1, for the first reason alone; if others are making use of reflect-metadata, which is entirely likely, it could impact us. |
||
}; | ||
} |
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.
Is it important that we append the property to the target as-is, or can we extend it with the decorator?
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.
Good point. I think it should be ok to return a new class in the decorator. But then what are the downsides of appending the static property the existing controller class? Is the extra complexity worth it?
One of my concerns is that controllers decorated with
@services
will have anonymous class name or the same class namenewClass
for all controllers. This will make (error) stack traces rather unhelpful, as we are already experiencing with juggler models that all have the sam class nameModelConstructor
(see lib/model-builder.js).