This project is intended for new StateFun users that would like to start implementing their StateFun application functions using GoLang. The tutorial is streamlined and split into a few parts which we recommend to go through a specific order, as lay out below. Each part is demonstrated with some code snippets plus comments to guide you through the SDK fundamentals.
This function demonstrates StateFun's type system using the GoLang SDK.
This function demonstrates how to send messages to other functions.
To let your StateFun application interact with the outside world, functions may write messages to egresses. This function demonstrates sending messages to an Apache Kafka or AWS Kinesis egress, which is currently our most commonly used egresses that are natively supported by StateFun.
Consistent state is at the core of stateful functions. This function demonstrates interacting with function state.
This function demonstrates performing asynchronous operations during a function invocation. It is a common scenario for functions to have external dependencies in order for it to complete its work, such as fetching enrichment information from remote databases.
This function builds a full stateful functions application and shows how they are exposed and deployed in the real world. Run this function locally along with the stateful functions runtime!
To actually start serving run from one terminal:
$ cd pkg/showcase/part6 $ go build $ ./part6
And from another: docker-compose up
The setup you executed in the last part of this tutorial is not how you‘d normally deploy StateFun processes and functions. It’s a rather simplified setup to allow you to explore the interaction between functions and the StateFun processes by setting debugger breakpoints in the function code in your IDE.
We recommend now to take a look at a slightly more realistic setup, using Docker Compose, in the Greeter Docker Compose Example.