gengokit

package
v0.0.0-...-8353322 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2016 License: MIT Imports: 16 Imported by: 0

README

gengokit

gengokit is a truss plugin that from a doctree and []truss.SimpleFile

  1. Generates Golang code for a gokit microservice that includes:
    • Logging
    • Metrics/Instrumentation
    • gRPC transport
    • http/json transport (including all encoding/decoding)
    • no-op handler methods for each service rpc, ready for business logic to be added
  2. Generates Golang code for a cli gokit microservice client that includes:
    • gRPC transport
    • http/json transport (including all encoding/decoding)
    • handler methods that marshal command line arguments into server requests
  3. Parses code previously generated by protoc-gen-truss-gokit and inserts/removes handler methods/rpcs that are defined/removed from the definition

Development

Build

$ go generate github.com/TuneLab/go-truss/... $ go install github.com/TuneLab/go-truss/...

Test

make test from the $GOPATH/src/github.com/TuneLab/go-truss/truss directory runs the integration tests

Structure

./template/service contain go text/template files that represent a gokit microservice

./astmodifier provides functions to modify source code already generated and/or user modified.

gengokit.go executes the template files using doctree's representation of the protoc AST. ./generator also uses ./astmodifier to rewrite code to insert/remove handler methods/rpcs that are defined/removed from a definition file without touching user written logic.

NOTE:

  • No Service rpc methods named "NewBasicService" allowed for generation reasons

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateGokit

func GenerateGokit(dt doctree.Doctree, previousFiles []truss.NamedReadWriter, goImportPath string) ([]truss.NamedReadWriter, error)

GenerateGokit accepts a doctree representing the ast of a group of .proto files, a []truss.NamedReadWriter representing files generated previously, and a goImportPath for templating go code imports GenerateGoCode returns the a []truss.NamedReadWriter representing a generated gokit microservice file structure

Types

This section is empty.

Directories

Path Synopsis
Package clientarggen collects information for templating the code in a truss-generated client which marshals command line flags into message fields for each service.
Package clientarggen collects information for templating the code in a truss-generated client which marshals command line flags into message fields for each service.
Package httptransport provides functions and template helpers for templating the http-transport of a go-kit based microservice.
Package httptransport provides functions and template helpers for templating the http-transport of a go-kit based microservice.
This file is here to hold the `go generate` command above.
This file is here to hold the `go generate` command above.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL