The goakit
plugin is a Goa plugin that generates
Go kit services and clients from goa design packages.
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.
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).
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.