Coder Social home page Coder Social logo

grofers / go-codon Goto Github PK

View Code? Open in Web Editor NEW
142.0 97.0 8.0 176 KB

Workflow based REST framework code generator

License: MIT License

Makefile 1.94% Go 96.47% Shell 1.32% Dockerfile 0.27%
workflows aggregation swagger web web-framework concurrency golang rest-api rest workflow

go-codon's Introduction

go-codon

Generates Go server code from a combination of REST and Workflow DSLs.

Build Status

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.

Check out wiki section for more information. Follow this tutorial for a very basic example on how to use this tool.

Installation

Set up your Golang development environment (Getting Started). Set your GOPATH and GOBIN directories. Also add GOBIN to your PATH so that golang tools can be used in command line.

Download the latest binary from Github releases and put it in your GOBIN directory. Or to install from source do:

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

Example

This is what a workflow looks like (for an API to get posts and the comments for each post concurrently):

name: get_posts_comments
start:
    - get_posts
tasks:
    get_posts:
        action: clients.jplaceholder.get_posts
        input:
            userId: <%jmes main.userId %>
        publish:
            posts: <%jmes action %>
        on-success:
            - get_all_comments: true
    get_comments:
        action: clients.jplaceholder.get_comments
        input:
            postId: <%jmes main.postId %>
        publish:
            comments: <%jmes action %>
    get_all_comments:
        with-items: <%jmes main.posts %>
        loop:
            task: get_comments
            input:
                postId: <%jmes item.id %>
            publish:
                combined: <%jmes {"post_details":item,"comments":task.comments} %>
output:
    body: <%jmes main.combined %>
    status_code: 200

To run this example checkout examples.

Projects go-codon would not exist without

(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

go-codon's People

Contributors

nileshbhadana avatar paruljai avatar shashankmehra avatar yashmehrotra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-codon's Issues

Fix installation process

Currently the installation process uses both dependency manager and hard coded dependencies, also, it would be better to switch to dep instead

can't regenerate glide.lock

steps to reproduce

  1. run glide install with the committed glide.lock, dependencies should install fine.
  2. delete glide.lock
  3. run glide install, it fails and doesn't regen glide.lock

codon.go:6: running "go-bindata": exec: "go-bindata": executable file not found in $PATH

codon.go:6: running "go-bindata": exec: "go-bindata": executable file not found in $PATH

Stack trace

./scripts/dependencies.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3242  100  3242    0     0   2292      0  0:00:01  0:00:01 --:--:--  2292
Downloading https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-darwin-amd64.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   623    0   623    0     0    364      0 --:--:--  0:00:01 --:--:--   364
100 3346k  100 3346k    0     0   206k      0  0:00:16  0:00:16 --:--:--  292k
glide not found. Did you add $LGOBIN to your $PATH?
Fail to install glide
./scripts/dependencies.sh: line 4: glide: command not found
go get github.com/go-openapi/runtime
go get github.com/tylerb/graceful
go get github.com/jessevdk/go-flags
go get golang.org/x/net/context
go get golang.org/x/net/context/ctxhttp
go generate
codon.go:6: running "go-bindata": exec: "go-bindata": executable file not found in $PATH
make: *** [igenerate] Error 1```

intermittent build failure due to some issue in package management

[INFO]  --> Fetching gopkg.in/mgo.v2.
[INFO]  --> Fetching gopkg.in/yaml.v2.
[WARN]  Unable to checkout gopkg.in/mgo.v2
[ERROR] Update failed for gopkg.in/mgo.v2: Cannot detect VCS
[WARN]  Unable to checkout gopkg.in/yaml.v2
[ERROR] Update failed for gopkg.in/yaml.v2: Cannot detect VCS
[ERROR] Failed to install: Cannot detect VCS
Cannot detect VCS

refer: Masterminds/glide#449

local:

screenshot 2018-09-11 13 31 51

travis:

failure:
https://travis-ci.org/grofers/go-codon/jobs/427082960
screenshot 2018-09-11 13 32 54

success:
https://travis-ci.org/grofers/go-codon/jobs/427082961

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.