goakit

package
v3.19.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: MIT Imports: 9 Imported by: 3

README

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.

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

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