template

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PackagePathGoKitEndpoint         = "github.com/go-kit/kit/endpoint"
	PackagePathContext               = "context"
	PackagePathGoKitLog              = "github.com/go-kit/kit/log"
	PackagePathTime                  = "time"
	PackagePathGoogleGRPC            = "google.golang.org/grpc"
	PackagePathGoogleGRPCStatus      = "google.golang.org/grpc/status"
	PackagePathGoogleGRPCCodes       = "google.golang.org/grpc/codes"
	PackagePathNetContext            = "golang.org/x/net/context"
	PackagePathGoKitTransportGRPC    = "github.com/go-kit/kit/transport/grpc"
	PackagePathHttp                  = "net/http"
	PackagePathGoKitTransportHTTP    = "github.com/go-kit/kit/transport/http"
	PackagePathBytes                 = "bytes"
	PackagePathJson                  = "encoding/json"
	PackagePathIOUtil                = "io/ioutil"
	PackagePathIO                    = "io"
	PackagePathStrings               = "strings"
	PackagePathUrl                   = "net/url"
	PackagePathEmptyProtobuf         = "github.com/golang/protobuf/ptypes/empty"
	PackagePathFmt                   = "fmt"
	PackagePathOs                    = "os"
	PackagePathOsSignal              = "os/signal"
	PackagePathSyscall               = "syscall"
	PackagePathErrors                = "errors"
	PackagePathNet                   = "net"
	PackagePathGorillaMux            = "github.com/gorilla/mux"
	PackagePathPath                  = "path"
	PackagePathStrconv               = "strconv"
	PackagePathOpenTracingGo         = "github.com/opentracing/opentracing-go"
	PackagePathGoKitTracing          = "github.com/go-kit/kit/tracing/opentracing"
	PackagePathGoKitTransportJSONRPC = "github.com/go-kit/kit/transport/http/jsonrpc"
	PackagePathGoKitMetrics          = "github.com/go-kit/kit/metrics"
	PackagePathGoKitSD               = "github.com/go-kit/kit/sd"
	PackagePathGoKitLB               = "github.com/go-kit/kit/sd/lb"
	PackagePathSyncErrgroup          = "golang.org/x/sync/errgroup"

	TagMark         = "// @"
	MicrogenMainTag = "microgen"
)
View Source
const (
	MiddlewareTag             = "middleware"
	LoggingMiddlewareTag      = "logging"
	RecoveringMiddlewareTag   = "recovering"
	HttpTag                   = "http"
	HttpServerTag             = "http-server"
	HttpClientTag             = "http-client"
	GrpcTag                   = "grpc"
	GrpcServerTag             = "grpc-server"
	GrpcClientTag             = "grpc-client"
	MainTag                   = "main"
	ErrorLoggingMiddlewareTag = "error-logging"
	TracingMiddlewareTag      = "tracing"
	CachingMiddlewareTag      = "caching"
	JSONRPCTag                = "json-rpc"
	JSONRPCServerTag          = "json-rpc-server"
	JSONRPCClientTag          = "json-rpc-client"
	Transport                 = "transport"
	TransportClient           = "transport-client"
	TransportServer           = "transport-server"
	MetricsMiddlewareTag      = "metrics"
	ServiceDiscoveryTag       = "service-discovery"
)
View Source
const (
	MicrogenExt    = ".microgen.go"
	PathService    = "service"
	PathTransport  = "transport"
	PathExecutable = "cmd"
)
View Source
const (
	GolangProtobufPtypesTimestamp = "github.com/golang/protobuf/ptypes/timestamp"
	JsonbPackage                  = "github.com/sas1024/gorm-jsonb/jsonb"
	GolangProtobufPtypes          = "github.com/golang/protobuf/ptypes"
	GolangProtobufWrappers        = "github.com/golang/protobuf/ptypes/wrappers"
)
View Source
const (
	HttpMethodTag  = "http-method"
	HttpMethodPath = "http-path"
)
View Source
const (
	EndpointsSetName = "EndpointsSet"
)
View Source
const (
	MiddlewareTypeName = "Middleware"
)

Variables

View Source
var CachingMiddlewareName = mstrings.ToUpperFirst(cachingMiddlewareStructName)
View Source
var (
	ErrProtobufEmpty = errors.New("protobuf package is empty")
)
View Source
var ServiceErrorLoggingMiddlewareName = mstrings.ToUpperFirst(serviceErrorLoggingStructName)
View Source
var ServiceLoggingMiddlewareName = mstrings.ToUpperFirst(serviceLoggingStructName)
View Source
var ServiceRecoveringMiddlewareName = mstrings.ToUpperFirst(serviceRecoveringStructName)

Functions

func AllowEllipsis added in v0.9.0

func AllowEllipsis(ctx context.Context) bool

func FetchHttpMethodTag added in v0.9.0

func FetchHttpMethodTag(rawString []string) string

func IsContextFirst added in v0.3.0

func IsContextFirst(fields []types.Variable) bool

func IsErrorLast added in v0.3.0

func IsErrorLast(fields []types.Variable) bool

func ParseFile added in v0.9.0

func ParseFile(filename string) (*types.File, error)

func RemoveContextIfFirst added in v0.9.0

func RemoveContextIfFirst(fields []types.Variable) []types.Variable

Remove from function fields context if it is first in slice

func SourcePackageImport added in v0.9.0

func SourcePackageImport(ctx context.Context) string

func WithSourcePackageImport added in v0.9.0

func WithSourcePackageImport(parent context.Context, val string) context.Context

func WithTags added in v0.9.0

func WithTags(parent context.Context, tt TagsSet) context.Context

Types

type BufferAdapter added in v0.9.0

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

func (*BufferAdapter) Hold added in v0.9.0

func (b *BufferAdapter) Hold() *DelayBuffer

func (*BufferAdapter) Ln added in v0.9.0

func (b *BufferAdapter) Ln(a ...interface{})

func (*BufferAdapter) Lnf added in v0.9.0

func (b *BufferAdapter) Lnf(format string, a ...interface{})

func (*BufferAdapter) Printf added in v0.9.0

func (b *BufferAdapter) Printf(format string, a ...interface{})

func (*BufferAdapter) Println added in v0.9.0

func (b *BufferAdapter) Println(a ...interface{})

func (*BufferAdapter) Raw added in v0.9.0

func (b *BufferAdapter) Raw(data []byte)

func (BufferAdapter) Render added in v0.9.0

func (b BufferAdapter) Render(w io.Writer) error

type DelayBuffer added in v0.9.0

type DelayBuffer struct {
	BufferAdapter
	// contains filtered or unexported fields
}

func (*DelayBuffer) Release added in v0.9.0

func (b *DelayBuffer) Release()

type EmptyTemplate added in v0.9.0

type EmptyTemplate struct{}

Template for tags, that not produce any files.

func (EmptyTemplate) ChooseStrategy added in v0.9.0

func (EmptyTemplate) DefaultPath added in v0.9.0

func (EmptyTemplate) DefaultPath() string

func (EmptyTemplate) Prepare added in v0.9.0

func (EmptyTemplate) Render added in v0.9.0

type GenerationInfo added in v0.3.0

type GenerationInfo struct {
	Iface               *types.Interface
	SourcePackageImport string
	SourceFilePath      string
	OutputPackageImport string
	OutputFilePath      string
	FileHeader          string

	ProtobufPackageImport string
	ProtobufClientAddr    string
	AllowedMethods        map[string]bool
}

func (GenerationInfo) String added in v0.9.0

func (i GenerationInfo) String() string

type Rendered added in v0.9.0

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

func (*Rendered) Add added in v0.9.0

func (r *Rendered) Add(s string)

func (*Rendered) Contain added in v0.9.0

func (r *Rendered) Contain(s string) bool

func (*Rendered) NotContain added in v0.9.0

func (r *Rendered) NotContain(s string) bool

type TagsSet added in v0.9.0

type TagsSet map[string]struct{}

func Tags added in v0.9.0

func Tags(ctx context.Context) TagsSet

func (TagsSet) Add added in v0.9.0

func (s TagsSet) Add(item string)

func (TagsSet) Has added in v0.9.0

func (s TagsSet) Has(item string) bool

func (TagsSet) HasAny added in v0.9.0

func (s TagsSet) HasAny(items ...string) bool

type Template added in v0.3.0

type Template interface {
	// Do all preparing actions, e.g. scan file.
	// Should be called first.
	Prepare(ctx context.Context) error
	// Default relative path for template (=file)
	DefaultPath() string
	// Template chooses generation strategy, e.g. appends to file or create new.
	ChooseStrategy(ctx context.Context) (write_strategy.Strategy, error)
	// Main render function, where template produce code.
	Render(ctx context.Context) write_strategy.Renderer
}

func NewCacheMiddlewareTemplate added in v0.9.0

func NewCacheMiddlewareTemplate(info *GenerationInfo) Template

func NewEndpointsClientTemplate added in v0.9.0

func NewEndpointsClientTemplate(info *GenerationInfo) Template

func NewEndpointsServerTemplate added in v0.9.0

func NewEndpointsServerTemplate(info *GenerationInfo) Template

func NewEndpointsTemplate added in v0.3.0

func NewEndpointsTemplate(info *GenerationInfo) Template

func NewErrorLoggingTemplate added in v0.9.0

func NewErrorLoggingTemplate(info *GenerationInfo) Template

func NewExchangeTemplate added in v0.3.0

func NewExchangeTemplate(info *GenerationInfo) Template

func NewGRPCClientTemplate added in v0.3.0

func NewGRPCClientTemplate(info *GenerationInfo) Template

func NewGRPCEndpointConverterTemplate added in v0.3.0

func NewGRPCEndpointConverterTemplate(info *GenerationInfo) Template

func NewGRPCServerTemplate added in v0.3.0

func NewGRPCServerTemplate(info *GenerationInfo) Template

func NewHttpClientTemplate added in v0.9.0

func NewHttpClientTemplate(info *GenerationInfo) Template

func NewHttpConverterTemplate added in v0.9.0

func NewHttpConverterTemplate(info *GenerationInfo) Template

func NewHttpServerTemplate added in v0.9.0

func NewHttpServerTemplate(info *GenerationInfo) Template

func NewJSONRPCEndpointConverterTemplate added in v0.9.0

func NewJSONRPCEndpointConverterTemplate(info *GenerationInfo) Template

func NewLoggingTemplate added in v0.3.0

func NewLoggingTemplate(info *GenerationInfo) Template

func NewMainTemplate added in v0.9.0

func NewMainTemplate(info *GenerationInfo) Template

func NewMiddlewareTemplate added in v0.3.0

func NewMiddlewareTemplate(info *GenerationInfo) Template

func NewProtoTemplate added in v0.9.0

func NewProtoTemplate(info *GenerationInfo, protoPkg string) Template

func NewRecoverTemplate added in v0.9.0

func NewRecoverTemplate(info *GenerationInfo) Template

func NewStubGRPCTypeConverterTemplate added in v0.3.0

func NewStubGRPCTypeConverterTemplate(info *GenerationInfo) Template

func NewStubInterfaceTemplate added in v0.3.0

func NewStubInterfaceTemplate(info *GenerationInfo) Template

type WriteStrategyState added in v0.3.0

type WriteStrategyState int
const (
	FileStrat WriteStrategyState = iota + 1
	AppendStrat
)

Jump to

Keyboard shortcuts

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