Skip to content

Commit

Permalink
feat(http): ✨ parallel post with specific data for each url (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
matteo-cristino authored Jun 23, 2023
1 parent c26170d commit 378d393
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 50 deletions.
231 changes: 230 additions & 1 deletion docs/packages/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,233 @@ With this **keys**:

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents
#### Table of Contents

* [READ_REQUEST](#read_request)
* [EXTERNAL_CONNECTION](#external_connection)
* [Parameters](#parameters)
* [EXTERNAL_OUTPUT](#external_output)
* [Parameters](#parameters-1)
* [PASS_OUTPUT](#pass_output)
* [Parameters](#parameters-2)
* [POST_AND_SAVE_TO_VARIABLE](#post_and_save_to_variable)
* [Parameters](#parameters-3)
* [PARALLEL_GET](#parallel_get)
* [Parameters](#parameters-4)
* [PARALLEL_GET_ARRAY](#parallel_get_array)
* [Parameters](#parameters-5)
* [PARALLEL_POST](#parallel_post)
* [Parameters](#parameters-6)
* [PARALLEL_POST_ARRAY_WITHIN](#parallel_post_array_within)
* [Parameters](#parameters-7)
* [PARALLEL_POST_ARRAY](#parallel_post_array)
* [Parameters](#parameters-8)
* [PARALLEL_POST_ARRAY_DIFFERENT_DATA](#parallel_post_array_different_data)
* [Parameters](#parameters-9)

### READ_REQUEST

[packages/http/src/actions.ts:31-31](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L31-L31 "Source code on GitHub")

`Given I read the http request`<br><br>
Read the http_request that is coming form the outside, it will return
a dictionary of the following form:

{
http_request: {
base_url: '/api/http_request',
headers: {
'accept-encoding': 'gzip, deflate',
connection: 'close',
'content-length': '0',
host: '127.0.0.1:44267'
},
http_version: '1.1',
method: 'POST',
path: '/',
protocol: 'http',
socket: {
local_address: '::ffff:127.0.0.1',
local_port: 44267,
remote_address: '::ffff:127.0.0.1',
remote_family: 'IPv6',
remote_port: 59794
}
}
}

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

### EXTERNAL_CONNECTION

[packages/http/src/actions.ts:37-37](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L37-L37 "Source code on GitHub")

`Given I have a endpoint named 'myEndpoint'`<br><br>
Set the endpoint to be used later in the other statements

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myEndpoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the url's endpoint or the url's endpoint itself

### EXTERNAL_OUTPUT

[packages/http/src/actions.ts:44-44](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L44-L44 "Source code on GitHub")

`Given I connect to 'myEndpoint' and save the output into 'myResult'`<br><br>
Connect to *myEndpoint* and store the result into *myResult*

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myEndpoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the url's endpoint or the url's endpoint itself
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt

### PASS_OUTPUT

[packages/http/src/actions.ts:50-50](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L50-L50 "Source code on GitHub")

`Then I pass the output to 'myEndpoint'`<br><br>
Perform a post to *myEndpoint* with data the zencode output

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myEndpoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the url's endpoint or the url's endpoint itself

### POST_AND_SAVE_TO_VARIABLE

[packages/http/src/actions.ts:61-61](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L61-L61 "Source code on GitHub")

`Given I connect to 'myEndpoint' and pass it the content of 'myVariable' and save the output into 'myResult'`<br><br>
Perform a post to *myEndpoint* with data contained in *myVariable* and store the result in *myResult* which
will be a dictionary with two entries:

* **status**: will contain the status code
* **result**: in case of success will contain the result otherwise it is a empty string

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myEndpoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the url's endpoint or the url's endpoint itself
* `myVairable` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the post data
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt of the post

### PARALLEL_GET

[packages/http/src/actions.ts:72-72](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L72-L72 "Source code on GitHub")

`Given I execute parallel GET to 'myEndpoint' and save the result named 'myResult' within the object 'myObject'`<br><br>
By repeating this statment *n* times it will perform *n* parallel get to *myEndpoint* and store the result in
*myObject.myResult* which will be a dictionary with two entries:

* **status**: will contain the status code
* **result**: in case of success will contain the result otherwise it is a empty string

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myEndpoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the url's endpoint or the url's endpoint itself
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt of the get
* `myObject` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store myResult

### PARALLEL_GET_ARRAY

[packages/http/src/actions.ts:82-82](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L82-L82 "Source code on GitHub")

`Given I execute parallel GET to array 'myEndpointArray' and save the result named 'myResult' within the object 'myObject'`<br><br>
Perform parallel get to array *myEndpointArray* and store the result in *myObject.myResult* which will be an array of dictionary with two entries:

* **status**: will contain the status code
* **result**: in case of success will contain the result otherwise it is a empty string

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myEndpointArray` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the array of urls' endpoint
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt of the get
* `myObject` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store myResult

### PARALLEL_POST

[packages/http/src/actions.ts:94-94](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L94-L94 "Source code on GitHub")

`Given I execute parallel POST with 'myData' to 'myEndpoint' and save the result named 'myResult' within the object 'myObject'`<br><br>
By repeating this statment *n* times it will perform *n* parallel post to *myEndpoint* with data contained in *myData* and store the result in
*myObject.myResult* which will be an array of dictionary with two entries:

* **status**: will contain the status code
* **result**: in case of success will contain the result otherwise it is a empty string

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myData` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the data of the post
* `myEndpoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the url's endpoint
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt of the post
* `myObject` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store myResult

### PARALLEL_POST_ARRAY_WITHIN

[packages/http/src/actions.ts:106-106](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L106-L106 "Source code on GitHub")

`Given I execute parallel POST with 'myData' to array 'myEndpointArray' and save the result named 'myResult' within the object 'myObject'`<br><br>
Perform parallel post to array *myEndpointArray* with data contained in *myData* and store the result in
*myObject.myResult* which will be an array of dictionary with two entries:

* **status**: will contain the status code
* **result**: in case of success will contain the result otherwise it is a empty string

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myData` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the data of the post
* `myEndpointArray` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the array of urls' endpoint
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt of the post
* `myObject` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store myResult

### PARALLEL_POST_ARRAY

[packages/http/src/actions.ts:117-117](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L117-L117 "Source code on GitHub")

`Given I execute parallel POST with 'myData' to array 'myEndpointArray' and save the result named 'myResult'`<br><br>
Perform parallel post to array *myEndpointArray* with data contained in *myData* and store the result in
*myResult* which will be an array of dictionary with two entries:

* **status**: will contain the status code
* **result**: in case of success will contain the result otherwise it is a empty string

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myData` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the data of the post
* `myEndpointArray` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the array of urls' endpoint
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt of the post

### PARALLEL_POST_ARRAY_DIFFERENT_DATA

[packages/http/src/actions.ts:128-128](https://github.com/dyne/restroom-mw/blob/8db4074a7fb710ca3898d2dbf1660f32b07114d4/packages/http/src/actions.ts#L128-L128 "Source code on GitHub")

`Given I execute parallel POST with array 'myDataArray' to array 'myEndpointArray' and save the result named 'myResult'`<br><br>
Perform parallel post to array *myEndpointArray* and for the *n-th* endpoint uses the *n-th* entry found in the *myDataArray* as data
and store the result in *myResult* which will be an array of dictionary with two entries:

* **status**: will contain the status code
* **result**: in case of success will contain the result otherwise it is a empty string

Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)

#### Parameters

* `myDataArray` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the array of data of the post
* `myEndpointArray` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the variable containing the array of urls' endpoint
* `myResult` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of the varibale where will be store the reuslt of the post
Loading

0 comments on commit 378d393

Please sign in to comment.