mesh

package
v0.0.0-...-395d267 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeOk      = 1
	NodeTimeout = 2
	NodeDead    = 3
)

Variables

This section is empty.

Functions

func CreateCanaryMesh

func CreateCanaryMesh(routineConfig *RoutineConfiguration, setupConfig *SetupConfiguration)

CreateCanaryMesh creates a canary bot & mesh with the desired configuration Use a pre-defined routineConfig with e.g. StandardProductionRoutineConfig() and define your mesh setup configuration

- Logger will be initialized

- setupConfig will be checked

- DB will be created

- Mesh will be initialized

- Routines will be started

- API will be created

func GetId

func GetId(n *meshv1.Node) uint32

GetId returns the hashed ID of a node

func GetSampleId

func GetSampleId(p *meshv1.Sample) uint32

GetSampleId returns the ID of a sample

Types

type Mesh

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

Mesh is the internal mesh representation

func (*Mesh) Join

func (m *Mesh) Join(targets []string) (bool, bool)

Join tries to join the mesh by communicating with the targets.

func (*Mesh) NodeDiscovery

func (m *Mesh) NodeDiscovery(toNode *meshv1.Node, newNode *meshv1.Node)

func (*Mesh) Rtt

func (m *Mesh) Rtt()

func (*Mesh) StartServer

func (m *Mesh) StartServer() error

StartServer starts the mesh server, by setting up gRPC and TLS.

type MeshClient

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

MeshClient is the client for the mesh service

type MeshServer

type MeshServer struct {
	meshv1.UnimplementedMeshServiceServer
	// contains filtered or unexported fields
}

MeshServer handles incoming requests

func (*MeshServer) JoinMesh

func (s *MeshServer) JoinMesh(ctx context.Context, req *meshv1.Node) (*meshv1.JoinMeshResponse, error)

JoinMesh handles the join mesh request from a node wishing to join the mesh

func (*MeshServer) NodeDiscovery

func (s *MeshServer) NodeDiscovery(ctx context.Context, req *meshv1.NodeDiscoveryRequest) (*emptypb.Empty, error)

NodeDiscovery handles the node discovery request from a node in the mesh

func (*MeshServer) Ping

func (s *MeshServer) Ping(ctx context.Context, req *meshv1.Node) (*emptypb.Empty, error)

Ping handles the ping request from a node in the mesh

func (*MeshServer) PushSamples

func (s *MeshServer) PushSamples(ctx context.Context, req *meshv1.Samples) (*emptypb.Empty, error)

PushSamples adds samples to the database if they are newer than the current sample

func (*MeshServer) Rtt

func (s *MeshServer) Rtt(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error)

Rtt handles the round trip time request from a node in the mesh

type NodeDiscovered

type NodeDiscovered struct {
	NewNode *meshv1.Node
	From    uint32 // TODO change to name
}

NodeDiscovered represents a newly discovered node in the mesh

type RoutineConfiguration

type RoutineConfiguration struct {
	// Timeout for every grpc request
	RequestTimeout time.Duration

	// Join config
	JoinInterval time.Duration

	// Ping config
	PingInterval    time.Duration
	PingRetryAmount int
	PingRetryDelay  time.Duration

	// Node discovery
	BroadcastToAmount int

	// Push samples
	PushSampleInterval    time.Duration
	PushSampleToAmount    int
	PushSampleRetryAmount int
	PushSampleRetryDelay  time.Duration

	// Clean nodes & samples
	CleanupInterval time.Duration
	CleanupMaxAge   time.Duration

	// Sample: RTT
	RttInterval time.Duration
}

Configuration for the timer- and channelRoutines

func StandardProductionRoutineConfig

func StandardProductionRoutineConfig() *RoutineConfiguration

Use standard configuration parameters for your production

type SetupConfiguration

type SetupConfiguration struct {
	// remote target
	Targets []string

	// local config
	Name          string
	JoinAddress   string
	ListenAddress string
	ListenPort    int64

	// API
	ApiPort int64

	// TLS server side
	ServerCertPath string
	ServerKeyPath  string
	ServerCert     []byte
	ServerKey      []byte
	// TLS client side
	CaCertPath []string
	CaCert     []byte

	//Auth API
	Tokens []string

	// Clean nodes & samples
	CleanupNodes   bool
	CleanupSamples bool

	//Logging
	Debug     bool
	DebugGrpc bool
}

Configuration how the bot can connect to the mesh etc.

Jump to

Keyboard shortcuts

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