Skip to content

Commit e57914f

Browse files
smahatidanjoa
andauthored
Hotfix mar31 (#2480)
Co-authored-by: Daniel Hutzel <[email protected]>
1 parent 36b367e commit e57914f

File tree

2 files changed

+45
-12
lines changed

2 files changed

+45
-12
lines changed

guides/integration/data-federation.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ Relying on live calls to remote services per row is clearly not an option. Inste
7777

7878
We'll use the same [XTravels sample](calesi.md#the-xtravels-sample) and setup as in the [_CAP-level Service Integration_](calesi.md) guide. If you haven't done so already, clone the required repositories to follow along:
7979

80-
```sh
80+
```sh :line-numbers
8181
mkdir -p cap/samples
8282
cd cap/samples
83-
git clone https://github.com/capire/xtravels
83+
git clone https://github.com/capire/xtravels
8484
git clone https://github.com/capire/xflights
8585
git clone https://github.com/capire/s4
8686
```
@@ -89,6 +89,14 @@ git clone https://github.com/capire/s4
8989
[@capire/xflights]: https://github.com/capire/xflights
9090
[@capire/s4]: https://github.com/capire/s4
9191

92+
```sh :line-numbers=6
93+
echo '{"workspaces":["xflights","xtravels","s4"]}' > package.json
94+
npm install
95+
```
96+
97+
> [!note]
98+
> Line 6 above turns the `cap/samples` folder into a root for `npm workspaces` to optimize the `npm install` locally.
99+
> We'll learn more about that in the [_Inner Loop Development guide_](inner-loops.md).
92100
93101

94102

@@ -180,15 +188,27 @@ Let's have a closer look at this code, which handles these main tasks:
180188

181189
## Test Drive Locally
182190

183-
Let's see the outcome in action: to activate the above data federation code, edit `srv/server.js` file and uncomment the single line of code in there like this:
191+
Let's see the outcome in action: to activate the above data federation code, edit `xtravels/srv/server.js` file and uncomment the single line of code in there like this:
184192

185193
::: code-group
186-
```js :line-numbers [srv/server.js]
194+
```js [srv/server.js]
187195
process.env.NODE_ENV || require ('./data-federation')
188196
```
189197
:::
190198

191-
Restart the Xtravels app, and see these lines in the log output:
199+
With that in place, we can start the xtravels app again, and see the data federation in action. Do so by running the following commands from within the `cap/samples` root folder in separate terminals, and in that order:
200+
201+
```shell :line-numbers=1
202+
cds watch s4
203+
```
204+
```shell :line-numbers=2
205+
cds watch xflights
206+
```
207+
```shell :line-numbers=3
208+
cds watch xtravels
209+
```
210+
211+
In the logs of the xtravels app server, you should now see the output of the replication handler, showing that entries from the remote services are replicated locally:
192212

193213
```zsh
194214
Replicated 49 entries { for: 'sap.capire.xflights.Supplements', via: 'hcql' }

guides/integration/inner-loops.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,39 @@ Here's a very rough comparison from a real world example:
3232

3333
### The XTravels Sample
3434

35-
We'll use the same [XTravels sample](calesi.md#the-xtravels-sample) and setup as in the [_CAP-level Service Integration_](calesi.md) guide. If you haven't done so already, clone the required repositories to follow along:
35+
We'll use the same [XTravels sample](calesi.md#the-xtravels-sample) and setup as described in the [_CAP-level Service Integration_](calesi.md) guide. If you haven't done so already, clone the required repositories to follow along:
3636

3737
```sh :line-numbers
3838
mkdir -p cap/samples
3939
cd cap/samples
4040
git clone https://github.com/capire/xtravels
4141
git clone https://github.com/capire/xflights
4242
git clone https://github.com/capire/s4
43-
echo '{"workspaces":["xflights","xtravels","s4"]}' > package.json
44-
npm install
4543
```
4644

4745
[@capire/xtravels]: https://github.com/capire/xtravels
4846
[@capire/xflights]: https://github.com/capire/xflights
4947
[@capire/s4]: https://github.com/capire/s4
5048

49+
```sh :line-numbers=6
50+
echo '{"workspaces":["xflights","xtravels","s4"]}' > package.json
51+
npm install
52+
```
53+
5154
> [!note]
5255
>
5356
> Line 6 above turns the `cap/samples` folder into a root for `npm workspaces`. For the time being this simply optimizes the `npm install`. We'll revisit that in chapter [*Using `npm` Workspaces*](#using-npm-workspaces) below.
5457
58+
#### Activate Generic Data Federation
59+
60+
In addition, activate generic data federation as described in the [_CAP-level Data Federation_](data-federation.md) guide, by editing `xtravels/srv/server.js` file and uncommenting the single line of code in there like this:
61+
62+
::: code-group
63+
```js [xtravels/srv/server.js]
64+
process.env.NODE_ENV || require ('./data-federation')
65+
```
66+
:::
67+
5568

5669

5770
## Mocked Out of the Box
@@ -166,12 +179,12 @@ For Java, make sure to add the `--with-mocks` option to the `cds deploy` command
166179

167180
## Run with Real Services
168181

169-
Instead of mocking required services by the imported APIs [using `cds mock` as shown above](#cds-mock), we can also run the real *xflights* service from its respective home folder which we [cloned already in the beginning](#the-xtravels-sample). We can combine that with `s4` still mocked from the imported API, as above.
182+
Instead of mocking required services by the imported APIs [using `cds mock` as shown above](#cds-mock), we can also run the real *xflights* and *s4* services from their respective home folders which we [cloned already in the beginning](#the-xtravels-sample).
170183

171184
Do so by running the following commands from within the `cap/samples` root folder in separate terminals, and in that order:
172185

173186
```shell :line-numbers=1
174-
cd xtravels; cds mock apis/capire/s4.cds
187+
cds watch s4
175188
```
176189
```shell :line-numbers=2
177190
cds watch xflights
@@ -200,10 +213,10 @@ In the log output of the xtravels server we should see that it _connects_ to the
200213

201214
We can use `cds repl` to experiment the options to send requests and queries to remote services interactively. Do so as follows...
202215

203-
From within the xtravels project's root folder `cap/samples/xtravels`, start by mocking the remote services in separate terminals, then start xtravels server within `cds repl` (instead of `cds watch`) in a third terminal:
216+
From within the xtravels project's root folder `cap/samples/xtravels`, start by again running the remote services in separate terminals, then start xtravels server again in a third terminal, this time within `cds repl` instead of `cds watch`:
204217
205218
```shell :line-numbers=1
206-
cd xtravels; cds mock apis/capire/s4.cds
219+
cds watch s4
207220
```
208221
209222
```shell :line-numbers=2

0 commit comments

Comments
 (0)