pattern

package
v0.5.42 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertMapInterfaceMapString

func ConvertMapInterfaceMapString(v interface{}) interface{}

ConvertMapInterfaceMapString converts map[interface{}]interface{} => map[string]interface{}

It will also convert []interface{} => []string

func RecursiveCastMapStringInterfaceToMapStringInterface

func RecursiveCastMapStringInterfaceToMapStringInterface(in map[string]interface{}) map[string]interface{}

RecursiveCastMapStringInterfaceToMapStringInterface will convert a map[string]interface{} recursively => map[string]interface{}

func RegisterMesheryOAMTraits

func RegisterMesheryOAMTraits() error

RegisterMesheryOAMTraits will register local meshery traits with meshery server

func RegisterMesheryOAMWorkloads

func RegisterMesheryOAMWorkloads() error

RegisterMesheryOAMWorkloads will register local meshery workloads with meshery server

func RegisterScope

func RegisterScope(data []byte) (err error)

RegisterScope will register a Scope definition into the database

func RegisterTrait

func RegisterTrait(data []byte) (err error)

RegisterTrait will register a TraitDefinition into the database

func RegisterWorkload

func RegisterWorkload(data []byte) (err error)

RegisterWorkload will register a workload definition into the database

Types

type Graph

type Graph struct {
	Nodes map[string]*Node
	Edges map[string][]string

	sync.RWMutex
}

Graph represents the graph data structure

func NewGraph

func NewGraph() *Graph

NewGraph creates a new instance of the graph and returns a pointer to it

func (*Graph) AddEdge

func (g *Graph) AddEdge(src, dest string) *Graph

AddEdge adds edge from source to destination nodes

These edges are unidirectional, hence for bidirectional edges this method needs to be called twice

func (*Graph) AddNode

func (g *Graph) AddNode(name string, data Service) *Graph

AddNode adds a node to the graph

func (*Graph) DetectCycle

func (g *Graph) DetectCycle() bool

DetectCycle will return true if there is a cycle in the graph

func (*Graph) Order

func (g *Graph) Order() int

Order returns the count for number of edges

func (*Graph) Traverse

func (g *Graph) Traverse(fn VisitFn)

Traverse traverses the graph in topological sorted order and executes the visit function on each visited node

func (*Graph) Visit

func (g *Graph) Visit(fn VisitFn)

Visit visits each node in the graph but does not keep track of the pre-visited nodes

type Node

type Node struct {
	Data Service
}

Node is a graph node

type ParallelProcessGraph

type ParallelProcessGraph struct {
	Edges map[string][]string

	ParallelProcessGraphNodeMap map[string]*ParallelProcessGraphNode
	// contains filtered or unexported fields
}

ParallelProcessGraph provides methods for parallel processing of the graph

func NewParallelProcessGraph

func NewParallelProcessGraph(g *Graph) *ParallelProcessGraph

NewParallelProcessGraph creates a parallel processing graph from a simple graph returns a pointer to ParallelProcessGraph

func (*ParallelProcessGraph) Traverse

func (g *ParallelProcessGraph) Traverse(fn VisitFn)

Traverse spins up the processes concurrently if it can

type ParallelProcessGraphNode

type ParallelProcessGraphNode struct {
	Name string
	Data *Node

	DepUpdateCh chan struct{}
	DepCancleCh chan struct{}

	DepCount int
	// contains filtered or unexported fields
}

ParallelProcessGraphNode is the node for ParallelProcessGraph it contains the constructs for channel based communication

func (*ParallelProcessGraphNode) Process

Process starts an internal loop which listens for the signals on the channels and operate accordingly

type Pattern

type Pattern struct {
	Name     string              `yaml:"name,omitempty"`
	Services map[string]*Service `yaml:"services,omitempty"`
}

Pattern is the golang representation of the Pattern config file model

func NewPatternFile

func NewPatternFile(yml []byte) (af Pattern, err error)

NewPatternFile takes in raw yaml and encodes it into a construct

func NewPatternFileFromCytoscapeJSJSON

func NewPatternFileFromCytoscapeJSJSON(byt []byte) (Pattern, error)

NewPatternFileFromCytoscapeJSJSON takes in CytoscapeJS JSON and creates a PatternFile from it

func (*Pattern) GenerateApplicationConfiguration

func (p *Pattern) GenerateApplicationConfiguration() (v1alpha1.Configuration, error)

GenerateApplicationConfiguration generates OAM Application Configuration from the the given Pattern file for a particular deploymnet

func (*Pattern) GetApplicationComponent

func (p *Pattern) GetApplicationComponent(name string) (v1alpha1.Component, error)

GetApplicationComponent generates OAM Application Components from the the given Pattern file

func (*Pattern) GetServiceType

func (p *Pattern) GetServiceType(name string) string

GetServiceType returns the type of the service

func (*Pattern) ToCytoscapeJS

func (p *Pattern) ToCytoscapeJS() (cytoscapejs.GraphElem, error)

ToCytoscapeJS converts pattern file into cytoscape object

func (*Pattern) ToYAML

func (p *Pattern) ToYAML() ([]byte, error)

ToYAML converts a patternfile to yaml

type Plan

type Plan struct {
	Data Pattern
	*Graph
}

Plan struct represents a node of an execution plan

func CreatePlan

func CreatePlan(pattern Pattern, policies [][2]string) (*Plan, error)

CreatePlan takes in the application components and creates a plan of execution for it

func (*Plan) Execute

func (p *Plan) Execute(cb func(string, Service) bool) error

Execute traverses the plan and calls the callback function on each of the node

func (*Plan) IsFeasible

func (p *Plan) IsFeasible() bool

IsFeasible returns true if the plan execution is feasible

type Queue

type Queue struct {
	InternalQueue []string

	sync.RWMutex
}

Queue is the thread safe queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() string

Dequeue removes data from the queue

func (*Queue) Enqueue

func (q *Queue) Enqueue(str string)

Enqueue data to the queue

func (*Queue) Length

func (q *Queue) Length() int

Length returns the length of the queue

func (*Queue) Peek

func (q *Queue) Peek() string

Peek returns the first item in the queue

type ScopeCapability

type ScopeCapability struct {
	OAMDefinition v1alpha1.ScopeDefinition `json:"oam_definition,omitempty"`
	// contains filtered or unexported fields
}

ScopeCapability is the struct for capturing the ScopeDefinition of a particular type

func GetScopes

func GetScopes() (scopes []ScopeCapability)

GetScopes return all of the scopes

type Service

type Service struct {
	Type      string   `yaml:"type,omitempty"`
	Namespace string   `yaml:"namespace,omitempty"`
	DependsOn []string `yaml:"dependsOn,omitempty"`

	Settings map[string]interface{} `yaml:"settings,omitempty"`
	Traits   map[string]interface{} `yaml:"traits,omitempty"`
}

Service represents the services defined within the appfile

type TraitCapability

type TraitCapability struct {
	OAMDefinition v1alpha1.TraitDefinition `json:"oam_definition,omitempty"`
	// contains filtered or unexported fields
}

TraitCapability is the struct for capturing the workload definition of a particular type

func GetTraits

func GetTraits() (traits []TraitCapability)

GetTraits return all of the traits

func ValidateTrait

func ValidateTrait(
	trait interface{},
	configSpecComp v1alpha1.ConfigurationSpecComponent,
	af Pattern,
) (*TraitCapability, error)

ValidateTrait takes in a trait and a component and checks if the given trait is legal on that component or not. The function ASSUMES that if this function is called with a trait and corresponding component then the trait DOES EXIST in the ApplicationConfiguration

After checking if the applied trait is legal or not it will validate the schema of the trait

type VisitFn

type VisitFn func(name string, node Service) bool

VisitFn is the function definition for the visitor function

type WorkloadCapability

type WorkloadCapability struct {
	OAMDefinition v1alpha1.WorkloadDefinition `json:"oam_definition,omitempty"`
	// contains filtered or unexported fields
}

WorkloadCapability is the struct for capturing the workload definition of a particular type

func GetWorkloads

func GetWorkloads() (caps []WorkloadCapability)

GetWorkloads return all of the workloads

func ValidateWorkload

func ValidateWorkload(workload interface{}, component v1alpha1.Component) (*WorkloadCapability, error)

ValidateWorkload takes in a workload and validates it against the corresponding schema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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