Skip to content

square-it/flogo-demo-services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flogo demo by Square IT Services - Services application

Introduction

This repository is part of the Flogo Demo by Square IT Services.

These two applications can communicate through a REST service or via an MQTT broker.

Flogo Demo architecture

Description

This application has a flow triggered indistinctly by a REST or MQTT trigger which take as a parameter the Unicode identifier of any emoji defined in the OpenMoji library.

It can be compiled and run on any system where Go program can be compiled to.

As any flow-based Flogo application, it can be modified with the Flogo Web UI.

Prerequisites

Usage

Build from sources

  1. clone this repository
git clone https://github.com/square-it/flogo-demo-services.git
cd flogo-demo-services
  1. compile the application into a native executable
flogo ensure
flogo build -e

Prepare

  1. launch a Mosquitto MQTT broker (required):
docker run --name mosquitto -d -p 1883:1883 -p 9001:9001 eclipse-mosquitto
  1. to enable OpenTracing, run a Zipkin collector (optional):
docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin

For detailed instructions read OpenTracing collectors for Flogo.

Test

Considering this application will run on a host reachable at 192.168.1.1 with a Raspberry Pi reachable at 192.168.1.2

  1. define Raspberry Pi and MQTT configuration
export RPI_HOST=192.168.1.2
export RPI_PORT=4445

export MQTT_BROKER=192.168.1.1:1883
export MQTT_DEMO=demo
  1. run the executable
cd bin
./flogo-demo-services

To enable OpenTracing with a Zipkin HTTP collector listening on 192.168.1.1:9411, run instead

export FLOGO_OPENTRACING_IMPLEMENTATION=zipkin
export FLOGO_OPENTRACING_TRANSPORT=http
export FLOGO_OPENTRACING_ENDPOINTS=http://192.168.1.1:9411/api/v1/spans
cd bin
./flogo-demo-services
  1. test with a sample smiley

a. with the REST trigger

curl http://192.168.1.1:4445/v1/smiley/1F605

b. with a MQTT message

docker run -it --rm --name mqtt-publisher efrecon/mqtt-client pub -h 192.168.1.1 -t "demo" -m "1F609"

Development

  1. run a Flogo Web UI
docker run --name flogo -it -d -p 3303:3303 -e FLOGO_NO_ENGINE_RECREATION=false flogo/flogo-docker:v0.5.8 eula-accept
  1. install custom-made activities contributions
docker exec -it flogo sh -c 'cd /tmp/flogo-web/build/server/local/engines/flogo-web && flogo install github.com/square-it/flogo-contrib-activities/command'
docker exec -it flogo sh -c 'cd /tmp/flogo-web/build/server/local/engines/flogo-web && flogo install github.com/square-it/flogo-contrib-activities/copyfile'
  1. restart the Flogo Web UI container
docker restart flogo

The Flogo Web UI is available at http://localhost:3303.

Import the application using the provided flogo.json.