agent

package
v0.0.0-...-fb044b6 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ADD_HOST        = "khutulun.addHost"
	PROCESS_SERVICE = "khutulun.processService"
)
View Source
const BUFFER_SIZE = 65536
View Source
const DEFAULT_MAX_MESSAGE_SIZE = 8192
View Source
const TICKER_FREQUENCY = 30 * time.Second

Variables

This section is empty.

Functions

func NewAddHostCommand

func NewAddHostCommand(address string) map[string]any

func NewProcessServiceCommand

func NewProcessServiceCommand(namespace string, serviceName string, phase string) map[string]any

Types

type Agent

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

func NewAgent

func NewAgent(stateRootDir string) (*Agent, error)

func (*Agent) CoerceClout

func (self *Agent) CoerceClout(clout *cloutpkg.Clout, copy_ bool) (*cloutpkg.Clout, error)

func (*Agent) CompileTOSCA

func (self *Agent) CompileTOSCA(context contextpkg.Context, templateNamespace string, templateName string, serviceNamespace string, serviceName string) (*cloutpkg.Clout, *problemspkg.Problems, error)

func (*Agent) DeployService

func (self *Agent) DeployService(context contextpkg.Context, templateNamespace string, templateName string, serviceNamespace string, serviceName string, async bool) error

func (*Agent) Instantiate

func (self *Agent) Instantiate(clout *cloutpkg.Clout, coercedClout *cloutpkg.Clout) bool

func (*Agent) ListResources

func (self *Agent) ListResources(context contextpkg.Context, namespace string, serviceName string, type_ string) (ResourceIdentifiers, error)

func (*Agent) NewDelegate

func (self *Agent) NewDelegate(namespace string, delegateName string) (Delegate, error)

func (*Agent) NewDelegates

func (self *Agent) NewDelegates() *Delegates

func (*Agent) NewPluginDelegate

func (self *Agent) NewPluginDelegate(namespace string, delegateName string) (*PluginDelegate, error)

func (*Agent) OpenFile

func (self *Agent) OpenFile(path string, coerceClout bool) (io.ReadCloser, error)

func (*Agent) ParseTOSCA

func (self *Agent) ParseTOSCA(context contextpkg.Context, templateNamespace string, templateName string) (*normal.ServiceTemplate, *problemspkg.Problems, error)

func (*Agent) ProcessAllServices

func (self *Agent) ProcessAllServices(context contextpkg.Context, phase string)

func (*Agent) ProcessNext

func (self *Agent) ProcessNext(context contextpkg.Context, next []delegatepkg.Next, delegates *Delegates)

func (*Agent) ProcessService

func (self *Agent) ProcessService(context contextpkg.Context, namespace string, serviceName string, phase string, delegates *Delegates)

func (*Agent) Release

func (self *Agent) Release() error

type Broadcaster

type Broadcaster struct {
	Protocol string

	Port int
	// contains filtered or unexported fields
}

func NewBroadcaster

func NewBroadcaster(protocol string, address string, port int) *Broadcaster

func (*Broadcaster) Address

func (self *Broadcaster) Address() *net.UDPAddr

func (*Broadcaster) Send

func (self *Broadcaster) Send(message []byte) error

func (*Broadcaster) SendJSON

func (self *Broadcaster) SendJSON(message any) error

func (*Broadcaster) Start

func (self *Broadcaster) Start() error

func (*Broadcaster) Stop

func (self *Broadcaster) Stop() error

type Delegate

type Delegate interface {
	Name() (string, string)
	Delegate() delegatepkg.Delegate
	Release() error
}

type Delegates

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

func (*Delegates) All

func (self *Delegates) All() []delegatepkg.Delegate

func (*Delegates) Fill

func (self *Delegates) Fill(namespace string, coercedClout *cloutpkg.Clout)

func (*Delegates) Get

func (self *Delegates) Get(namespace string, delegateName string) (delegatepkg.Delegate, error)

func (*Delegates) NewDelegate

func (self *Delegates) NewDelegate(namespace string, delegateName string) (Delegate, error)

func (*Delegates) Release

func (self *Delegates) Release()

type GRPC

type GRPC struct {
	api.UnimplementedAgentServer

	Protocol string
	Address  string
	Port     int
	Local    bool
	// contains filtered or unexported fields
}

func NewGRPC

func NewGRPC(agent *Agent, protocol string, address string, port int) *GRPC

func (*GRPC) AddHost

func (self *GRPC) AddHost(context contextpkg.Context, addHost *api.AddHost) (*emptypb.Empty, error)

api.AgentServer interface

func (*GRPC) DeployService

func (self *GRPC) DeployService(context contextpkg.Context, deployService *api.DeployService) (*emptypb.Empty, error)

api.AgentServer interface

func (*GRPC) GetPackageFiles

func (self *GRPC) GetPackageFiles(getPackageFiles *api.GetPackageFiles, server api.Agent_GetPackageFilesServer) error

api.AgentServer interface

func (*GRPC) GetVersion

func (self *GRPC) GetVersion(context contextpkg.Context, empty *emptypb.Empty) (*api.Version, error)

api.AgentServer interface

func (*GRPC) Interact

func (self *GRPC) Interact(server api.Agent_InteractServer) error

api.AgentServer interface

func (*GRPC) ListHosts

func (self *GRPC) ListHosts(empty *emptypb.Empty, server api.Agent_ListHostsServer) error

api.AgentServer interface

func (*GRPC) ListNamespaces

func (self *GRPC) ListNamespaces(empty *emptypb.Empty, server api.Agent_ListNamespacesServer) error

api.AgentServer interface

func (*GRPC) ListPackageFiles

func (self *GRPC) ListPackageFiles(identifier *api.PackageIdentifier, server api.Agent_ListPackageFilesServer) error

api.AgentServer interface

func (*GRPC) ListPackages

func (self *GRPC) ListPackages(listPackages *api.ListPackages, server api.Agent_ListPackagesServer) error

api.AgentServer interface

func (*GRPC) ListResources

func (self *GRPC) ListResources(listResources *api.ListResources, server api.Agent_ListResourcesServer) error

api.AgentServer interface

func (*GRPC) RemovePackage

func (self *GRPC) RemovePackage(context contextpkg.Context, packageIdentifer *api.PackageIdentifier) (*emptypb.Empty, error)

api.AgentServer interface

func (*GRPC) SetPackageFiles

func (self *GRPC) SetPackageFiles(server api.Agent_SetPackageFilesServer) error

api.AgentServer interface

func (*GRPC) Start

func (self *GRPC) Start() error

func (*GRPC) Stop

func (self *GRPC) Stop()

type Gossip

type Gossip struct {
	Address string
	Port    int // memberlist default is 7946
	// contains filtered or unexported fields
}

func NewGossip

func NewGossip(address string, port int) *Gossip

func (*Gossip) AddHosts

func (self *Gossip) AddHosts(gossipAddresses []string) error

func (*Gossip) Announce

func (self *Gossip) Announce() error

func (*Gossip) GetBroadcasts

func (self *Gossip) GetBroadcasts(overhead int, limit int) [][]byte

memberlist.Delegate interface

func (*Gossip) GetHost

func (self *Gossip) GetHost(name string) *HostInformation

func (*Gossip) GetMember

func (self *Gossip) GetMember(host string) (*memberlist.Node, bool)

func (*Gossip) ListHosts

func (self *Gossip) ListHosts() HostInformations

func (*Gossip) LocalGossipAddress

func (self *Gossip) LocalGossipAddress() string

func (*Gossip) LocalState

func (self *Gossip) LocalState(join bool) []byte

memberlist.Delegate interface

func (*Gossip) MergeRemoteState

func (self *Gossip) MergeRemoteState(buf []byte, join bool)

memberlist.Delegate interface

func (*Gossip) NodeMeta

func (self *Gossip) NodeMeta(limit int) []byte

memberlist.Delegate interface

func (*Gossip) NotifyMsg

func (self *Gossip) NotifyMsg(bytes []byte)

memberlist.Delegate interface

func (*Gossip) Send

func (self *Gossip) Send(host string, message []byte) error

func (*Gossip) SendJSON

func (self *Gossip) SendJSON(host string, message any) error

func (*Gossip) Start

func (self *Gossip) Start() error

func (*Gossip) Stop

func (self *Gossip) Stop() error

type HTTP

type HTTP struct {
	Protocol string
	Address  string
	Port     int
	// contains filtered or unexported fields
}

func NewHTTP

func NewHTTP(agent *Agent, protocol string, address string, port int) (*HTTP, error)

func (*HTTP) Start

func (self *HTTP) Start() error

func (*HTTP) Stop

func (self *HTTP) Stop() error

type HostInformation

type HostInformation struct {
	Name        string `json:"name"`
	GRPCAddress string `json:"grpcAddress"`
}

type HostInformations

type HostInformations []*HostInformation

func (HostInformations) Len

func (self HostInformations) Len() int

sort.Interface interface

func (HostInformations) Less

func (self HostInformations) Less(i, j int) bool

sort.Interface interface

func (HostInformations) Swap

func (self HostInformations) Swap(i, j int)

sort.Interface interface

type Namespaced

type Namespaced struct {
	Namespace string
	Name      string
}

func NewNamespaced

func NewNamespaced(namespace string, name string) Namespaced

type OnMessageFunc

type OnMessageFunc func(bytes []byte, broadcast bool)

type PluginDelegate

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

func (*PluginDelegate) Delegate

func (self *PluginDelegate) Delegate() delegatepkg.Delegate

Delegate interface

func (*PluginDelegate) Name

func (self *PluginDelegate) Name() (string, string)

Delegate interface

func (*PluginDelegate) Release

func (self *PluginDelegate) Release() error

Delegate interface

type ReceiveFunc

type ReceiveFunc func(address *net.UDPAddr, message []byte)

type Receiver

type Receiver struct {
	Protocol       string
	Inter          *net.Interface
	Address        string
	Port           int
	Receive        ReceiveFunc
	MaxMessageSize int
	Ignore         []*net.UDPAddr
	// contains filtered or unexported fields
}

func NewReceiver

func NewReceiver(protocol string, inter *net.Interface, address string, port int, receive ReceiveFunc) *Receiver

func (*Receiver) Start

func (self *Receiver) Start() error

func (*Receiver) Stop

func (self *Receiver) Stop() error

type ResourceIdentifier

type ResourceIdentifier struct {
	Namespace string `json:"namespace" yaml:"namespace"`
	Service   string `json:"service" yaml:"service"`
	Type      string `json:"type" yaml:"type"`
	Name      string `json:"name" yaml:"name"`
	Host      string `json:"host" yaml:"host"`
}

type ResourceIdentifiers

type ResourceIdentifiers []ResourceIdentifier

func (ResourceIdentifiers) Len

func (self ResourceIdentifiers) Len() int

sort.Interface interface

func (ResourceIdentifiers) Less

func (self ResourceIdentifiers) Less(i, j int) bool

sort.Interface interface

func (ResourceIdentifiers) Swap

func (self ResourceIdentifiers) Swap(i, j int)

sort.Interface interface

type Server

type Server struct {
	GRPCProtocol       string
	GRPCAddress        string
	GRPCPort           int
	HTTPProtocol       string
	HTTPAddress        string
	HTTPPort           int
	GossipAddress      string
	GossipPort         int
	BroadcastProtocol  string
	BroadcastInterface *net.Interface
	BroadcastAddress   string // https://en.wikipedia.org/wiki/Multicast_address
	BroadcastPort      int
	// contains filtered or unexported fields
}

func NewServer

func NewServer(agent *Agent) *Server

func (*Server) Start

func (self *Server) Start(watcher bool, ticker bool) error

func (*Server) Stop

func (self *Server) Stop()

type Ticker

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

func NewTicker

func NewTicker(frequency time.Duration, f func()) *Ticker

func (*Ticker) Start

func (self *Ticker) Start()

func (*Ticker) Stop

func (self *Ticker) Stop()

Jump to

Keyboard shortcuts

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