vertex

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CollectorEntries

type CollectorEntries []CollectorEntry

CollectorEntries is type alias for the CollectorEntries slice

type CollectorEntry

type CollectorEntry struct {
	In []In
	Fn string
}

CollectorEntry entry is collector interface struct which contain: 1. in types like func (a int, b string etc...) 2 function name

type Entry

type Entry struct {
	// RefID, structure, which provides interface dep
	RefID string
	// Name of the entry
	Name string
	// IsReference, can be true, false or nil (unknown)
	IsReference *bool
	// IsDisabled retrun true if vertex returns errors.Disabled
	IsDisabled bool
	// Kind is just reflect.Kind
	Kind reflect.Kind
}

Entry is the general entry used in InitDepsToInvoke, CollectsDepsToInvoke, addToList and etc..

type FnsToCall

type FnsToCall [][]string

FnsToCall is slice with the functions which can return the same resulting set of values for example fn a() b --| fn c() b ----> both a and c returns b

type In

type In struct {
	In  reflect.Value
	Dep string
}

In struct represents In value, which contain: 1. 'in' as reflect.Value 2. dep name as string

type Meta

type Meta struct {
	// FnsProviderToInvoke is the function names to invoke if type implements Provides() interface
	FnsProviderToInvoke ProviderEntries
	// CollectorEntries is the function names to invoke if type implements Collector() interface
	CollectorEntries CollectorEntries

	// List of the vertex deps
	// foo4.DB, foo4.S4 etc.. which were found in the Init() method
	InitDepsToInvoke map[string][]Entry
	InitDepsOrd      []string

	// List of the vertex deps
	// foo4.DB, foo4.S4 etc.. which were found in the Collects() method
	CollectsDepsToInvoke map[string][]Entry
}

Meta information included into the Vertex May include: 1. Disabled info 2. Relation status

func NewMeta

func NewMeta() Meta

type ProvidedEntry

type ProvidedEntry struct {
	Str string
	// we need to distinguish false (default bool value) and nil --> we don't know information about reference
	IsReference *bool
	Value       reflect.Value
	Kind        reflect.Kind
}

ProvidedEntry is proviers helper entity

type ProviderEntries

type ProviderEntries []ProviderEntry

ProviderEntries is type alias for the ProviderEntry slice

func (*ProviderEntries) Merge

func (pe *ProviderEntries) Merge() FnsToCall

Merge creates FnsToCall

type ProviderEntry

type ProviderEntry struct {
	FunctionName  string
	ReturnTypeIds []string
}

ProviderEntry is Provides interface method representation. It consists of: 1. Function name 2. Return type Ids (strings), for example foo.S2

type Vertex

type Vertex struct {
	// ID of the vertex, currently string representation of the structure fn
	ID string
	// Vertex (Registered structure)
	Iface any
	// Meta information about current Vertex
	Meta Meta
	// Dependencies of the node
	Dependencies []*Vertex
	// Set of entries which can vertex provide (for example, foo4 vertex can provide DB instance and logger)
	Provides map[string]ProvidedEntry

	// If vertex disabled it removed from the processing (Init, Serve, Stop), but present in the graph
	IsDisabled bool
	// for the topological sort, private
	NumOfDeps int
	Visited   bool
	Visiting  bool
	// contains filtered or unexported fields
}

Vertex is main vertex representation for the graph since we can have cyclic dependencies when we traverse the VerticesMap, we should mark nodes as visited or not to detect cycle

func NewVertex

func NewVertex() *Vertex

func (*Vertex) AddProvider

func (v *Vertex) AddProvider(valueKey string, value reflect.Value, isRef bool, kind reflect.Kind)

AddProvider adds an provider for a dep (vertex->vertex)

func (*Vertex) GetState

func (v *Vertex) GetState() fsm.State

GetState gets the vertex state

func (*Vertex) RemoveProvider

func (v *Vertex) RemoveProvider(valueKey string)

RemoveProvider removes provider from the map

func (*Vertex) SetState

func (v *Vertex) SetState(st fsm.State)

SetState sets the state for the vertex

Jump to

Keyboard shortcuts

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