generator

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_KIT_PROTO_FILE_INDENT_CHAR = "    "
View Source
const ENV_NAME_KIT_PROTO_FILE_INDENT_CHAR = "KIT_PROTO_FILE_INDENT_CHAR"

Variables

View Source
var SupportedTransports = []string{"http", "grpc"}

SupportedTransports is an array containing the supported transport types.

Functions

This section is empty.

Types

type BaseGenerator

type BaseGenerator struct {
	// contains filtered or unexported fields
}

BaseGenerator implements some basic generator functionality used by all generators.

func (*BaseGenerator) AddImportsToFile

func (b *BaseGenerator) AddImportsToFile(imp []parser.NamedTypeValue, src string) (string, error)

AddImportsToFile adds missing imports toa file that we edit with the generator

func (*BaseGenerator) CreateFolderStructure

func (b *BaseGenerator) CreateFolderStructure(path string) error

CreateFolderStructure create folder structure of path

func (*BaseGenerator) EnsureThatWeUseQualifierIfNeeded

func (b *BaseGenerator) EnsureThatWeUseQualifierIfNeeded(tp string, imp []parser.NamedTypeValue) string

EnsureThatWeUseQualifierIfNeeded is used to see if we need to import a path of a given type.

func (*BaseGenerator) GenerateNameBySample

func (b *BaseGenerator) GenerateNameBySample(sample string, exclude []parser.NamedTypeValue) string

GenerateNameBySample is used to generate a variable name using a sample.

The exclude parameter represents the names that it can not use.

E.x sample = "hello" this will return the name "h" if it is not in any NamedTypeValue name.

func (*BaseGenerator) InitPg

func (b *BaseGenerator) InitPg()

InitPg initiates the partial generator (used when we don't want to generate the full source only portions)

type BuildService

type BuildService struct {
	Context    string `yaml:"context"`
	DockerFile string `yaml:"dockerfile"`
}

BuildService represents one docker service build.

type DockerCompose

type DockerCompose struct {
	Version  string                 `yaml:"version"`
	Services map[string]interface{} `yaml:"services"`
}

DockerCompose represents the docker-compose.yml

type DockerService

type DockerService struct {
	Build         BuildService `yaml:"build"`
	Restart       string       `yaml:"restart"`
	Volumes       []string
	ContainerName string   `yaml:"container_name"`
	Ports         []string `yaml:"ports"`
}

DockerService represents one docker service.

type Gen

type Gen interface {
	Generate() error
}

Gen represents a generator.

func NewGenerateClient

func NewGenerateClient(name string, transport, pbImportPath string) Gen

NewGenerateClient returns a client generator.

func NewGenerateDocker

func NewGenerateDocker(glide bool) Gen

NewGenerateDocker returns a new docker generator.

func NewGenerateMiddleware

func NewGenerateMiddleware(name, serviceName string, ep bool) Gen

NewGenerateMiddleware returns a initialized and ready generator.

func NewGenerateService

func NewGenerateService(name, transport, pbPath, pbImportPath string, sMiddleware, gorillaMux, eMiddleware bool, methods []string) Gen

NewGenerateService returns a initialized and ready generator.

func NewGenerateTransport

func NewGenerateTransport(name string, gorillaMux bool, transport, pbPath, pbImportPath string, methods []string) Gen

NewGenerateTransport returns a transport generator.

func NewNewService

func NewNewService(name string) Gen

NewNewService returns a initialized and ready generator.

The name parameter is the name of the service that will be created this name should be without the `Service` suffix

type GenerateClient

type GenerateClient struct {
	BaseGenerator
	// contains filtered or unexported fields
}

GenerateClient implements Gen and it is used to generate the client lib of the service/

func (*GenerateClient) Generate

func (g *GenerateClient) Generate() (err error)

Generate generates the client lib.

type GenerateDocker

type GenerateDocker struct {
	BaseGenerator
	// contains filtered or unexported fields
}

GenerateDocker implements Gen and is used to generate docker files for services.

func (*GenerateDocker) Generate

func (g *GenerateDocker) Generate() (err error)

Generate generates the docker configurations.

type GenerateMiddleware

type GenerateMiddleware struct {
	BaseGenerator
	// contains filtered or unexported fields
}

GenerateMiddleware implements Gen and is used to generate middleware.

func (*GenerateMiddleware) Generate

func (g *GenerateMiddleware) Generate() (err error)

Generate generates a new service middleware

type GenerateService

type GenerateService struct {
	BaseGenerator
	// contains filtered or unexported fields
}

GenerateService implements Gen and is used to generate the service.

func (*GenerateService) Generate

func (g *GenerateService) Generate() (err error)

Generate generates the service.

type GenerateTransport

type GenerateTransport struct {
	BaseGenerator
	// contains filtered or unexported fields
}

GenerateTransport implement Gen, is used to generate a service transport

func (*GenerateTransport) Generate

func (g *GenerateTransport) Generate() (err error)

Generate generates the transport.

type NewService

type NewService struct {
	BaseGenerator
	// contains filtered or unexported fields
}

NewService implements Gen and is used to create a new service.

func (*NewService) Generate

func (g *NewService) Generate() error

Generate will run the generator.

type PartialGenerator

type PartialGenerator struct {
	// contains filtered or unexported fields
}

PartialGenerator wraps a jen statement

func NewPartialGenerator

func NewPartialGenerator(st *jen.Statement) *PartialGenerator

NewPartialGenerator returns a partial generator

func (*PartialGenerator) NewLine

func (p *PartialGenerator) NewLine()

NewLine insert a new line in code.

func (*PartialGenerator) Raw

func (p *PartialGenerator) Raw() *jen.Statement

Raw returns the jen statement.

func (*PartialGenerator) String

func (p *PartialGenerator) String() string

String returns the source code string

Jump to

Keyboard shortcuts

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