Skip to content
This repository was archived by the owner on Mar 13, 2021. It is now read-only.

Commit ced0e0d

Browse files
committed
Release v0.3.0
1 parent bf764bf commit ced0e0d

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

README.md

+13-17
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,40 @@ module.exports.$interactionModel = 'request-reply';
3939
Streaming functions must comply to the following signature:
4040
```js
4141
module.exports = (inputStreams, outputStreams) => {
42-
const firstInputStream = inputStreams.$order[0];
43-
const firstOutputStream = outputStreams.$order[0];
44-
const secondOutputStream = outputStreams.$order[1];
42+
const { numbers, letters } = inputStreams;
43+
const { repetitions } = outputStreams;
4544
// do something
4645
};
4746
module.exports.$interactionModel = 'node-streams';
4847
```
4948

5049
Please note that streaming functions must always declare the corresponding interaction mode.
5150

52-
Parameters can also be looked up by name:
51+
Streams can also be looked up by index:
5352
```js
5453
module.exports = (inputStreams, outputStreams) => {
55-
const { numbers, letters } = inputStreams;
56-
const { repetitions } = outputStreams;
54+
const firstInputStream = inputStreams.$order[0];
55+
const firstOutputStream = outputStreams.$order[0];
56+
const secondOutputStream = outputStreams.$order[1];
5757
// do something
5858
};
5959
module.exports.$interactionModel = 'node-streams';
6060
```
6161

62-
6362
Input streams are [Readable streams](https://nodejs.org/api/stream.html#stream_readable_streams).
6463

6564
Output streams are [Writable streams](https://nodejs.org/api/stream.html#stream_class_stream_readable).
6665

6766
The function **must** end the output streams when it is done emitting data or when an error occurs
6867
(if the output streams are [`pipe`](https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options)'d from
69-
input streams, then this is automatically managed by this invoker).
68+
input streams, then this is automatically managed).
7069

7170
## Message support
7271

7372
A message is an object that contains both headers and a payload.
7473
Message headers are a map with case-insensitive keys and multiple string values.
7574

76-
Since JavaScript and Node have no built-in type for messages or headers, riff uses the [@projectriff/message](https://github.com/projectriff/node-message/) npm module. To use messages, functions should install the `@projectriff/message` package:
77-
```bash
78-
npm install --save @projectriff/message
79-
```
75+
Since JavaScript and Node have no built-in type for messages or headers, riff uses the [@projectriff/message](https://github.com/projectriff/node-message/) npm module.
8076

8177
By default, request-reply functions accept and produce payloads.
8278
They can be configured instead to **receive** either the entire message or the headers only.
@@ -87,8 +83,6 @@ They can be configured instead to **receive** either the entire message or the h
8783
##### Receiving messages
8884

8985
```js
90-
const { Message } = require('@projectriff/message');
91-
9286
// a request-reply function that accepts a message, which is an instance of Message
9387
module.exports = message => {
9488
const authorization = message.headers.getValue('Authorization');
@@ -101,6 +95,11 @@ module.exports.$argumentType = 'message';
10195

10296
##### Producing messages
10397

98+
To produce messages, functions should install the `@projectriff/message` package:
99+
```bash
100+
npm install --save @projectriff/message
101+
```
102+
104103
```js
105104
const { Message } = require('@projectriff/message');
106105

@@ -115,9 +114,6 @@ module.exports = name => {
115114
.payload(`Hello ${name}!`)
116115
.build();
117116
};
118-
119-
// even if the function receives payloads, it can still produce a message
120-
module.exports.$argumentType = 'payload';
121117
```
122118

123119
## Lifecycle

npm-shrinkwrap.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@projectriff/node-function-invoker",
3-
"version": "0.2.2-snapshot",
3+
"version": "0.3.0",
44
"description": "riff invoker for Node functions",
55
"main": "lib/invoker.js",
66
"repository": "[email protected]:projectriff/node-function-invoker.git",

0 commit comments

Comments
 (0)