template

package
v0.0.0-...-0f723c4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 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

func AllowEllipsis(ctx context.Context) bool

func FetchHttpMethodTag

func FetchHttpMethodTag(rawString []string) string

func IsContextFirst

func IsContextFirst(fields []types.Variable) bool

func IsErrorLast

func IsErrorLast(fields []types.Variable) bool

func ParseFile

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

func RemoveContextIfFirst

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

Remove from function fields context if it is first in slice

func SourcePackageImport

func SourcePackageImport(ctx context.Context) string

func WithSourcePackageImport

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

func WithTags

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

Types

type BufferAdapter

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

func (*BufferAdapter) Hold

func (b *BufferAdapter) Hold() *DelayBuffer

func (*BufferAdapter) Ln

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

func (*BufferAdapter) Lnf

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

func (*BufferAdapter) Printf

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

func (*BufferAdapter) Println

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

func (*BufferAdapter) Raw

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

func (BufferAdapter) Render

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

type DelayBuffer

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

func (*DelayBuffer) Release

func (b *DelayBuffer) Release()

type EmptyTemplate

type EmptyTemplate struct{}

Template for tags, that not produce any files.

func (EmptyTemplate) ChooseStrategy

func (EmptyTemplate) DefaultPath

func (EmptyTemplate) DefaultPath() string

func (EmptyTemplate) Prepare

func (EmptyTemplate) Render

type GenerationInfo

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

func (i GenerationInfo) String() string

type Rendered

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

func (*Rendered) Add

func (r *Rendered) Add(s string)

func (*Rendered) Contain

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

func (*Rendered) NotContain

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

type TagsSet

type TagsSet map[string]struct{}

func Tags

func Tags(ctx context.Context) TagsSet

func (TagsSet) Add

func (s TagsSet) Add(item string)

func (TagsSet) Has

func (s TagsSet) Has(item string) bool

func (TagsSet) HasAny

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

type Template

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

func NewCacheMiddlewareTemplate(info *GenerationInfo) Template

func NewEndpointsClientTemplate

func NewEndpointsClientTemplate(info *GenerationInfo) Template

func NewEndpointsServerTemplate

func NewEndpointsServerTemplate(info *GenerationInfo) Template

func NewEndpointsTemplate

func NewEndpointsTemplate(info *GenerationInfo) Template

func NewErrorLoggingTemplate

func NewErrorLoggingTemplate(info *GenerationInfo) Template

func NewExchangeTemplate

func NewExchangeTemplate(info *GenerationInfo) Template

func NewGRPCClientTemplate

func NewGRPCClientTemplate(info *GenerationInfo) Template

func NewGRPCEndpointConverterTemplate

func NewGRPCEndpointConverterTemplate(info *GenerationInfo) Template

func NewGRPCServerTemplate

func NewGRPCServerTemplate(info *GenerationInfo) Template

func NewHttpClientTemplate

func NewHttpClientTemplate(info *GenerationInfo) Template

func NewHttpConverterTemplate

func NewHttpConverterTemplate(info *GenerationInfo) Template

func NewHttpServerTemplate

func NewHttpServerTemplate(info *GenerationInfo) Template

func NewJSONRPCEndpointConverterTemplate

func NewJSONRPCEndpointConverterTemplate(info *GenerationInfo) Template

func NewLoggingTemplate

func NewLoggingTemplate(info *GenerationInfo) Template

func NewMainTemplate

func NewMainTemplate(info *GenerationInfo) Template

func NewMiddlewareTemplate

func NewMiddlewareTemplate(info *GenerationInfo) Template

func NewProtoTemplate

func NewProtoTemplate(info *GenerationInfo, protoPkg string) Template

func NewRecoverTemplate

func NewRecoverTemplate(info *GenerationInfo) Template

func NewStubGRPCTypeConverterTemplate

func NewStubGRPCTypeConverterTemplate(info *GenerationInfo) Template

func NewStubInterfaceTemplate

func NewStubInterfaceTemplate(info *GenerationInfo) Template

type WriteStrategyState

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