network

package
v0.16.91 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 36 Imported by: 7

Documentation

Index

Constants

View Source
const SmartRerouteAttempt = 99969996

Variables

View Source
var CircuitEventHandlerRegistry = cowslice.NewCowSlice(make([]CircuitEventHandler, 0))
View Source
var DbSnapshotTooFrequentError = dbSnapshotTooFrequentError{}

Functions

This section is empty.

Types

type Cache

type Cache interface {
	RemoveFromCache(id string)
}

type Circuit

type Circuit struct {
	Id         string
	ClientId   string
	Service    *Service
	Terminator xt.Terminator
	Path       *Path
	Rerouting  concurrenz.AtomicBoolean
	PeerData   xt.PeerData
}

type CircuitEventHandler added in v0.16.92

type CircuitEventHandler interface {
	CircuitCreated(circuitId string, clientId string, serviceId string, path *Path)
	CircuitDeleted(circuitId string, clientId string)
	PathUpdated(circuitId string, path *Path)
}

type Controller

type Controller interface {
	models.EntityRetriever
	// contains filtered or unexported methods
}

type Controllers

type Controllers struct {
	Terminators *TerminatorController
	Routers     *RouterController
	Services    *ServiceController
	// contains filtered or unexported fields
}

func NewControllers

func NewControllers(db boltz.Db, stores *db.Stores) *Controllers

type ForwardingFaultReport added in v0.15.24

type ForwardingFaultReport struct {
	R          *Router
	CircuitIds []string
}

type InvalidCircuitError added in v0.16.92

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

func (InvalidCircuitError) Error added in v0.16.92

func (err InvalidCircuitError) Error() string
type Link struct {
	Id  *identity.TokenId
	Src *Router
	Dst *Router

	Down       bool
	StaticCost int32
	SrcLatency int64
	DstLatency int64
	Cost       int64
	// contains filtered or unexported fields
}

func (*Link) CurrentState

func (link *Link) CurrentState() *LinkState

func (*Link) GetCost added in v0.13.0

func (link *Link) GetCost() int64

func (*Link) GetDstLatency added in v0.13.0

func (link *Link) GetDstLatency() int64

func (*Link) GetSrcLatency added in v0.13.0

func (link *Link) GetSrcLatency() int64

func (*Link) GetStaticCost added in v0.13.0

func (link *Link) GetStaticCost() int32

func (*Link) SetDstLatency added in v0.13.0

func (link *Link) SetDstLatency(latency int64)

func (*Link) SetSrcLatency added in v0.13.0

func (link *Link) SetSrcLatency(latency int64)

func (*Link) SetStaticCost added in v0.13.0

func (link *Link) SetStaticCost(cost int32)

type LinkMode

type LinkMode byte
const (
	Pending LinkMode = iota
	Connected
	Failed
)

func (LinkMode) String

func (t LinkMode) String() string

type LinkState

type LinkState struct {
	Mode      LinkMode
	Timestamp int64
}

type MultipleErrors

type MultipleErrors []error

func (MultipleErrors) Error

func (e MultipleErrors) Error() string

type Network

type Network struct {
	*Controllers

	VersionProvider common.VersionProvider
	// contains filtered or unexported fields
}

func NewNetwork

func NewNetwork(nodeId *identity.TokenId, options *Options, database boltz.Db, metricsCfg *metrics.Config, versionProvider common.VersionProvider, closeNotify <-chan struct{}) (*Network, error)

func (*Network) AcceptMetrics

func (network *Network) AcceptMetrics(metrics *metrics_pb.MetricsMessage)

func (*Network) AddCapability

func (network *Network) AddCapability(capability string)

func (*Network) AddRouterPresenceHandler

func (network *Network) AddRouterPresenceHandler(h RouterPresenceHandler)

func (*Network) AllConnectedRouters

func (network *Network) AllConnectedRouters() []*Router

func (*Network) CircuitCreated added in v0.16.92

func (network *Network) CircuitCreated(circuitId string, clientId string, serviceId string, path *Path)

func (*Network) CircuitDeleted added in v0.16.92

func (network *Network) CircuitDeleted(circuitId string, clientId string)

func (*Network) ConnectRouter

func (network *Network) ConnectRouter(r *Router)

func (*Network) ConnectedRouter

func (network *Network) ConnectedRouter(id string) bool

func (*Network) CreateCircuit

func (network *Network) CreateCircuit(srcR *Router, clientId *identity.TokenId, service string, ctx logcontext.Context) (*Circuit, error)

func (*Network) CreatePath added in v0.16.92

func (network *Network) CreatePath(srcR, dstR *Router) (*Path, error)

func (*Network) CreatePathWithNodes added in v0.16.92

func (network *Network) CreatePathWithNodes(nodes []*Router) (*Path, error)

func (*Network) CreateRouter

func (network *Network) CreateRouter(router *Router) error

func (*Network) DisconnectRouter

func (network *Network) DisconnectRouter(r *Router)

func (*Network) GetAllCircuits added in v0.16.92

func (network *Network) GetAllCircuits() []*Circuit
func (network *Network) GetAllLinks() []*Link

func (*Network) GetAllLinksForRouter

func (network *Network) GetAllLinksForRouter(routerId string) []*Link

func (*Network) GetAppId

func (network *Network) GetAppId() *identity.TokenId

func (*Network) GetCapabilities

func (network *Network) GetCapabilities() []string

func (*Network) GetCircuit added in v0.16.92

func (network *Network) GetCircuit(circuitId string) (*Circuit, bool)

func (*Network) GetConnectedRouter

func (network *Network) GetConnectedRouter(routerId string) *Router

func (*Network) GetControllers

func (network *Network) GetControllers() *Controllers

func (*Network) GetDb

func (network *Network) GetDb() boltz.Db

func (*Network) GetEventDispatcher added in v0.12.1

func (network *Network) GetEventDispatcher() event.Dispatcher
func (network *Network) GetLink(linkId *identity.TokenId) (*Link, bool)

func (*Network) GetMetricsRegistry added in v0.12.3

func (network *Network) GetMetricsRegistry() metrics.Registry

func (*Network) GetOptions added in v0.15.18

func (network *Network) GetOptions() *Options

func (*Network) GetRouter

func (network *Network) GetRouter(routerId string) (*Router, error)

func (*Network) GetServiceCache

func (network *Network) GetServiceCache() Cache

func (*Network) GetServiceEventsMetricsRegistry added in v0.16.41

func (network *Network) GetServiceEventsMetricsRegistry() metrics.UsageRegistry

func (*Network) GetStores

func (network *Network) GetStores() *db.Stores

func (*Network) GetTraceController

func (network *Network) GetTraceController() trace.Controller

func (*Network) InitServiceCounterDispatch added in v0.16.23

func (network *Network) InitServiceCounterDispatch(handler metrics.Handler)

func (*Network) LinkChanged

func (network *Network) LinkChanged(l *Link)

func (*Network) LinkConnected

func (network *Network) LinkConnected(id *identity.TokenId, connected bool) error

func (*Network) NotifyRouterRenamed added in v0.16.50

func (network *Network) NotifyRouterRenamed(id, name string)

func (*Network) PathUpdated added in v0.16.92

func (network *Network) PathUpdated(circuitId string, path *Path)

func (*Network) RemoveCircuit added in v0.16.92

func (network *Network) RemoveCircuit(circuitId string, now bool) error

func (*Network) ReportForwardingFaults added in v0.15.24

func (network *Network) ReportForwardingFaults(ffr *ForwardingFaultReport)

func (*Network) RouteResult added in v0.16.0

func (network *Network) RouteResult(r *Router, circuitId string, attempt uint32, success bool, rerr string, peerData xt.PeerData) bool

func (*Network) RouterChanged

func (network *Network) RouterChanged(r *Router)

func (*Network) Run

func (network *Network) Run()

func (*Network) ServiceDialFail added in v0.16.23

func (network *Network) ServiceDialFail(serviceId string)

func (*Network) ServiceDialOtherError added in v0.16.23

func (network *Network) ServiceDialOtherError(serviceId string)

func (*Network) ServiceDialSuccess added in v0.16.23

func (network *Network) ServiceDialSuccess(serviceId string)

func (*Network) ServiceDialTimeout added in v0.16.23

func (network *Network) ServiceDialTimeout(serviceId string)

func (*Network) SnapshotDatabase added in v0.11.40

func (network *Network) SnapshotDatabase() error

func (*Network) UpdatePath added in v0.16.92

func (network *Network) UpdatePath(path *Path) (*Path, error)

func (*Network) ValidateTerminators

func (network *Network) ValidateTerminators(r *Router)

type Options

type Options struct {
	CycleSeconds uint32
	Smart        struct {
		RerouteFraction float32
		RerouteCap      uint32
	}
	RouteTimeout            time.Duration
	CreateCircuitRetries    uint32
	CtrlChanLatencyInterval time.Duration
	PendingLinkTimeout      time.Duration
}

func DefaultOptions

func DefaultOptions() *Options

func LoadOptions

func LoadOptions(src map[interface{}]interface{}) (*Options, error)

type Path added in v0.16.92

type Path struct {
	Nodes     []*Router
	Links     []*Link
	IngressId string
	EgressId  string
}

func (*Path) CreateRouteMessages added in v0.16.92

func (self *Path) CreateRouteMessages(attempt uint32, circuitId string, terminator xt.Terminator) ([]*ctrl_pb.Route, error)

func (*Path) EgressRouter added in v0.16.92

func (self *Path) EgressRouter() *Router

func (*Path) EqualPath added in v0.16.92

func (self *Path) EqualPath(other *Path) bool

func (*Path) String added in v0.16.92

func (self *Path) String() string

type PathAndCost

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

type Router

type Router struct {
	models.BaseEntity
	Name               string
	Fingerprint        *string
	AdvertisedListener string
	Control            channel2.Channel
	Connected          concurrenz.AtomicBoolean
	VersionInfo        *common.VersionInfo
}

func NewRouter

func NewRouter(id, name, fingerprint string) *Router

type RouterController

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

func (*RouterController) BaseList

func (ctrl *RouterController) BaseList(query string) (*models.EntityListResult, error)

func (*RouterController) BaseLoad

func (ctrl *RouterController) BaseLoad(id string) (models.Entity, error)

func (*RouterController) BaseLoadInTx

func (ctrl *RouterController) BaseLoadInTx(tx *bbolt.Tx, id string) (models.Entity, error)

func (*RouterController) BasePreparedList

func (ctrl *RouterController) BasePreparedList(query ast.Query) (*models.EntityListResult, error)

func (*RouterController) BasePreparedListAssociated

func (ctrl *RouterController) BasePreparedListAssociated(id string, typeLoader models.EntityRetriever, query ast.Query) (*models.EntityListResult, error)

func (*RouterController) Create

func (ctrl *RouterController) Create(router *Router) error

func (*RouterController) Delete

func (ctrl *RouterController) Delete(id string) error

func (*RouterController) IsConnected

func (ctrl *RouterController) IsConnected(id string) bool

func (*RouterController) Read

func (ctrl *RouterController) Read(id string) (entity *Router, err error)

func (*RouterController) UpdateCachedFingerprint added in v0.16.51

func (ctrl *RouterController) UpdateCachedFingerprint(id, fingerprint string)

type RouterPresenceHandler

type RouterPresenceHandler interface {
	RouterConnected(r *Router)
	RouterDisconnected(r *Router)
}

type RoutingTerminator

type RoutingTerminator struct {
	RouteCost uint32
	*Terminator
}

func (*RoutingTerminator) GetRouteCost

func (r *RoutingTerminator) GetRouteCost() uint32

type Service

type Service struct {
	models.BaseEntity
	Name               string
	TerminatorStrategy string
	Terminators        []*Terminator
}

type ServiceController

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

func (*ServiceController) BaseList

func (ctrl *ServiceController) BaseList(query string) (*models.EntityListResult, error)

func (*ServiceController) BaseLoad

func (ctrl *ServiceController) BaseLoad(id string) (models.Entity, error)

func (*ServiceController) BaseLoadInTx

func (ctrl *ServiceController) BaseLoadInTx(tx *bbolt.Tx, id string) (models.Entity, error)

func (*ServiceController) BasePreparedList

func (ctrl *ServiceController) BasePreparedList(query ast.Query) (*models.EntityListResult, error)

func (*ServiceController) BasePreparedListAssociated

func (ctrl *ServiceController) BasePreparedListAssociated(id string, typeLoader models.EntityRetriever, query ast.Query) (*models.EntityListResult, error)

func (*ServiceController) Create

func (ctrl *ServiceController) Create(s *Service) error

func (*ServiceController) Delete

func (ctrl *ServiceController) Delete(id string) error

func (*ServiceController) NotifyTerminatorChanged added in v0.15.6

func (ctrl *ServiceController) NotifyTerminatorChanged(terminator *db.Terminator) *db.Terminator

func (*ServiceController) Read

func (ctrl *ServiceController) Read(id string) (entity *Service, err error)

func (*ServiceController) RemoveFromCache

func (ctrl *ServiceController) RemoveFromCache(id string)

func (*ServiceController) Update

func (ctrl *ServiceController) Update(s *Service) error

type ServiceCounters added in v0.16.23

type ServiceCounters interface {
	ServiceDialSuccess(serviceId string)
	ServiceDialFail(serviceId string)
	ServiceDialTimeout(serviceId string)
	ServiceDialOtherError(serviceId string)
}

type Terminator

type Terminator struct {
	models.BaseEntity
	Service        string
	Router         string
	Binding        string
	Address        string
	Identity       string
	IdentitySecret []byte
	Cost           uint16
	Precedence     xt.Precedence
	PeerData       map[uint32][]byte
}

func (*Terminator) GetAddress

func (entity *Terminator) GetAddress() string

func (*Terminator) GetBinding

func (entity *Terminator) GetBinding() string

func (*Terminator) GetCost

func (entity *Terminator) GetCost() uint16

func (*Terminator) GetIdentity added in v0.14.0

func (entity *Terminator) GetIdentity() string

func (*Terminator) GetIdentitySecret added in v0.14.0

func (entity *Terminator) GetIdentitySecret() []byte

func (*Terminator) GetPeerData

func (entity *Terminator) GetPeerData() xt.PeerData

func (*Terminator) GetPrecedence added in v0.13.0

func (entity *Terminator) GetPrecedence() xt.Precedence

func (*Terminator) GetRouterId

func (entity *Terminator) GetRouterId() string

func (*Terminator) GetServiceId

func (entity *Terminator) GetServiceId() string

type TerminatorController

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

func (*TerminatorController) BaseList

func (ctrl *TerminatorController) BaseList(query string) (*models.EntityListResult, error)

func (*TerminatorController) BaseLoad

func (ctrl *TerminatorController) BaseLoad(id string) (models.Entity, error)

func (*TerminatorController) BaseLoadInTx

func (ctrl *TerminatorController) BaseLoadInTx(tx *bbolt.Tx, id string) (models.Entity, error)

func (*TerminatorController) BasePreparedList

func (ctrl *TerminatorController) BasePreparedList(query ast.Query) (*models.EntityListResult, error)

func (*TerminatorController) BasePreparedListAssociated

func (ctrl *TerminatorController) BasePreparedListAssociated(id string, typeLoader models.EntityRetriever, query ast.Query) (*models.EntityListResult, error)

func (*TerminatorController) Create

func (ctrl *TerminatorController) Create(s *Terminator) (string, error)

func (*TerminatorController) CreateInTx added in v0.16.58

func (ctrl *TerminatorController) CreateInTx(ctx boltz.MutateContext, terminator *Terminator) (string, error)

func (*TerminatorController) Delete

func (ctrl *TerminatorController) Delete(id string) error

func (*TerminatorController) Patch

func (ctrl *TerminatorController) Patch(terminator *Terminator, checker boltz.FieldChecker) error

func (*TerminatorController) Query

func (ctrl *TerminatorController) Query(query string) (*TerminatorListResult, error)

func (*TerminatorController) Read

func (ctrl *TerminatorController) Read(id string) (entity *Terminator, err error)

func (*TerminatorController) Update

func (ctrl *TerminatorController) Update(terminator *Terminator) error

type TerminatorListResult

type TerminatorListResult struct {
	Entities []*Terminator
	models.QueryMetaData
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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