diff --git a/action_test.go b/action_test.go index 93da50e..587de71 100644 --- a/action_test.go +++ b/action_test.go @@ -10,6 +10,7 @@ import ( "github.com/project-flogo/contrib/activity/rest" coreactivity "github.com/project-flogo/core/activity" "github.com/project-flogo/core/api" + "github.com/project-flogo/core/engine/channels" microapi "github.com/project-flogo/microgateway/api" "github.com/project-flogo/microgateway/internal/testing/activity" "github.com/project-flogo/microgateway/internal/testing/trigger" @@ -294,13 +295,17 @@ func TestMicrogatewayChannelPattern(t *testing.T) { assert.Nil(t, err) action, err := handler.NewAction(&Action{}, map[string]interface{}{ - "pattern": "DefaultChannelPattern", - "useJWT": false, - "useCircuitBreaker": false, + "pattern": "DefaultChannelPattern", + "useJWT": false, + "channel": "test", + "value": "test", }) assert.Nil(t, err) assert.NotNil(t, action) + _, err = channels.New("test", 5) + assert.Nil(t, err) + e, err := api.NewEngine(app) assert.Nil(t, err) e.Start() diff --git a/docs/default-channel-pattern.md b/docs/default-channel-pattern.md new file mode 100644 index 0000000..175200b --- /dev/null +++ b/docs/default-channel-pattern.md @@ -0,0 +1,83 @@ +# Gateway using Default Channel Pattern +Link: https://github.com/project-flogo/microgateway/internal/pattern/DefaultChannelPattern.json +Examples: +https://github.com/project-flogo/microgateway/examples/api/default-channel-pattern +https://github.com/project-flogo/microgateway/examples/json/default-channel-pattern + + + +This recipe is a gateway using the defult channel pattern which uses JWT. +This receipe uses 2 triggers. +1. REST trigger:- For calling the channel pattern +Link: https://github.com/project-flogo/contrib/trigger/rest + +2. Channel Trigger:- For calling second microgateway action +Link: https://github.com/project-flogo/contrib/trigger/channel + +Channel Pattern: +Channels allow one action to call another action. Channel pattern checks for JWT conditions. +If valid ... it runs corresponding channel activity and message is sent over the channel defined by its name. +Channel trigger then receives the message from channel and corresponding action (eg: log activity) is called. + + +#Channel Activity +| Name | Type | Description | +|:-----------|:--------|:--------------| +| channel | string | The channel to put the value on | +| value | string | The value to put on channel | + +Link: https://github.com/project-flogo/contrib/activity/channel + + +#JWT +| Name | Type | Description | +|:-----------|:--------|:--------------| +| token | string | The raw token | +| key | string | The key used to sign the token | +| signingMethod | string | The signing method used (HMAC, ECDSA, RSA, RSAPSS) | +| issuer | string | The 'iss' standard claim to match against | +| subject | string | The 'sub' standard claim to match against | +| audience | string | The 'aud' standard claim to match against | + +Link: https://github.com/project-flogo/microgateway/activity/jwt + + +## Installation +* Install [Go](https://golang.org/) + +## Setup +```bash +git clone https://github.com/project-flogo/microgateway +cd microgateway/examples/api/default-http-pattern +``` + +## Testing +Start the gateway: +```bash +go run main.go +``` + + +### Request is successful +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oKs" +``` + +You should see: +```json +{"response":"Success!"} +``` +On the server screen, you get 200 response code and log service outputs "Output: Test log message service invoked" + + +### JWT token is invalid +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oK" +``` + +You should see: +```json +{"errorMessage":"","validationMessage":"signature is invalid"} +``` diff --git a/docs/default-http-pattern.md b/docs/default-http-pattern.md new file mode 100644 index 0000000..d647160 --- /dev/null +++ b/docs/default-http-pattern.md @@ -0,0 +1,114 @@ +# Gateway using Default Http Pattern +This recipe is a gateway using the defult http pattern which uses JWT, Rate Limiter, and Circuit Breaker. +Link: https://github.com/project-flogo/microgateway/internal/pattern/DefaultHttpPattern.json +Examples: +https://github.com/project-flogo/microgateway/examples/api/default-http-pattern +https://github.com/project-flogo/microgateway/examples/json/default-http-pattern + + +Http Pattern: +Pattern checks for JWT, Ratelimiter and CircuitBreaker conditions. +If valid ... it runs corresponding activity. +This receipe uses REST trigger. +1. REST trigger:- For calling the http pattern +Link: https://github.com/project-flogo/contrib/trigger/rest + + +#Circuit Breaker Service: +| Name | Type | Description | +|:-----------|:--------|:--------------| +| mode | string | The tripping mode: 'a' for contiguous errors, 'b' for errors within a time period, 'c' for contiguous errors within a time period, and 'd' for a probabilistic smart circuit breaker mode. Defaults to mode 'a' | +| threshold | number | The number of errors required for tripping| +| period | number | Number of seconds in which errors have to occur for the circuit breaker to trip. Applies to modes 'b' and 'c'| +| timeout | number | Number of seconds that the circuit breaker will remain tripped. Applies to modes 'a', 'b', 'c'| + +Link: https://github.com/project-flogo/microgateway/activity/circuitbreaker + + +#Rate Limiter +| Name | Type | Description | +|:-----------|:--------|:--------------| +| limit | string | Limit can be specifed in the format of "limit-period". Valid periods are 'S', 'M' & 'H' to represent Second, Minute & Hour. Example: "10-S" represents 10 request/second | + +Link: https://github.com/project-flogo/microgateway/activity/ratelimiter + + + +#JWT +| Name | Type | Description | +|:-----------|:--------|:--------------| +| token | string | The raw token | +| key | string | The key used to sign the token | +| signingMethod | string | The signing method used (HMAC, ECDSA, RSA, RSAPSS) | +| issuer | string | The 'iss' standard claim to match against | +| subject | string | The 'sub' standard claim to match against | +| audience | string | The 'aud' standard claim to match against | + +Link: https://github.com/project-flogo/microgateway/activity/jwt + + + +## Installation +* Install [Go](https://golang.org/) + +## Setup +```bash +git clone https://github.com/project-flogo/microgateway +cd microgateway/examples/api/default-http-pattern +``` + +## Testing +Start the gateway: +```bash +go run main.go +``` +and test below scenario. + +In another terminal start the server: +```bash +go run main.go -server +``` + +### Request is successful +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oKs" +``` + +You should see: +```json +{"category":{"id":0,"name":"string"},"id":1,"name":"sally","photoUrls":["string"],"status":"available","tags":[{"id":0,"name":"string"}]} +``` + +### JWT token is invalid +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oK" +``` + +You should see: +```json +{"errorMessage":"","validationMessage":"signature is invalid"} +``` + +### Rate limit is exceeded +Run the following command faster the 1 per second: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oKs" +``` + +You should see: +```json +{"status":"Rate Limit Exceeded - The service you have requested is over the allowed limit."} +``` + +### Circuit breaker tripped +Stop the server and run the following command 6 times: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oKs" +``` + +You should see: +```json +{"error":"circuit breaker tripped"} +``` diff --git a/examples/api/default-channel-pattern/README.md b/examples/api/default-channel-pattern/README.md new file mode 100644 index 0000000..8670ad6 --- /dev/null +++ b/examples/api/default-channel-pattern/README.md @@ -0,0 +1,60 @@ +# Gateway using Default Channel Pattern +This recipe is a gateway using the defult channel pattern which uses JWT. + +#Channel Activity +| Name | Type | Description | +|:-----------|:--------|:--------------| +| channel | string | The channel to put the value on | +| value | string | The value to put on channel | + + +#JWT +| Name | Type | Description | +|:-----------|:--------|:--------------| +| token | string | The raw token | +| key | string | The key used to sign the token | +| signingMethod | string | The signing method used (HMAC, ECDSA, RSA, RSAPSS) | +| issuer | string | The 'iss' standard claim to match against | +| subject | string | The 'sub' standard claim to match against | +| audience | string | The 'aud' standard claim to match against | + + +## Installation +* Install [Go](https://golang.org/) + +## Setup +```bash +git clone https://github.com/project-flogo/microgateway +cd microgateway/examples/api/default-http-pattern +``` + +## Testing +Start the gateway: +```bash +go run main.go +``` + + +### Request is successful +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oKs" +``` + +You should see: +```json +{"response":"Success!"} +``` +On the server screen, you get 200 response code and log service outputs "Output: Test log message service invoked" + + +### JWT token is invalid +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oK" +``` + +You should see: +```json +{"errorMessage":"","validationMessage":"signature is invalid"} +``` diff --git a/examples/api/default-channel-pattern/main.go b/examples/api/default-channel-pattern/main.go new file mode 100644 index 0000000..871f54a --- /dev/null +++ b/examples/api/default-channel-pattern/main.go @@ -0,0 +1,20 @@ +package main + +import ( + + "github.com/project-flogo/core/engine" + "github.com/project-flogo/microgateway/examples" + _ "github.com/project-flogo/microgateway/activity/circuitbreaker" + _ "github.com/project-flogo/microgateway/activity/jwt" + _ "github.com/project-flogo/contrib/activity/channel" +) + + +func main() { + + e, err := examples.DefaultChannelPattern() + if err != nil { + panic(err) + } + engine.RunEngine(e) +} diff --git a/examples/api/default-http-pattern/main.go b/examples/api/default-http-pattern/main.go index 3255f34..d460e63 100644 --- a/examples/api/default-http-pattern/main.go +++ b/examples/api/default-http-pattern/main.go @@ -21,7 +21,8 @@ var ( const reply = `{ "id": 1, - "category": { "id": 0, + "category": { + "id": 0, "name": "string" }, "name": "sally", diff --git a/examples/examples.go b/examples/examples.go index a2a8516..7674436 100644 --- a/examples/examples.go +++ b/examples/examples.go @@ -1,10 +1,13 @@ package examples import ( + "github.com/project-flogo/contrib/activity/log" "github.com/project-flogo/contrib/activity/rest" + channeltrigger "github.com/project-flogo/contrib/trigger/channel" trigger "github.com/project-flogo/contrib/trigger/rest" "github.com/project-flogo/core/api" "github.com/project-flogo/core/engine" + "github.com/project-flogo/core/engine/channels" "github.com/project-flogo/microgateway" microapi "github.com/project-flogo/microgateway/api" ) @@ -162,3 +165,64 @@ func DefaultHTTPPattern() (engine.Engine, error) { return api.NewEngine(app) } + +func DefaultChannelPattern() (engine.Engine, error) { + app := api.NewApp() + + trg := app.NewTrigger(&trigger.Trigger{}, &trigger.Settings{Port: 9096}) + handler, err := trg.NewHandler(&trigger.HandlerSettings{ + Method: "GET", + Path: "/endpoint", + }) + if err != nil { + panic(err) + } + + _, err = handler.NewAction(µgateway.Action{}, map[string]interface{}{ + "pattern": "DefaultChannelPattern", + "useJWT": true, + "jwtSigningMethod": "HMAC", + "jwtKey": "qwertyuiopasdfghjklzxcvbnm789101", + "jwtAud": "www.mashling.io", + "jwtIss": "Mashling", + "jwtSub": "tempuser@mail.com", + "channel": "test", + "value": "test", + }) + if err != nil { + panic(err) + } + + // channel + _, err = channels.New("test", 5) + if err != nil { + panic(err) + } + + gateway := microapi.New("Log") + service := gateway.NewService("log", &log.Activity{}) + service.SetDescription("Invoking test Log service") + step := gateway.NewStep(service) + step.AddInput("message", "Output: Test log message service invoked") + response := gateway.NewResponse(false) + response.SetCode(200) + settings, err := gateway.AddResource(app) + if err != nil { + panic(err) + } + + channeltrg := app.NewTrigger(&channeltrigger.Trigger{}, nil) + channelhandler, err := channeltrg.NewHandler(&channeltrigger.HandlerSettings{ + Channel: "test", + }) + if err != nil { + panic(err) + } + + _, err = channelhandler.NewAction(µgateway.Action{}, settings) + if err != nil { + panic(err) + } + + return api.NewEngine(app) +} diff --git a/examples/examples_test.go b/examples/examples_test.go index e5a8143..4eb47a8 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -11,10 +11,11 @@ import ( "time" _ "github.com/project-flogo/contrib/activity/rest" - "github.com/project-flogo/core/engine" + _ "github.com/project-flogo/microgateway/activity/ratelimiter" _ "github.com/project-flogo/microgateway/activity/circuitbreaker" + "github.com/project-flogo/core/engine" _ "github.com/project-flogo/microgateway/activity/jwt" - _ "github.com/project-flogo/microgateway/activity/ratelimiter" + _ "github.com/project-flogo/contrib/activity/channel" "github.com/project-flogo/microgateway/api" test "github.com/project-flogo/microgateway/internal/testing" "github.com/stretchr/testify/assert" @@ -256,3 +257,61 @@ func TestDefaultHttpPatternJSON(t *testing.T) { assert.Nil(t, err) testDefaultHTTPPattern(t, e) } + + +func testDefaultChannelPattern(t *testing.T, e engine.Engine) { + defer api.ClearResources() + + test.Drain("9096") + err := e.Start() + assert.Nil(t, err) + defer func() { + err := e.Stop() + assert.Nil(t, err) + }() + test.Pour("9096") + + transport := &http.Transport{ + MaxIdleConns: 1, + } + defer transport.CloseIdleConnections() + client := &http.Client{ + Transport: transport, + } + request := func() string { + req, err := http.NewRequest(http.MethodGet, "http://localhost:9096/endpoint", nil) + assert.Nil(t, err) + response, err := client.Do(req) + assert.Nil(t, err) + body, err := ioutil.ReadAll(response.Body) + assert.Nil(t, err) + response.Body.Close() + return string(body) + } + + body := request() + assert.NotEqual(t, 0, len(body)) +} + +func TestDefaultChannelPatternAPI(t *testing.T) { + if testing.Short() { + t.Skip("skipping Basic Gateway API integration test in short mode") + } + + e, err := DefaultChannelPattern() + assert.Nil(t, err) + testDefaultChannelPattern(t, e) +} + +func TestDefaultChannelPatternJSON(t *testing.T) { + if testing.Short() { + t.Skip("skipping Basic Gateway JSON integration test in short mode") + } + data, err := ioutil.ReadFile(filepath.FromSlash("./json/default-channel-pattern/flogo.json")) + assert.Nil(t, err) + cfg, err := engine.LoadAppConfig(string(data), false) + assert.Nil(t, err) + e, err := engine.New(cfg) + assert.Nil(t, err) + testDefaultChannelPattern(t, e) +} diff --git a/examples/json/default-channel-pattern/README.md b/examples/json/default-channel-pattern/README.md new file mode 100644 index 0000000..7fe51ea --- /dev/null +++ b/examples/json/default-channel-pattern/README.md @@ -0,0 +1,70 @@ +# Gateway using Default Channel Pattern +This recipe is a gateway using the defult channel pattern which uses JWT. + +#JWT +| Name | Type | Description | +|:-----------|:--------|:--------------| +| token | string | The raw token | +| key | string | The key used to sign the token | +| signingMethod | string | The signing method used (HMAC, ECDSA, RSA, RSAPSS) | +| issuer | string | The 'iss' standard claim to match against | +| subject | string | The 'sub' standard claim to match against | +| audience | string | The 'aud' standard claim to match against | + +#Channel Activity +| Name | Type | Description | +|:-----------|:--------|:--------------| +| channel | string | The channel to put the value on | +| value | string | The value to put on channel | + + +## 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/rest +flogo install github.com/project-flogo/microgateway/activity/jwt +flogo install github.com/project-flogo/contrib/activity/channel +flogo build +``` + +Start the gateway: +``` +bin/MyProxy + +and test below scenario. + +### Request is successful +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oKs" +``` + +You should see: +```json +{"response":"Success!"} +``` +On the server screen, you get 200 response code and log service outputs "Output: Test log message service invoked" + + +### JWT token is invalid +Run the following command: +```bash +curl --request GET http://localhost:9096/endpoint -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJNYXNobGluZyIsImlhdCI6MTU0NDEzMTYxOCwiZXhwIjoxNTc1NjY3NjE4LCJhdWQiOiJ3d3cubWFzaGxpbmcuaW8iLCJzdWIiOiJ0ZW1wdXNlckBtYWlsLmNvbSJ9.wgunWSIJqieRKsmObATT2VEHMMzkKte6amuUlhc1oK" +``` + +You should see: +```json +{"errorMessage":"","validationMessage":"signature is invalid"} +``` diff --git a/examples/json/default-channel-pattern/flogo.json b/examples/json/default-channel-pattern/flogo.json new file mode 100644 index 0000000..aa69e0f --- /dev/null +++ b/examples/json/default-channel-pattern/flogo.json @@ -0,0 +1,108 @@ +{ + "name": "MyProxy", + "type": "flogo:app", + "version": "1.0.0", + "description": "This is a simple proxy.", + "properties": null, + "channels": [ + "test:5" + ], + "triggers": [ + { + "name": "flogo-rest", + "id": "MyProxy", + "ref": "github.com/project-flogo/contrib/trigger/rest", + "settings": { + "port": "9096" + }, + "handlers": [ + { + "settings": { + "method": "GET", + "path": "/endpoint" + }, + "actions": [ + { + "ref": "github.com/project-flogo/microgateway", + "settings": { + "pattern": "DefaultChannelPattern", + "useJWT": true, + "jwtSigningMethod": "HMAC", + "jwtKey": "qwertyuiopasdfghjklzxcvbnm789101", + "jwtAud": "www.mashling.io", + "jwtIss": "Mashling", + "jwtSub": "tempuser@mail.com", + "channel": "test", + "value": "test" + } + } + ] + } + ] + }, + { + "name": "flogo-channel", + "id": "MyChannelProxy", + "ref": "github.com/project-flogo/contrib/trigger/channel", + "settings": { + }, + "handlers": [ + { + "settings": { + "channel": "test" + }, + "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" + }, + "id": "microgateway:Log", + "metadata": null + } + ] +} diff --git a/go.mod b/go.mod index 1f4fd18..b8053ad 100644 --- a/go.mod +++ b/go.mod @@ -12,8 +12,8 @@ require ( github.com/google/flatbuffers v1.10.0 // indirect github.com/leesper/go_rng v0.0.0-20171009123644-5344a9259b21 // indirect github.com/pkg/errors v0.8.0 // indirect - github.com/project-flogo/contrib v0.9.0-alpha.3.0.20190115023822-118c915f5736 - github.com/project-flogo/core v0.9.0-alpha.4.0.20190116201316-ba1703f1f4cf + github.com/project-flogo/contrib v0.9.0-alpha.3.0.20190211153431-680ebf186e58 + github.com/project-flogo/core v0.9.0-alpha.4.0.20190220191401-07116138c345 github.com/stretchr/objx v0.1.1 // indirect github.com/stretchr/testify v1.2.2 github.com/ulule/limiter v2.2.0+incompatible diff --git a/go.sum b/go.sum index ada7bc9..7b9220b 100644 --- a/go.sum +++ b/go.sum @@ -38,6 +38,8 @@ github.com/pointlander/core v0.9.0-alpha.0.0.20181102192353-c6bcaae4c33f h1:tGng github.com/pointlander/core v0.9.0-alpha.0.0.20181102192353-c6bcaae4c33f/go.mod h1:BHeB55AxPhvlNGd+it50rE977ag6xE3bD2RluSDeKBA= github.com/pointlander/core v0.9.0-alpha.0.0.20190115220707-01b9cad3c178 h1:sPojCVyc6nRZqFsJju/4txUWK+Z8yz9RXtQYBz01VOc= github.com/pointlander/core v0.9.0-alpha.0.0.20190115220707-01b9cad3c178/go.mod h1:BHeB55AxPhvlNGd+it50rE977ag6xE3bD2RluSDeKBA= +github.com/pointlander/core v0.9.0-alpha.0.0.20190220184728-615799d1e40b h1:e5gjLKzpw7VziFqq4/8afKmXx/I3ghLjt8OoTY0ewHQ= +github.com/pointlander/core v0.9.0-alpha.0.0.20190220184728-615799d1e40b/go.mod h1:Dof6t60n/nvN7aPpoUz97JL+VIKdsYMbhqwN++WCdz8= github.com/project-flogo/contrib v0.0.0-20181102044714-faa70a874eed h1:ovwna9Fk6kCsGpwXv/9lIBCozolTzHAO2oICscByD0U= github.com/project-flogo/contrib v0.0.0-20181102044714-faa70a874eed/go.mod h1:4kkrCbxbMG1J4cfwZohIHaTDUkgjK7ICodU2czRgIbg= github.com/project-flogo/contrib v0.0.0-20181103024438-71cb103ef1ab h1:SVilfDqHc/FO2tJkIg4hcVZu2qR5jzYkzbFFvO3qkio= @@ -46,6 +48,8 @@ github.com/project-flogo/contrib v0.9.0-alpha.3.0.20181105173100-2e8b1851a5ac h1 github.com/project-flogo/contrib v0.9.0-alpha.3.0.20181105173100-2e8b1851a5ac/go.mod h1:1RHAPbNoZcLQacY5XOd7zwO+AkoCsww9OJF/pDdWTkk= github.com/project-flogo/contrib v0.9.0-alpha.3.0.20190115023822-118c915f5736 h1:39J/KsTIzIAZ4bxn9QyKoTWpwHFEMBuScuWYfIxX4gk= github.com/project-flogo/contrib v0.9.0-alpha.3.0.20190115023822-118c915f5736/go.mod h1:tdinBFJomgOs2xQJCc3igHomrCeu2JaHu1EbuYb56Ww= +github.com/project-flogo/contrib v0.9.0-alpha.3.0.20190211153431-680ebf186e58 h1:L3qUPNpuHxLUJh+mtQGSanFwfFMT9WccaKemhDTpiQk= +github.com/project-flogo/contrib v0.9.0-alpha.3.0.20190211153431-680ebf186e58/go.mod h1:tdinBFJomgOs2xQJCc3igHomrCeu2JaHu1EbuYb56Ww= github.com/project-flogo/core v0.9.0-alpha.2/go.mod h1:BHeB55AxPhvlNGd+it50rE977ag6xE3bD2RluSDeKBA= github.com/project-flogo/core v0.9.0-alpha.2.0.20181102174659-cb0e18f709b5 h1:86cBHJmAqybh1NBXssPRNVhveU0Vtd1bFmuE0rsD95I= github.com/project-flogo/core v0.9.0-alpha.2.0.20181102174659-cb0e18f709b5/go.mod h1:BHeB55AxPhvlNGd+it50rE977ag6xE3bD2RluSDeKBA= @@ -59,6 +63,8 @@ github.com/project-flogo/core v0.9.0-alpha.4.0.20190115151814-9af0a55fd853 h1:ZJ github.com/project-flogo/core v0.9.0-alpha.4.0.20190115151814-9af0a55fd853/go.mod h1:BHeB55AxPhvlNGd+it50rE977ag6xE3bD2RluSDeKBA= github.com/project-flogo/core v0.9.0-alpha.4.0.20190116201316-ba1703f1f4cf h1:8ix+yZGUm+bliXHrm2jKTFUV6IPa+3U4DR9s9dq326Y= github.com/project-flogo/core v0.9.0-alpha.4.0.20190116201316-ba1703f1f4cf/go.mod h1:BHeB55AxPhvlNGd+it50rE977ag6xE3bD2RluSDeKBA= +github.com/project-flogo/core v0.9.0-alpha.4.0.20190220191401-07116138c345 h1:UXb1zbj3FTOP4m04AKEnCE/q5xjNNodGsSmcLLt4KsU= +github.com/project-flogo/core v0.9.0-alpha.4.0.20190220191401-07116138c345/go.mod h1:Dof6t60n/nvN7aPpoUz97JL+VIKdsYMbhqwN++WCdz8= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= diff --git a/internal/pattern/DefaultChannelPattern.json b/internal/pattern/DefaultChannelPattern.json index ff9b815..44fbbe0 100644 --- a/internal/pattern/DefaultChannelPattern.json +++ b/internal/pattern/DefaultChannelPattern.json @@ -9,34 +9,14 @@ "key": "=$.conf.jwtKey" } }, - { - "if": "$.conf.useCircuitBreaker == true", - "service": "CircuitBreaker" - }, { "if": "$.conf.useJWT == false || $.JWTValidator.outputs.valid == true", "service": "ActionBackend", "input": { - "inputs": { - "channel": "test", - "value": "test" - } + "channel": "=$.conf.channel", + "value": "=$.conf.value" }, "halt": "false" - }, - { - "if": "$.conf.useCircuitBreaker == true && $.ActionBackend.error != nil", - "service": "CircuitBreaker", - "input": { - "operation": "counter" - } - }, - { - "if": "$.conf.useCircuitBreaker == true && $.ActionBackend.error == nil", - "service": "CircuitBreaker", - "input": { - "operation": "reset" - } } ], "responses": [ @@ -50,16 +30,6 @@ } } }, - { - "if": "$.conf.useCircuitBreaker == true && $.CircuitBreaker.outputs.tripped == true", - "error": true, - "output": { - "code": 403, - "data": { - "error": "circuit breaker tripped" - } - } - }, { "error": false, "output": { @@ -76,14 +46,6 @@ "description": "Validate some tokens", "ref": "github.com/project-flogo/microgateway/activity/jwt" }, - { - "name": "CircuitBreaker", - "description": "Circuit breaker service", - "ref": "github.com/project-flogo/microgateway/activity/circuitbreaker", - "settings": { - "mode": "a" - } - }, { "name": "ActionBackend", "description": "Make an action call to your backend", diff --git a/internal/pattern/assets.go b/internal/pattern/assets.go index 2b2333f..4028133 100644 --- a/internal/pattern/assets.go +++ b/internal/pattern/assets.go @@ -1,9 +1,7 @@ -// Code generated by go-bindata. +// Code generated by go-bindata. DO NOT EDIT. @generated // sources: // DefaultHttpPattern.json // DefaultChannelPattern.json -// DO NOT EDIT! - package pattern import ( @@ -84,12 +82,12 @@ func defaulthttppatternJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4653, mode: os.FileMode(420), modTime: time.Unix(1549574923, 0)} + info := bindataFileInfo{name: "DefaultHttpPattern.json", size: 4653, mode: os.FileMode(420), modTime: time.Unix(1550003149, 0)} a := &asset{bytes: bytes, info: info} return a, nil } -var _defaultchannelpatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x55\xcd\x6e\xdb\x3c\x10\xbc\xfb\x29\x36\x84\x91\x53\x3e\x39\x5f\xdb\x93\x01\x1f\x92\xf4\x94\x22\x40\x81\x06\xcd\xa1\xe8\x61\x4d\xad\x6d\xda\x32\x29\x90\x4b\x1b\x6a\xe2\x77\x2f\x44\xfd\xd8\x12\x64\x45\x81\x7b\xb1\x01\x72\x7f\x66\x66\x67\xc5\xd7\x11\x80\xd0\xb8\x25\x31\x05\xf1\x95\x16\xe8\x13\x7e\x58\xa1\xd6\x94\x7c\x47\x66\xb2\x5a\xdc\xe4\x21\x8e\x29\x75\x62\x0a\xbf\x46\x00\x00\xaf\xe1\x17\x40\xa8\x45\x9e\x37\x8e\xa4\xd1\x8b\xc8\x3b\x7a\x7c\x79\x86\xd9\x0c\xd8\x7a\x0a\x79\x21\xc8\x91\xdd\x29\x19\x3a\x3c\xbe\x3c\xff\xc4\x44\xc5\xc8\xc6\x1e\x03\x94\x4e\x3d\x8b\x69\x5d\x16\x40\xb0\xd9\x90\xce\x33\x66\xe3\x28\xc5\x2c\x31\x18\x47\x2b\xc2\x98\xac\x8b\xee\x3c\xaf\x8c\x55\x7f\x90\x95\xd1\x75\x15\x00\xb1\xa1\xac\x4c\x09\x78\xd6\x7b\xfe\x46\x99\x28\xef\x0f\xe1\xff\x70\xd3\x4f\xe0\x41\x59\xe9\x15\xdf\x5b\xc2\x0d\xd9\x5e\x2e\xcd\x50\x31\xa8\x7c\xa9\xcf\x02\x13\x47\xf0\xf6\x06\xe3\xe8\x54\x91\xc8\x78\x4e\x3d\xbb\x68\x97\x9f\xf4\x36\xbf\x93\x39\xf9\x7b\x94\x1b\xd2\x71\xaf\x92\xe1\xc8\x35\xce\x00\x84\x2c\x66\x9c\x97\x62\x72\x7c\xa2\x22\x80\xd8\x61\xe2\xa9\xbe\xaa\x6f\x0e\x95\x92\x75\xbb\x15\x26\x79\x37\x11\xf8\x0c\x53\xa0\x5b\x60\xb8\xbe\x86\x71\xd4\x20\x15\x91\xb5\xc6\xc2\xd5\x0c\xb4\x4a\x86\x0c\xa0\x4f\x04\x93\x92\x2d\xec\x32\x05\x21\x8d\xd7\x5c\x4d\xec\x32\x63\x9c\xc7\x3d\xfb\xf7\xb8\x2d\x39\xe2\x16\xea\x11\xc0\xef\xb0\xa0\x96\x5c\x6a\xb4\xa3\x8f\x2d\x69\x81\xbf\xdf\x83\xc5\x70\x6b\x94\x81\x9e\x98\x86\xf4\xfa\xb0\x48\x6a\x62\x97\x26\xce\xe9\x7e\xb9\xfd\xff\x64\x45\x63\x64\x6c\x7b\xb1\xaa\x98\x2f\x6e\x27\x94\x10\xf0\x44\xce\xe1\x92\x3a\xec\x78\xf1\xfc\x9a\x77\x75\x5b\xb6\x2a\x4d\xa9\x63\x0f\x3f\x2e\xc1\xe7\xa1\x12\xc8\x02\x0a\xcc\x4b\x9c\x25\x86\xa1\xac\xab\x3a\x61\x66\x43\xa0\x7d\xba\xbd\x7d\x07\x5a\x65\xac\x1c\xdd\x0f\x2f\x25\x39\x77\x75\x16\x4e\x6d\xc7\xd2\xee\x1d\x6e\xac\x1e\x9b\xee\xa7\x20\x26\x27\xad\x4a\x2b\xcb\x97\x11\x04\xce\x6c\x09\xc2\xa3\xe0\x8e\xc1\x96\xc2\x90\x97\x8a\x57\x7e\x1e\x49\xb3\x9d\xa4\xd6\xac\x49\xf2\x7f\x8b\xc4\x2c\xcd\x64\xab\xa4\x35\x4b\x64\xda\x63\x36\x41\xc9\x6a\xa7\x38\x9b\xac\xf7\xdc\xfd\xa9\xaa\x90\x9d\xdb\xcf\x16\xb6\x87\xd6\xa8\xaa\x0d\xbf\x10\x5e\xe9\x80\x79\xbb\xbb\x23\x66\xa5\x97\xcd\x2f\xb9\xd8\x16\x63\x14\xd8\xff\x35\xab\xa8\x9d\x79\x36\x5a\xcc\x9e\x70\x43\x80\x1a\x30\x44\x83\xc4\x24\x01\x36\x90\x19\x6f\x61\xde\xce\x7d\x8f\xa5\x34\x9a\xad\x9a\x9f\x10\x2c\x9f\x9e\xa3\x63\x46\x87\xd1\xdf\x00\x00\x00\xff\xff\xd9\x8a\xd0\x63\x88\x08\x00\x00") +var _defaultchannelpatternJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x94\x93\xc1\x6e\x1a\x31\x10\x86\xef\x3c\xc5\xd4\x42\x39\xa5\x0b\xad\x7a\x42\xe2\x90\xb6\xa7\x54\x91\x2a\x35\x6a\x0e\x55\x0f\x83\x77\x00\x83\xf1\xac\xec\x31\x68\x9b\xf0\xee\x95\xbd\xec\xb2\x45\x10\xd2\xcb\xae\x34\xfe\x67\xfc\xfd\x33\x9e\xe7\x01\x80\x72\xb8\x21\x35\x01\xf5\x95\xe6\x18\xad\x7c\x59\xa2\x73\x64\xbf\xa3\x08\x79\xa7\x6e\x93\x24\x08\x55\x41\x4d\xe0\xd7\x00\x00\xe0\x39\x7f\x01\x94\x99\xa7\xbc\x61\xa1\xd9\xcd\x8b\x18\xe8\xfe\xe9\x11\xa6\x53\x10\x1f\x29\xe7\x65\x51\x20\xbf\x35\x3a\xdf\x70\xff\xf4\xf8\x13\xad\x29\x51\xd8\x1f\x05\xc6\x55\x51\xd4\xa4\x2b\x0b\xa0\x84\xd7\xe4\x52\xc6\x74\x58\x54\x58\x5b\xc6\xb2\x58\x12\x96\xe4\x43\x71\x17\x65\xc9\xde\xfc\x41\x31\xec\xba\x2a\x00\x6a\x4d\xf5\x21\x25\xf3\xac\x76\xf2\x8d\x6a\x75\x38\xdf\xe7\xff\xfe\xf6\x4d\x06\xe6\x68\x03\xc1\xcb\x0b\x0c\x8b\x3e\x72\xc1\x51\xaa\x28\xa1\xd8\xa6\xc8\xab\x4e\xef\x74\xa2\xfb\x8c\x7a\x4d\xae\x7c\xd5\xaa\x6e\xda\xdd\x27\x6f\x43\x3d\x6f\x5b\xb4\x91\xfa\x9a\x26\xd0\x9a\xeb\x2e\x58\xa2\x4d\xf5\x55\x76\xd0\x1c\x27\xe7\xbf\xf3\x14\x3d\x85\x8a\x5d\xa0\xff\x9b\x24\xdc\xdc\x5c\xed\x43\x73\x5d\x47\x41\xde\xb3\x57\x93\x9c\xde\x05\x9b\xa4\x13\xf3\x5c\x26\x57\x9f\xc6\x1f\x7a\x5e\x4b\x14\xfc\x47\xd6\xab\x98\xfc\x9f\x45\xc9\x82\x07\x0a\x01\x17\x5d\x5b\xda\xa9\x5f\x9a\x7e\x5b\x34\xd3\xbf\x85\xf3\xe3\x78\x7c\x85\xb3\x6d\x71\x42\xfd\x11\xb5\xa6\x10\xde\x5d\xc4\xe9\x06\x73\x78\x38\x67\xe6\xd2\xee\xe6\xf9\xcd\x29\x29\x68\x6f\xaa\xbc\x08\x13\x50\x07\x05\x41\xe0\x0d\x41\xde\xa1\x70\x14\x7b\xca\x33\x5e\x18\x59\xc6\x59\xa1\x79\x33\xaa\x3c\xaf\x48\xcb\xfb\xb9\xe5\x05\x8f\x36\x46\x7b\x5e\xa0\xd0\x0e\xeb\x11\x6a\x31\x5b\x23\xf5\x68\xb5\x13\x75\xb6\x79\x2d\xd9\x85\x97\x7e\x82\xf6\x80\x6b\x02\x74\x80\x59\x0d\x1a\xad\x05\x61\xa8\x39\x7a\x98\x9d\xe6\x5e\x23\xd5\xec\xc4\x9b\xd9\x11\xb2\x5d\x98\x63\x5b\x07\xfb\xc1\xdf\x00\x00\x00\xff\xff\x5c\xb6\xd2\xe2\xdc\x04\x00\x00") func defaultchannelpatternJsonBytes() ([]byte, error) { return bindataRead( @@ -104,7 +102,7 @@ func defaultchannelpatternJson() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "DefaultChannelPattern.json", size: 2184, mode: os.FileMode(420), modTime: time.Unix(1549486667, 0)} + info := bindataFileInfo{name: "DefaultChannelPattern.json", size: 1244, mode: os.FileMode(420), modTime: time.Unix(1550687842, 0)} a := &asset{bytes: bytes, info: info} return a, nil }