Skip to main content
The Art Of Using Go in Flogo
  1. Blog/

The Art Of Using Go in Flogo

·2 mins·
Table of Contents

Not too long ago Flogo introduced a new Go API that allows you to build event-driven apps by simply embedding the Flogo engine in your existing Go code. Now you can use the event-driven engine of Flogo to build Go apps while using the activities and triggers that already exist and combining that with “regular” Go code. In one of my other posts, I built an app that could receive messages from PubNub and for this post, I’ll walk through building the exact same using the Go API.

Note: I realize that certain pieces of the code aren’t as optimized as they could be, but I wanted to keep the flow similar to what I did with the Web UI

To run this example you’ll need to have Go installed and execute these commands from where you created the file with the source code (which will have to be in your $GOPATH)

Get all the dependencies

#If you already have Flogo or the Flogo CLI, you can skip thesego get -u github.com/TIBCOSoftware/flogo-contrib/activity/loggo get -u github.com/TIBCOSoftware/flogo-lib/core/datago get -u github.com/TIBCOSoftware/flogo-lib/enginego get -u github.com/TIBCOSoftware/flogo-lib/flogogo get -u github.com/TIBCOSoftware/flogo-lib/logger

# You will need to go get these :)
go get -u github.com/retgits/flogo-components/activity/writetofile
go get -u github.com/retgits/flogo-components/trigger/pubnubsubscriber

Generate the metadata

The Flogo engine needs a bit of metadata, and to generate that the line at the top of the file needs to be executed. To do that, simply run the command below:

go generate

Build and run

Now that the “hard” part is done, you can build the app like you would do for any Go app:

go build./pubnub-app

Testing it out
#

If you’re testing it out in the same way as I did in my last post, you’ll see the same the same status messages come by as in the example with the Web UI and when you test the app in the exact same way, you’ll see that both apps will receive the same message!

No matter if you’re a Go developer or someone who builds microservices visually (through a very cool Web UI), you can do it using Flogo! If you’re trying out Flogo and have any questions, feel free to join our Gitter channel, create an issue on GitHub or even drop me a note on Twitter. I’d also love to get your feedback if you thought this was helpful (or not).

Originally published on hackernoon.com

Related

Deploying Flogo Apps to Lambda with the Serverless Framework (Part 2)

·4 mins
I can hear you think “Part 2?! So there actually is a part 1?” 😱 The answer to that is, yes, there most definitely is a part 1 (but you can safely ignore that 😅). In that part I went over deploying Flogo apps built with the Flogo Web UI using the Serverless Framework. Now, with the Go API that we added to Flogo, you can mix triggers and activities from Flogo (and the community) with your regular Go code and deploy using the Serverless Framework.

How To Build Securely Chatting Microservices With Flogo And PubNub

·5 mins
Building microservices is awesome, having them talk to each other is even more awesome! But in today’s world, you can’t be too careful when it comes to sending sensitive data across the wire. Last week I was at PubNub for a Meetup where, together with Jordan Schuetz and Nicholas Grenié, we spoke about cool things you can do with PubNub. One of them is using PubNub as a messaging layer to have your microservices, built with Flogo (duh), talk to each other in a secure way. In this post, I’ll go over the steps to build those microservices and hook them up using PubNub.