Workflow based REST framework code generator
Generates Go server code from a combination of REST and Workflow DSLs.
A codon service has three components: -
Server: Accepts and validates HTTP requests -
Clients: Clients for upstream services which this service consumes -
Workflows: Procedures for every REST endpoint of this server which consume Clients and other custom actions.
Server and Client side specifications are written in Swagger. Swagger code generation is done through go-swagger. Workflow is written in
Flow, a Mistral inspired workflow specification in YAML. Its specification can be found here.
Set up your Golang development environment (Getting Started). Set your
GOBINdirectories. Also add
PATHso that golang tools can be used in command line.
Download the latest binary from Github releases and put it in your
GOBINdirectory. Or to install from source do:
sh mkdir -p $GOPATH/src/github.com/grofers cd $GOPATH/src/github.com/grofers git clone [email protected]:grofers/go-codon.git cd go-codon make install
This is what a workflow looks like (for an API to get posts and the comments for each post concurrently):
yaml name: get_posts_comments start: - get_posts tasks: get_posts: action: clients.jplaceholder.get_posts input: userId: publish: posts: on-success: - get_all_comments: true get_comments: action: clients.jplaceholder.get_comments input: postId: publish: comments: get_all_comments: with-items: loop: task: get_comments input: postId: publish: combined: output: body: status_code: 200To run this example checkout examples.
(Or just projects I am really thankful for) - go-swagger: Provides code generators for client and server side components using Swagger specification. - go-jmespath: Allows for easy querying and manipulation of json objects in workflows. - Pongo2: Django template renderer. Used for templates and workflow expressions in codon. - Mistral DSL: A workflow spec used for infrastructure orchestration. Codon's workflow DSL is inspired from Mistral's but modified for use in REST context. - mapstructure