goagen_js

package module
v0.0.0-...-7581385 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2017 License: MIT Imports: 11 Imported by: 0

README

goagen proto
====================

This package provides a `goa <https://goa.design/>`_ generator for gRPC.

Status
------------------

Very alpha. you can not use in the production.

- Enum is not work
- Required is not work
- Nested type is not work
- Message field order is alphabetical. Should set explicit "Order"?

How to generate proto from your design
---------------------------------------------

At first, you have to do *go get*

::

  % go get github.com/shirou/goagen_proto

Then, you can **goagen gen** with your design.

::

  % goagen gen --pkg-path=github.com/shirou/goagen_proto -d github.com/some/your/great/design

**api.proto** file will be generated.


Type Definition
~~~~~~~~~~~~~~~~~

protobuf has a valious kind of types. But goa can not specify the type.

You can set **Metadata("struct:field:grpctype")** to specify type like this.

::

		Attribute("age", Integer, "age", func() {
			Metadata("struct:field:grpctype", "uint32")
		})


Example
---------------------

See example directory.



LICENSE
---------------------

MIT License

Documentation

Overview

Package goagen_proto provides a goa generator for gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate() (files []string, err error)

Generate is the generator entry point called by the meta generator.

Types

type AlphabeticalName

type AlphabeticalName []Param

func (AlphabeticalName) Len

func (a AlphabeticalName) Len() int

func (AlphabeticalName) Less

func (a AlphabeticalName) Less(i, j int) bool

func (AlphabeticalName) Swap

func (a AlphabeticalName) Swap(i, j int)

type Generator

type Generator struct {
	API    *design.APIDefinition // The API definition
	OutDir string                // Destination directory
	Scheme string                // Scheme used by JavaScript client
	Host   string                // Host addressed by JavaScript client
	// contains filtered or unexported fields
}

Generator is the application code generator.

func NewGenerator

func NewGenerator(options ...Option) *Generator

NewGenerator returns an initialized instance of a JavaScript Client Generator

func (*Generator) Cleanup

func (g *Generator) Cleanup()

Cleanup removes all the files generated by this generator during the last invokation of Generate.

func (*Generator) Generate

func (g *Generator) Generate() ([]string, error)

Generate produces the skeleton main.

type Option

type Option func(*Generator)

Option a generator option definition

func API

func API(API *design.APIDefinition) Option

API The API definition

func Host

func Host(host string) Option

Host addressed by JavaScript client

func OutDir

func OutDir(outDir string) Option

OutDir Path to output directory

func Scheme

func Scheme(scheme string) Option

Scheme Scheme used by JavaScript client

type Param

type Param struct {
	Name          string // no CamelCase name
	CamelCaseName string // CamelCase name
	Kind          string // kind such as bool, number, ...
	Description   string
	Enum          []string // Enum
	Required      bool
	Repeat        bool
	// contains filtered or unexported fields
}

func (Param) EnumField

func (p Param) EnumField() string

func (Param) MessageField

func (p Param) MessageField(i int) string

type Params

type Params []Param

type RPCDefinition

type RPCDefinition struct {
	Action   *design.ActionDefinition
	Base     string
	Name     string
	Query    Params // sorted by alphabetical
	Response *Response
}

func (RPCDefinition) Comment

func (p RPCDefinition) Comment() string

func (RPCDefinition) FuncName

func (p RPCDefinition) FuncName() string

func (RPCDefinition) RequestDefinition

func (p RPCDefinition) RequestDefinition() []string

func (RPCDefinition) RequestName

func (p RPCDefinition) RequestName() string

func (RPCDefinition) ResponseDefinition

func (p RPCDefinition) ResponseDefinition() []string

func (RPCDefinition) ResponseName

func (p RPCDefinition) ResponseName() string

type Response

type Response struct {
	Name           string
	Identifier     string
	IdentifierName string
	Stream         bool // CollectionOf convert to stream
	Params         Params
}

type ServiceDefinition

type ServiceDefinition struct {
	Name     string
	Resource *design.ResourceDefinition
	RPCs     []RPCDefinition
}

func (ServiceDefinition) GetRPCs

func (s ServiceDefinition) GetRPCs() []string

func (ServiceDefinition) ServiceName

func (s ServiceDefinition) ServiceName() string

Directories

Path Synopsis
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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