goakit

package
v2.2.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: MIT Imports: 9 Imported by: 15

README

goakit

The goakit plugin is a goa plugin that generates Go kit services and clients from goa design packages.

Usage

goa v2 must be installed:

go get goa.design/goa/...

Simply import the plugin in the service design package. Use the blank identifier _ as explicit package name:

package design

import . "goa.design/goa/dsl"
import _ "goa.design/plugins/goakit" # Enables goakit

var _ = API("...

and generate as usual:

goa gen PACKAGE
goa example PACKAGE

where PACKAGE is the Go import path of the design package.

Effects of the Plugin

Importing the goakit package changes the behavior of both the gen and example commands of the goa tool. The gen command output is modified as follows:

  1. The generated code uses (github.com/go-kit/kit/endpoint).Endpoint instead of goa.Endpoint everywhere the Endpoint type is used.
  2. goakit generates a kitclient and a kitserver packages under the http directory which define Go kit HTTP encoder and decoder functions.
  3. goakit also generates the file mount.go in the kitserver package which define the same MountXXX functions as the server package for convenience.

The example command output is modified so that the example server uses the Go kit logger and HTTP transport struct (defined using the Go kit encoder and decoder functions generated by the gen command).

Example

The cellar example design illustrates the usage by importing both the official cellar example design package and the goakit plugin.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeDecodeFiles

func EncodeDecodeFiles(genpkg string, root *expr.RootExpr) []*codegen.File

EncodeDecodeFiles produces a set of go-kit transport encoders and decoders that wrap the corresponding generated goa functions.

func Generate

func Generate(genpkg string, roots []eval.Root, files []*codegen.File) ([]*codegen.File, error)

Generate generates go-kit specific decoders and encoders.

func Goakitify

func Goakitify(genpkg string, roots []eval.Root, files []*codegen.File) ([]*codegen.File, error)

Goakitify modifies all the previously generated files by adding go-kit imports and replacing the following instances * "goa.Endpoint" with "github.com/go-kit/kit/endpoint".Endpoint * "log.Logger" with "github.com/go-kit/kit/log".Logger

Goakitify also wraps instances of endpoint.Endpoint into instances of goa.Endpoint when used as argument of either goagrpc.NewStreamHandler or goagrpc.NewUnaryHandler.

func GoakitifyExample

func GoakitifyExample(genpkg string, roots []eval.Root, files []*codegen.File) ([]*codegen.File, error)

GoakitifyExample modifies all the previously generated example files by adding go-kit imports.

func MountFiles

func MountFiles(root *expr.RootExpr) []*codegen.File

MountFiles produces the files containing the HTTP handler mount functions that configure the mux to serve the requests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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