Skip to content

Latest commit

 

History

History

goakit

goakit

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

Usage

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

package design

import . "goa.design/goa/v3/dsl"
import _ "goa.design/plugins/v3/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 calc and fetcher example design packages show how to enable the plugin. The corresponding gen folders contain the generated HTTP Go kit server and client packages.