-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#30 async example
- Loading branch information
Showing
6 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Async Gateway | ||
|
||
## Testing | ||
|
||
Run: | ||
```bash | ||
go run main.go | ||
``` | ||
|
||
Run the following command: | ||
```bash | ||
curl --request GET http://localhost:9096/endpoint | ||
``` | ||
|
||
You should see: | ||
On the server screen, you get 200 response code and log service outputs "Output: Test log message service invoked" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/project-flogo/core/engine" | ||
"github.com/project-flogo/microgateway/examples" | ||
) | ||
|
||
func main() { | ||
e, err := examples.AsyncGatewayExample() | ||
if err != nil { | ||
panic(err) | ||
} | ||
engine.RunEngine(e) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Async Gateway | ||
This is an example of Async gateway. This receipe executes simple log action asynchronously | ||
|
||
|
||
#Log Activity | ||
| Name | Type | Description | | ||
|:-----------|:--------|:--------------| | ||
| message | string | The message to log | | ||
| addDetails | string | If set to true this will append the execution information to the log message | | ||
|
||
|
||
## Installation | ||
* Install [Go](https://golang.org/) | ||
* Install the flogo [cli](https://github.com/project-flogo/cli) | ||
|
||
## Setup | ||
```bash | ||
git clone https://github.com/project-flogo/microgateway | ||
cd microgateway/examples/api/default-http-pattern | ||
``` | ||
|
||
## Testing | ||
Create the gateway: | ||
``` | ||
flogo create -f flogo.json | ||
cd MyProxy | ||
flogo install github.com/project-flogo/contrib/activity/log | ||
flogo build | ||
``` | ||
|
||
Start the gateway: | ||
``` | ||
bin/MyProxy | ||
and test below scenario. | ||
Run the following command: | ||
```bash | ||
curl --request GET http://localhost:9096/endpoint | ||
``` | ||
|
||
You should see: | ||
On the server screen, you get 200 response code and log service outputs "Output: Test log message service invoked" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"name": "MyProxy", | ||
"type": "flogo:app", | ||
"version": "1.0.0", | ||
"description": "This is an example for async microgateway.", | ||
"properties": null, | ||
"channels": null, | ||
"triggers": [ | ||
{ | ||
"name": "flogo-rest", | ||
"id": "MyProxy", | ||
"ref": "github.com/project-flogo/contrib/trigger/rest", | ||
"settings": { | ||
"port": "9096" | ||
}, | ||
"handlers": [ | ||
{ | ||
"settings": { | ||
"method": "GET", | ||
"path": "/endpoint" | ||
}, | ||
"actions": [ | ||
{ | ||
"id": "microgateway:Log" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"resources": [ | ||
{ | ||
"id": "microgateway:Log", | ||
"compressed": false, | ||
"data": { | ||
"name": "Log", | ||
"steps": [ | ||
{ | ||
"service": "LogService", | ||
"input": { | ||
"message": "Output: Test log message service invoked" | ||
} | ||
} | ||
], | ||
"responses": [ | ||
{ | ||
"error": false, | ||
"output": { | ||
"code": 200, | ||
"data": "Successful call to action" | ||
} | ||
} | ||
], | ||
"services": [ | ||
{ | ||
"name": "LogService", | ||
"description": "simple Log service", | ||
"ref": "github.com/project-flogo/contrib/activity/log", | ||
"settings": { | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"actions": [ | ||
{ | ||
"ref": "github.com/project-flogo/microgateway", | ||
"settings": { | ||
"uri": "microgateway:Log", | ||
"async": true | ||
}, | ||
"id": "microgateway:Log", | ||
"metadata": null | ||
} | ||
] | ||
} |