inject

package module
v1.0.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 14 Imported by: 0

README

inject

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAnnotationIDType = errors.New("not a valid AnnotationIDType")
View Source
var ErrInvalidAnnotationType = errors.New("not a valid AnnotationType")
View Source
var ErrInvalidModuleAttr = errors.New("not a valid ModuleAttr")

Functions

func CollectEntries

func CollectEntries(path string) ([]annotation.Entry, error)

func NewTemplate

func NewTemplate() (*template.Template, error)

func WithLogger

func WithLogger(logger Logger)

Types

type Annotation

type Annotation struct {
	Index *int
	Name  string
	Group string
}

func (*Annotation) ID

func (a *Annotation) ID() string

type AnnotationIDType

type AnnotationIDType int

ENUM(DEFAULT,NAMED,GROUPED)

const (
	// AnnotationIDTypeDEFAULT is a AnnotationIDType of type DEFAULT.
	AnnotationIDTypeDEFAULT AnnotationIDType = iota
	// AnnotationIDTypeNAMED is a AnnotationIDType of type NAMED.
	AnnotationIDTypeNAMED
	// AnnotationIDTypeGROUPED is a AnnotationIDType of type GROUPED.
	AnnotationIDTypeGROUPED
)

func ParseAnnotationIDType

func ParseAnnotationIDType(name string) (AnnotationIDType, error)

ParseAnnotationIDType attempts to convert a string to a AnnotationIDType.

func (AnnotationIDType) IsValid

func (x AnnotationIDType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (AnnotationIDType) MarshalText

func (x AnnotationIDType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (AnnotationIDType) String

func (x AnnotationIDType) String() string

String implements the Stringer interface.

func (*AnnotationIDType) UnmarshalText

func (x *AnnotationIDType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type AnnotationType

type AnnotationType int

ENUM(MODULE,PROVIDE,INJECT,INVOKE)

const (
	// AnnotationTypeMODULE is a AnnotationType of type MODULE.
	AnnotationTypeMODULE AnnotationType = iota
	// AnnotationTypePROVIDE is a AnnotationType of type PROVIDE.
	AnnotationTypePROVIDE
	// AnnotationTypeINJECT is a AnnotationType of type INJECT.
	AnnotationTypeINJECT
	// AnnotationTypeINVOKE is a AnnotationType of type INVOKE.
	AnnotationTypeINVOKE
)

func ParseAnnotationType

func ParseAnnotationType(name string) (AnnotationType, error)

ParseAnnotationType attempts to convert a string to a AnnotationType.

func (AnnotationType) IsValid

func (x AnnotationType) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (AnnotationType) MarshalText

func (x AnnotationType) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (AnnotationType) String

func (x AnnotationType) String() string

String implements the Stringer interface.

func (*AnnotationType) UnmarshalText

func (x *AnnotationType) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type Component

type Component struct {
	Entry annotation.Entry
	An    Annotation
}

type DefaultLogger

type DefaultLogger struct{}

func (DefaultLogger) Debug

func (n DefaultLogger) Debug(args ...interface{})

func (DefaultLogger) Debugf

func (n DefaultLogger) Debugf(format string, args ...interface{})

func (DefaultLogger) Error

func (n DefaultLogger) Error(args ...interface{})

func (DefaultLogger) Errorf

func (n DefaultLogger) Errorf(format string, args ...interface{})

func (DefaultLogger) Fatal

func (n DefaultLogger) Fatal(args ...interface{})

func (DefaultLogger) Fatalf

func (n DefaultLogger) Fatalf(format string, args ...interface{})

func (DefaultLogger) Info

func (n DefaultLogger) Info(args ...interface{})

func (DefaultLogger) Infof

func (n DefaultLogger) Infof(format string, args ...interface{})

func (DefaultLogger) Panic

func (n DefaultLogger) Panic(args ...interface{})

func (DefaultLogger) Panicf

func (n DefaultLogger) Panicf(format string, args ...interface{})

func (DefaultLogger) Trace

func (n DefaultLogger) Trace(args ...interface{})

func (DefaultLogger) Tracef

func (n DefaultLogger) Tracef(format string, args ...interface{})

func (DefaultLogger) Warn

func (n DefaultLogger) Warn(args ...interface{})

func (DefaultLogger) Warnf

func (n DefaultLogger) Warnf(format string, args ...interface{})

type Generator

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

func NewGenerator

func NewGenerator(moduleName string, graph *Graph[Component]) *Generator

func (*Generator) Generate

func (p *Generator) Generate(ctx context.Context) error

type Graph

type Graph[T any] struct {
	// contains filtered or unexported fields
}

Graph represents a generic graph structure with vertices of any type. It includes maps for vertices, incoming edges, and edges for efficient graph operations.

func NewGraph

func NewGraph[T any]() *Graph[T]

NewGraph creates and returns a new instance of Graph.

func NewGraphFromEntries

func NewGraphFromEntries(ctx context.Context, entries []annotation.Entry) (*Graph[Component], error)

func (*Graph[T]) AddEdge

func (g *Graph[T]) AddEdge(fromKey, toKey string)

AddEdge adds a directed edge from one vertex to another. If either vertex does not exist, it logs a warning and does not add the edge.

func (*Graph[T]) AddVertex

func (g *Graph[T]) AddVertex(key string, value T)

AddVertex adds a new vertex with the specified key and value to the graph. If the vertex already exists, it logs a warning and does not overwrite it.

func (*Graph[T]) ExportToGraphviz

func (g *Graph[T]) ExportToGraphviz(filename string) error

func (*Graph[T]) Print

func (g *Graph[T]) Print()

func (*Graph[T]) VerticesWithNoIncomingEdges

func (g *Graph[T]) VerticesWithNoIncomingEdges() []*Vertex[T]

VerticesWithNoIncomingEdges returns a list of vertices with no incoming edges.

type ImportData

type ImportData struct {
	Alias string
	Path  string
	Entry annotation.Entry
}

type Logger

type Logger interface {
	Tracef(format string, args ...interface{})

	Trace(args ...interface{})

	Debugf(format string, args ...interface{})

	Debug(args ...interface{})

	Infof(format string, args ...interface{})

	Info(args ...interface{})

	Warnf(format string, args ...interface{})

	Warn(args ...interface{})

	Errorf(format string, args ...interface{})

	Error(args ...interface{})

	Fatalf(format string, args ...interface{})

	Fatal(args ...interface{})

	Panicf(format string, args ...interface{})

	Panic(args ...interface{})
}

Logger is our contract for the logger.

func NewLogger

func NewLogger() Logger

type ModuleAttr

type ModuleAttr int

ENUM(MODULE,PATH,PACKAGE,FUNC)

const (
	// ModuleAttrMODULE is a ModuleAttr of type MODULE.
	ModuleAttrMODULE ModuleAttr = iota
	// ModuleAttrPATH is a ModuleAttr of type PATH.
	ModuleAttrPATH
	// ModuleAttrPACKAGE is a ModuleAttr of type PACKAGE.
	ModuleAttrPACKAGE
	// ModuleAttrFUNC is a ModuleAttr of type FUNC.
	ModuleAttrFUNC
)

func ParseModuleAttr

func ParseModuleAttr(name string) (ModuleAttr, error)

ParseModuleAttr attempts to convert a string to a ModuleAttr.

func (ModuleAttr) IsValid

func (x ModuleAttr) IsValid() bool

IsValid provides a quick way to determine if the typed value is part of the allowed enumerated values

func (ModuleAttr) MarshalText

func (x ModuleAttr) MarshalText() ([]byte, error)

MarshalText implements the text marshaller method.

func (ModuleAttr) String

func (x ModuleAttr) String() string

String implements the Stringer interface.

func (*ModuleAttr) UnmarshalText

func (x *ModuleAttr) UnmarshalText(text []byte) error

UnmarshalText implements the text unmarshaller method.

type ModuleData

type ModuleData struct {
	PackageName  string
	FunctionName string
	ImportPath   string
	Modules      []ImportData
	Imports      []ImportData
	Alias        string
	Entry        annotation.Entry
	Type         string
}

type Vertex

type Vertex[T any] struct {
	Key   string // Unique identifier of the vertex.
	Value T      // Value stored in the vertex.
	// contains filtered or unexported fields
}

Vertex represents a node in a graph with a key and a value. It also holds a reference to the graph it belongs to for graph operations.

func (*Vertex[T]) Adjacent

func (v *Vertex[T]) Adjacent() []*Vertex[T]

Adjacent returns a list of adjacent vertices to this vertex. It returns nil if the vertex is not part of a graph.

func (*Vertex[T]) Incoming

func (v *Vertex[T]) Incoming() []*Vertex[T]

Incoming returns a list of vertices with edges incoming to this vertex. It iterates over all edges in the graph to find incoming connections.

Directories

Path Synopsis
cmd
examples

Jump to

Keyboard shortcuts

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