common

package
v0.0.0-...-c1a9e9f Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompilationStorage

type CompilationStorage interface {
	AddObject(pkgName string, stack []string, obj Renderer)
	RegisterProtocol(protoName string)
	AddExternalSpecPath(specPath *specurl.URL)
	AddPromise(p ObjectPromise)
	AddListPromise(p ObjectListPromise)

	SetDefaultContentType(contentType string)
	DefaultContentType() string

	SetActiveServers(servers []string)
	ActiveServers() []string

	SetActiveChannels(channels []string)
	ActiveChannels() []string
}

type CompileContext

type CompileContext struct {
	Storage     CompilationStorage
	Stack       types.SimpleStack[ContextStackItem]
	Logger      *CompilerLogger
	CompileOpts CompileOpts
	// contains filtered or unexported fields
}

func NewCompileContext

func NewCompileContext(specPath *specurl.URL, compileOpts CompileOpts) *CompileContext

func (*CompileContext) CurrentPackage

func (c *CompileContext) CurrentPackage() string

func (*CompileContext) GenerateObjName

func (c *CompileContext) GenerateObjName(name, suffix string) string

func (*CompileContext) PathStack

func (c *CompileContext) PathStack() []string

func (*CompileContext) PathStackRef

func (c *CompileContext) PathStackRef(joinParts ...string) string

PathStackRef returns a path to the current stack as a reference. NOTE: the reference is URL-encoded.

func (*CompileContext) PutListPromise

func (c *CompileContext) PutListPromise(p ObjectListPromise)

func (*CompileContext) PutObject

func (c *CompileContext) PutObject(obj Renderer)

func (*CompileContext) PutPromise

func (c *CompileContext) PutPromise(p ObjectPromise)

func (*CompileContext) RegisterNameTop

func (c *CompileContext) RegisterNameTop(n string)

func (*CompileContext) RuntimeModule

func (c *CompileContext) RuntimeModule(subPackage string) string

func (*CompileContext) WithResultsStore

func (c *CompileContext) WithResultsStore(store CompilationStorage) *CompileContext

type CompileOpts

type CompileOpts struct {
	ChannelOpts         ObjectCompileOpts
	MessageOpts         ObjectCompileOpts
	ModelOpts           ObjectCompileOpts
	ServerOpts          ObjectCompileOpts
	ReusePackages       map[string]string
	NoEncodingPackage   bool
	AllowRemoteRefs     bool
	RuntimeModule       string
	GeneratePublishers  bool
	GenerateSubscribers bool
}

type CompilerLogger

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

func (*CompilerLogger) Debug

func (c *CompilerLogger) Debug(msg string, args ...any)

func (*CompilerLogger) Fatal

func (c *CompilerLogger) Fatal(msg string, err error)

func (*CompilerLogger) Info

func (c *CompilerLogger) Info(msg string, args ...any)

func (*CompilerLogger) NextCallLevel

func (c *CompilerLogger) NextCallLevel()

func (*CompilerLogger) PrevCallLevel

func (c *CompilerLogger) PrevCallLevel()

func (*CompilerLogger) Trace

func (c *CompilerLogger) Trace(msg string, args ...any)

func (*CompilerLogger) Warn

func (c *CompilerLogger) Warn(msg string, args ...any)

type ContextStackItem

type ContextStackItem struct {
	PathItem       string
	Flags          map[SchemaTag]string
	PackageName    string
	RegisteredName string
}

type FileScope

type FileScope int
const (
	FileScopeName FileScope = iota
	FileScopeType
)

type GolangType

type GolangType interface {
	Renderer
	TypeName() string
}

type ObjectCompileOpts

type ObjectCompileOpts struct {
	Enable       bool
	IncludeRegex *regexp.Regexp
	ExcludeRegex *regexp.Regexp
}

func (ObjectCompileOpts) IsAllowedName

func (o ObjectCompileOpts) IsAllowedName(name string) bool

type ObjectListPromise

type ObjectListPromise interface {
	AssignList(objs []any)
	Assigned() bool
	FindCallback() func(item Renderer, path []string) bool
}

type ObjectPromise

type ObjectPromise interface {
	Assign(obj any)
	Assigned() bool
	FindCallback() func(item Renderer, path []string) bool
	Ref() string
	Origin() PromiseOrigin
}

type PackageScope

type PackageScope int
const (
	PackageScopeType PackageScope = iota
	PackageScopeAll
)

type PromiseOrigin

type PromiseOrigin int
const (
	PromiseOriginUser PromiseOrigin = iota
	PromiseOriginInternal
)

type ProtocolRenderer

type ProtocolRenderer interface {
	ProtocolName() string
	ProtocolTitle() string
}

type RenderContext

type RenderContext struct {
	ProtoRenderers map[string]ProtocolRenderer
	CurrentPackage string
	Logger         *types.Logger
	RenderOpts     RenderOpts
	// contains filtered or unexported fields
}

func (*RenderContext) GeneratedModule

func (c *RenderContext) GeneratedModule(subPackage string) string

func (*RenderContext) LogFinishRender

func (c *RenderContext) LogFinishRender()

func (*RenderContext) LogStartRender

func (c *RenderContext) LogStartRender(kind, pkg, name, mode string, directRendering bool, args ...any)

LogStartRender is typically called at the beginning of a RenderDefinition or RenderUsage method and logs that the object is started to be rendered. It also logs the object's name, type, and the current package. Every call to LogStartRender should be followed by a call to LogFinishRender which logs that the object is finished to be rendered.

func (*RenderContext) RuntimeModule

func (c *RenderContext) RuntimeModule(subPackage string) string

type RenderOpts

type RenderOpts struct {
	RuntimeModule string
	ImportBase    string
	TargetPackage string
	TargetDir     string
	PackageScope  PackageScope
	FileScope     FileScope
}

type Renderer

type Renderer interface {
	DirectRendering() bool
	RenderDefinition(ctx *RenderContext) []*jen.Statement
	RenderUsage(ctx *RenderContext) []*jen.Statement
	ID() string // Human-readable object identifier (typically it's the name), for logging, go file name, etc.
	String() string
}

type SchemaTag

type SchemaTag string
const (
	// SchemaTagDirectRender marks that an object must have directRender=true
	SchemaTagDirectRender SchemaTag = "directRender"
	// SchemaTagPkgScope sets the package scope for an object. Inherited by nested objects
	SchemaTagPkgScope SchemaTag = "pkgScope"
	// SchemaTagComponent marks all top-level objects in `component` section
	SchemaTagComponent SchemaTag = "components"
	// SchemaTagMarshal marks that an object is meant to be marshaled/unmarshaled. Inherited by nested objects
	SchemaTagMarshal SchemaTag = "marshal"
)

Jump to

Keyboard shortcuts

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