-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from project-flogo/master
update
- Loading branch information
Showing
79 changed files
with
869 additions
and
290 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,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2018, TIBCO Software Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of TIBCO Software Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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 |
---|---|---|
@@ -1 +1,66 @@ | ||
EXPERIMENTAL, DO NOT USE | ||
# Flogo Contrib | ||
|
||
[![Build Status](https://travis-ci.org/project-flogo/contrib.svg?branch=master)](https://travis-ci.org/project-flogo/contrib.svg?branch=master) | ||
|
||
Core collection of Flogo contributions. This repository consists of activities, triggers and functions. | ||
|
||
## Contributions | ||
|
||
### Activities | ||
* [actreply](activity/actreply): Action Reply | ||
* [actreturn](activity/actreturn): Action Return | ||
* [appdata](activity/actreturn): App Shared Data | ||
* [channel](activity/channel): Send internal engine messages | ||
* [counter](activity/counter): Simple Counter | ||
* [error](activity/error): Throw error | ||
* [jsexec](activity/jsexec): Execute Javascript | ||
* [log](activity/log): Log Message | ||
* [mapper](activity/mapper): Mapper | ||
* [noop](activity/noop): No-Op | ||
* [rest](activity/rest): Basic REST invoker | ||
|
||
### Triggers | ||
* [channel](trigger/channel): Listen to internal engine messages | ||
* [cli](trigger/cli): CLI | ||
* [loadtester](trigger/loadtester): Basic load tester | ||
* [rest](trigger/rest): REST | ||
* [timer](trigger/timer): Timer | ||
|
||
### Functions | ||
* [coerce](function/coerce): Type Conversion | ||
* [json](function/json): JSON functions | ||
* [number](function/number): Number functions | ||
* [string](function/string): Basic string functions | ||
|
||
## Installation | ||
|
||
#### Install Activity | ||
Example: install **log** activity | ||
|
||
```bash | ||
flogo install github.com/project-flogo/contrib/activity/log | ||
``` | ||
#### Install Trigger | ||
Example: install **rest** trigger | ||
|
||
```bash | ||
flogo install github.com/project-flogo/contrib/trigger/rest | ||
``` | ||
#### Install Functions | ||
Example: install **string** functions | ||
|
||
```bash | ||
flogo install github.com/project-flogo/contrib/function/string | ||
``` | ||
|
||
## Contributing and support | ||
|
||
### Contributing | ||
|
||
New activities, triggers and functions are welcomed. If you would like to contribute, please following the [contribution guidelines](https://github.com/TIBCOSoftware/flogo/blob/master/CONTRIBUTING.md). If you have any questions, issues, etc feel free to chat with us on [Gitter](https://gitter.im/project-flogo/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link). | ||
|
||
## License | ||
The contrib repository is licensed under a BSD-type license. See [LICENSE](LICENSE) for license text. | ||
|
||
### Support | ||
For Q&A you can post your questions on [Gitter](https://gitter.im/project-flogo/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link) |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/project-flogo/contrib/activity/actreply | ||
|
||
require ( | ||
github.com/project-flogo/core v0.9.0-beta.1 | ||
github.com/project-flogo/core v0.9.0-beta.2 | ||
github.com/stretchr/testify v1.3.0 | ||
) |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/project-flogo/contrib/activity/actreturn | ||
|
||
require ( | ||
github.com/project-flogo/core v0.9.0-beta.1 | ||
github.com/project-flogo/core v0.9.0-beta.2 | ||
github.com/stretchr/testify v1.3.0 | ||
) |
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,69 @@ | ||
# AppData | ||
This activity allows you to set and get global App attributes\. | ||
|
||
## Installation | ||
|
||
### Flogo CLI | ||
```bash | ||
flogo install github.com/project-flogo/contrib/activity/appdata | ||
``` | ||
|
||
## Configuration | ||
|
||
### Settings: | ||
| Name | Type | Description | ||
|:--- | :--- | :--- | ||
| name | string | The name of the shared attribute - **REQUIRED** | ||
| op | string | The operation (get or set), 'get' is the default | ||
| type | string | The data type of the shared value, default is 'any' | ||
|
||
### Input: | ||
| Name | Type | Description | ||
|:--- | :--- | :--- | ||
| value | object | The value of the shared attribute | ||
|
||
|
||
### Output: | ||
| Name | Type | Description | ||
|:--- | :--- | :--- | ||
| value | object | The value of the shared attribute | ||
|
||
|
||
## Examples | ||
|
||
### Get | ||
Get the value of the 'myAttr' attribute: | ||
|
||
```json | ||
{ | ||
"id": "get_app_attr", | ||
"name": "Get App Attr", | ||
"activity": { | ||
"ref": "github.com/project-flogo/contrib/activity/appdata", | ||
"settings": { | ||
"attribute": "myAttr", | ||
"operation": "get" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Set | ||
Update the value of the 'myAttr' attribute to _bar_: | ||
|
||
```json | ||
{ | ||
"id": "set_app_attr", | ||
"name": "Set App Attr", | ||
"activity": { | ||
"ref": "github.com/project-flogo/contrib/activity/appdata", | ||
"settings": { | ||
"attribute": "myAttr", | ||
"operation": "set" | ||
}, | ||
"input": { | ||
"value": "bar" | ||
} | ||
} | ||
} | ||
``` |
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,109 @@ | ||
package appdata | ||
|
||
import ( | ||
"github.com/project-flogo/core/activity" | ||
"github.com/project-flogo/core/app" | ||
"github.com/project-flogo/core/data" | ||
"github.com/project-flogo/core/data/coerce" | ||
"github.com/project-flogo/core/data/metadata" | ||
) | ||
|
||
const ( | ||
opGet int = 0 | ||
opSet int = 1 | ||
|
||
ivValue = "value" | ||
ovValue = "value" | ||
) | ||
|
||
type Settings struct { | ||
Name string `md:"name,required"` // The name of the shared attribute | ||
Op string `md:"op,allowed(get,set)"` // The operation (get or set), 'get' is the default | ||
Type string `md:"type"` // The data type of the shared value, default is 'any' | ||
} | ||
|
||
type Input struct { | ||
Value interface{} `md:"value"` // The value of the shared attribute | ||
} | ||
|
||
type Output struct { | ||
Value interface{} `md:"value"` // The value of the shared attribute | ||
} | ||
|
||
func init() { | ||
_ = activity.Register(&Activity{}, New) | ||
} | ||
|
||
var activityMd = activity.ToMetadata(&Settings{}, &Output{}) | ||
|
||
// Activity is a Counter Activity implementation | ||
type Activity struct { | ||
op int | ||
dt data.Type | ||
attrName string | ||
} | ||
|
||
func New(ctx activity.InitContext) (activity.Activity, error) { | ||
s := &Settings{} | ||
err := metadata.MapToStruct(ctx.Settings(), s, true) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
act := &Activity{attrName: s.Name} | ||
|
||
if s.Op == "set" { | ||
act.op = opSet | ||
} | ||
|
||
if s.Type != "" { | ||
t, err := data.ToTypeEnum(s.Type) | ||
if err != nil { | ||
return nil, err | ||
} | ||
act.dt = t | ||
} | ||
|
||
return act, nil | ||
} | ||
|
||
// Metadata implements activity.Activity.Metadata | ||
func (a *Activity) Metadata() *activity.Metadata { | ||
return activityMd | ||
} | ||
|
||
// Eval implements activity.Activity.Eval | ||
func (a *Activity) Eval(ctx activity.Context) (done bool, err error) { | ||
|
||
switch a.op { | ||
case opGet: | ||
|
||
val, exists := app.GetValue(a.attrName) | ||
if exists && a.dt > 1 { | ||
val, err = coerce.ToType(val, a.dt) | ||
if err != nil { | ||
return false, err | ||
} | ||
} | ||
err = ctx.SetOutput(ovValue, val) | ||
if err != nil { | ||
return false, err | ||
} | ||
case opSet: | ||
val := ctx.GetInput(ivValue) | ||
|
||
if a.dt > 1 { | ||
val, err = coerce.ToType(val, a.dt) | ||
if err != nil { | ||
return false, err | ||
} | ||
} | ||
|
||
err = app.SetValue(a.attrName, val) | ||
if err != nil { | ||
return false, err | ||
} | ||
} | ||
|
||
return true, nil | ||
} |
Oops, something went wrong.