README
¶
goakit
The goakit
plugin is a goa plugin that generates
Go kit services and clients from goa design packages.
Usage
goa v3 must be installed:
go get goa.design/goa/v3/...
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:
- The generated code uses
(github.com/go-kit/kit/endpoint).Endpoint
instead ofgoa.Endpoint
everywhere theEndpoint
type is used. goakit
generates akitclient
and akitserver
packages under thehttp
directory which define Go kit HTTP encoder and decoder functions.goakit
also generates the filemount.go
in thekitserver
package which define the sameMountXXX
functions as theserver
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 ¶
- func EncodeDecodeFiles(genpkg string, root *expr.RootExpr) []*codegen.File
- func Generate(genpkg string, roots []eval.Root, files []*codegen.File) ([]*codegen.File, error)
- func Goakitify(genpkg string, roots []eval.Root, files []*codegen.File) ([]*codegen.File, error)
- func GoakitifyExample(genpkg string, roots []eval.Root, files []*codegen.File) ([]*codegen.File, error)
- func MountFiles(root *expr.RootExpr) []*codegen.File
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeDecodeFiles ¶
EncodeDecodeFiles produces a set of go-kit transport encoders and decoders that wrap the corresponding generated goa functions.
func Goakitify ¶
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.
Types ¶
This section is empty.