-
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
feat: add integration for service-oriented backends #1119
Conversation
bcd2e89
to
0a6cbf1
Compare
0a6cbf1
to
71af4f4
Compare
418fa32
to
5fb6604
Compare
96c5aca
to
83fa5ac
Compare
83fa5ac
to
62dccfd
Compare
25eec64
to
e77f7f3
Compare
/** | ||
* DataSource instance properties/operations | ||
*/ | ||
export class DataSource { |
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.
Isn't this type definition shared with @loopback/repository
? Can we move commonly-used type definitions directly into loopback-datasource-juggler please?
My understanding is that we need to create index.d.ts
file alongside existing index.js and place all type definitions there.
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.
That's on my plate to move TS type definitions into loopback-datasource-juggler
. Let's deal it in a separate PR.
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.
Fair enough.
packages/service/LICENSE
Outdated
@@ -0,0 +1,25 @@ | |||
Copyright (c) IBM Corp. 2018. All Rights Reserved. | |||
Node module: @loopback/service |
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.
Let's use a more descriptive name than @loopback/service
please. For example, I would expect @loopback/service
to provide functionality for building services.
Few proposals:
@loopback/service-client
@loopback/service-integration
@loopback/service-proxy
@loopback/service-repository
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.
Must have
Please update the main documentation too, see e.g. https://github.com/strongloop/loopback-next/blob/d2daf382fc38e16abbb2087354ce75b5b8efe215/docs/site/Calling-other-APIs-and-Web-Services.md
Perhaps you should move the content from README to the docs, so that README contains only a link to our docs site?
A discussion
I am confused about the invocation proxy part as I don't see how to use it together with DataSource-backed services.
Additionally, I am concerned about performance impacts of using ES6 Services in our codebase. While there have been performance improvements made towards the end of 2017 (see this blog post), these speed ups did not make it into Node.js 8.x LTS.
Additionally, Proxies still introduce performance overhead:
Converting NamedNodeMap to use Proxy increased processing time by
- 1.9 s on V8 6.0 (Node v8.4.0)
- 0.5 s on V8 6.3 (Node v9.0.0-v8-canary-20170910)
Can we remove the proxy part from this initial pull request?
packages/service/README.md
Outdated
|
||
**NOTE**: Once we start to support declarative datasources with `@loopback/boot`, | ||
the datasource configuration files can be dropped into `src/datasources` to be | ||
discovered and bound automatically. |
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.
Please add a link to the GitHub issue tracking the task of adding support for data-sources to @loopback/boot
.
packages/service/README.md
Outdated
export class MyController { | ||
|
||
@serviceProxy('geoService') | ||
private geoService: GeoService; |
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.
Are all users required to write service interfaces manually? Shouldn't there be a type-unsafe interface allowing a simpler usage?
Something along the following lines:
// provided by us
interface GenericService {
[method: string]: Function
}
// usage
@serviceProxy('geoService')
private geoService: GenericService;
Or maybe it's our intention to force LB4 users to always write the service interface, to prevent them from being lazy and losing type safety?
packages/service/README.md
Outdated
|
||
export class MyController { | ||
|
||
@serviceProxy('geoService') |
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.
Why a proxy? Have you considered other names like @serviceClient
?
'datasources.' + meta.dataSourceName, | ||
); | ||
return getService(ds); | ||
} |
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.
What if neither dataSource
nor dataSourceName
is set?
Please throw a descriptive error in such case.
637699c
to
ee98cf2
Compare
@bajtos Your comments are addressed. PTAL. |
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.
LGTM, please consider addressing the last two comments below (Use vs. Usage, juggler namespace).
No further review is needed from my side.
|
||
{% include content/tbd.html %} | ||
``` | ||
$ npm install --save @loopback/service-proxy |
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.
FWIW, --save
is no longer needed with the npm version shipped in Node.js 8.x LTS, at least AFAIK. If you decide to change this line, then please check other places in this pull request that are using --save
argument.
packages/service-proxy/README.md
Outdated
$ npm install --save @loopback/service-proxy | ||
``` | ||
|
||
## Usage |
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.
This should be Basic use
, see http://loopback.io/doc/en/contrib/README-guidelines.html
This section is often titled “Usage,” but we prefer “Use” because it is a shorter and more common word, and means the same thing.
```ts | ||
import {DataSourceConstructor, juggler} from '@loopback/service-proxy'; | ||
|
||
const ds: juggler.DataSource = new DataSourceConstructor({ |
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.
This may be outside of this pull request, but it would be great if consumers of @loopback/service-proxy
did not need to know about juggler
namespace.
import {DataSourceConstructor, DataSource} from '@loopback/service-proxy';
const ds: DataSource = new DataSourceConstructor({
// ...
});
Ideally, we should not need two type entities (DataSource + DataSourceConstructor) and have a single entity behaving like a proper ES6 class:
import {DataSource} from '@loopback/service-proxy';
const ds = new DataSource({
// ...
});
The PR adds basic integration for service oriented backends such as REST and SOAP web services using legacy connectors.
Implements #1069
Checklist
npm test
passes on your machinepackages/cli
were updatedpackages/example-*
were updated