topology

package
v0.0.0-...-3dc5271 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2017 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

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

func NewContext

func NewContext(def []Input, inputs map[string]interface{}) *Context

func (*Context) FormatValue

func (p *Context) FormatValue(value string) interface{}

func (*Context) GetDefaultValue

func (p *Context) GetDefaultValue(name string) string

func (*Context) GetValue

func (p *Context) GetValue(name string) interface{}

type Dependency

type Dependency struct {
	//	gorm.Model
	NodeTemplateID int    //`gorm:"index"`  //Foreign key of the node template
	Type           string `json:"type"`   //The type of dependency: connect;contained
	Target         string `json:"target"` //The name of target node
}

Dependency is relationship between two node

type Input

type Input struct {
	Name  string
	Type  string
	Value string
}

Input define arguments that used by nodes

type Iterator

type Iterator interface {
}

Iterator iterate a topology

type Link struct {
	gorm.Model
	NodeID int    `gorm:"index"` //Foreign key of the node
	Type   string //link type
	Source string //source node name
	Target string //target node name
}

Link two nodes

type Node

type Node struct {
	gorm.Model
	Status
	TopologyID int         `gorm:"index"` //Foreign key of the topology
	Name       string      //node name
	Template   string      //template name
	Class      string      //the name of resource class
	Address    string      //address of node.
	Credential string      //credential key
	Links      []*Link     //dependencies of node
	Properties []*Property //the configuration of a node

	Done    chan error `gorm:"-" json:"-"`
	Timeout chan bool  `gorm:"-" json:"-"`
}

Node is element of topology

func (*Node) FindLinksByType

func (p *Node) FindLinksByType(depType string) []*Link

findLinksByType return all links of depType

func (p *Node) Link(depType string, target string)

link the source node to the target node

type NodeTemplate

type NodeTemplate struct {
	Name         string       `json:"name"`         //Node name
	Type         string       `json:"type"`         //The name of NodeType
	Parameters   []Parameter  `json:parameters`     //parameters of NodeTemplate
	Dependencies []Dependency `json:"dependencies"` //The dependencies of node
}

NodeTemplate is a prototype of service node.

type Parameter

type Parameter struct {
	//	gorm.Model
	NodeTemplateID int    //`gorm:"index"` //Foreign key of the node template
	Name           string `json:"name"`
	Value          string `json:"value"`
}

Parameter is used to generate the node of template

type Property

type Property struct {
	gorm.Model
	NodeID int `gorm:"index"` //Foreign key of the node
	Key    string
	Value  string
}

Link two nodes

type RunStatus

type RunStatus int

RunStatus of the topology or node

const (
	//when new
	RunStatusNone RunStatus = iota

	//all elements ok
	RunStatusGreen

	//some ok,some failed
	RunStatusYellow

	//all elements failed
	RunStatusRed

	DownStatusGreen

	DownStatusYellow

	DownStatusRed
)

type ServiceTemplate

type ServiceTemplate struct {
	Path        string
	Name        string         `json:"name"`
	Version     int32          `json:"version"`
	Environment string         `json:"environment"` //standalone|distributed
	Inputs      []Input        `json:"inputs"`
	Nodes       []NodeTemplate `json:"nodes"`
}

ServiceTemplate is a prototype of service.

func (*ServiceTemplate) FindTemplate

func (p *ServiceTemplate) FindTemplate(name string) *NodeTemplate

FindNode return the node

func (*ServiceTemplate) NewTopology

func (p *ServiceTemplate) NewTopology(name string, version int, ctx *Context) *Topology

CreateTopology create a topology by the service template.

type Status

type Status struct {
	RunStatus RunStatus
	Error     string
}

Status of the topology or node

type Topology

type Topology struct {
	gorm.Model
	Status
	Name     string  `json:"name"`     //topology name
	Template string  `json:"template"` //service template name
	Version  int     `json:"version"`  //service template version
	Nodes    []*Node `json:"nodes"`
}

Topology which has been deployed by the service template

func (*Topology) AddNode

func (p *Topology) AddNode(node *Node)

Only used to add host node

func (*Topology) GetNode

func (p *Topology) GetNode(name string) *Node

func (*Topology) GetNodes

func (p *Topology) GetNodes(name string) []*Node

func (*Topology) PutNode

func (p *Topology) PutNode(node *Node)

Jump to

Keyboard shortcuts

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