gengokit

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 8 Imported by: 0

README

gengokit

  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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FuncMap = template.FuncMap{
	"ToLower": strings.ToLower,
	"GoName":  generatego.CamelCase,
}

FuncMap contains a series of utility functions to be passed into templates and used within those templates.

Functions

func ApplyTemplate

func ApplyTemplate(templ string, templName string, data interface{}, funcMap template.FuncMap) (io.Reader, error)

ApplyTemplate is a helper methods that packages can call to render a template with any data and func map

Types

type Config

type Config struct {
	GoPackage   string
	PBPackage   string
	Version     string
	VersionDate string

	PreviousFiles map[string]io.Reader
}

type Data

type Data struct {
	// import path for the directory containing the definition .proto files
	ImportPath string
	// import path for .pb.go files containing service structs
	PBImportPath string
	// PackageName is the name of the package containing the service definition
	PackageName string
	// GRPC/Protobuff service, with all parameters and return values accessible
	Service *svcdef.Service
	// A helper struct for generating http transport functionality.
	HTTPHelper *httptransport.Helper
	FuncMap    template.FuncMap

	Version     string
	VersionDate string
}

Data is passed to templates as the executing struct; its fields and methods are used to modify the template

func NewData

func NewData(sd *svcdef.Svcdef, conf Config) (*Data, error)

func (*Data) ApplyTemplate

func (e *Data) ApplyTemplate(templ string, templName string) (io.Reader, error)

ApplyTemplate applies the passed template with the Data

type Renderable

type Renderable interface {
	Render(string, *Data) (io.Reader, error)
}

Directories

Path Synopsis
Package generator generates a gokit service based on a service definition.
Package generator generates a gokit service based on a service definition.
Package handlers manages the exported methods in the service handler code adding/removing exported methods to match the service definition.
Package handlers manages the exported methods in the service handler code adding/removing exported methods to match the service definition.
Package httptransport provides functions and template helpers for templating the http-transport of a go-kit based service.
Package httptransport provides functions and template helpers for templating the http-transport of a go-kit based service.
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