generator

package
v0.0.0-...-6da336c Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Config

type Config struct {
	FilePath       string
	Pattern        string
	MetricName     string
	MetricHelp     string
	MetricHistName string
	MetricHistHelp string
	Out            io.Writer
	Mode           GeneratorMode
	// Package defines the packege for which this code should be generated
	Package string
}

func (*Config) Generate

func (c *Config) Generate(ctx context.Context) error

type GeneratorMode

type GeneratorMode string
const (
	// Binary mode can generate instrumented code for an interface which methods return an error as the last argument.
	// With respect to the value of the error (nil or not nil), the corresponding counter in the counter vector will be increased.
	Binary GeneratorMode = "binary"
	// Handler can generate instrumented wrappers around a typical http server interface.
	// Each method is a http.HandlerFunc `func(w http.ResponseWriter, r *http.Request)`.
	// Extensions with more parameters after the `*http.Request` are also possible.
	// This way server code generated by https://github.com/deepmap/oapi-codegen can be instrumented.
	Handler GeneratorMode = "handler"
	// OapiCodeGenClient mode generates instrumented code from the client interface generated by https://github.com/deepmap/oapi-codegen.
	// See https://github.com/deepmap/oapi-codegen#generated-client-boilerplate.
	OapiCodeGenClient GeneratorMode = "oapi-codegen-client"
)

type InstrumentedInterface

type InstrumentedInterface struct {
	*pkg.Interface
	InstrumentedTypeName string
	// contains filtered or unexported fields
}

func (*InstrumentedInterface) Imports

func (ii *InstrumentedInterface) Imports() []string

func (*InstrumentedInterface) Methods

func (ii *InstrumentedInterface) Methods() (methods []*Method)

func (*InstrumentedInterface) MetricHelp

func (ii *InstrumentedInterface) MetricHelp() string

func (*InstrumentedInterface) MetricHistHelp

func (ii *InstrumentedInterface) MetricHistHelp() string

func (*InstrumentedInterface) MetricHistName

func (ii *InstrumentedInterface) MetricHistName() string

func (*InstrumentedInterface) MetricName

func (ii *InstrumentedInterface) MetricName() string

func (*InstrumentedInterface) Package

func (ii *InstrumentedInterface) Package() string

func (*InstrumentedInterface) PackagePrefix

func (ii *InstrumentedInterface) PackagePrefix() string

func (*InstrumentedInterface) PrintType

func (ii *InstrumentedInterface) PrintType(t types.Type) string

func (*InstrumentedInterface) PrintTypeName

func (ii *InstrumentedInterface) PrintTypeName(t *types.TypeName) string

type Method

type Method struct {
	*pkg.Method
	// contains filtered or unexported fields
}

func (*Method) IsHandler

func (m *Method) IsHandler() bool

func (*Method) ParamsWithTypes

func (m *Method) ParamsWithTypes() (str string)

func (*Method) ParamsWithoutTypes

func (m *Method) ParamsWithoutTypes() (str string)

func (*Method) ResultTypes

func (m *Method) ResultTypes() (str string)

func (*Method) ResultsWithoutTypes

func (m *Method) ResultsWithoutTypes() (str string)

func (*Method) ReturnsError

func (m *Method) ReturnsError() bool

func (*Method) ReturnsHTTPResponse

func (m *Method) ReturnsHTTPResponse() bool

Jump to

Keyboard shortcuts

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