wirecontroller

package
v0.0.0-...-984f6f0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// errors
	NotFound = "not found"
)

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, cfg *Config) (wirer.Wirer, error)

Types

type CallbackCtx

type CallbackCtx struct {
	Message  string
	Hold     bool
	Evaluate EvaluateName
}

type Config

type Config struct {
	//Client      client.Client
	VXLANClient vxlanclient.Client
	// used only for intercluster controller but dont do any harm
	ClusterCache wirer.Cache[wirecluster.Cluster]
	ServiceCache wirer.Cache[wireservice.Service]
	// used for both intercluster and incluster controller
	TopologyCache wirer.Cache[wiretopology.Topology]
	DaemonCache   wirer.Cache[wiredaemon.Daemon]
	PodCache      wirer.Cache[wirepod.Pod]
	NodeCache     wirer.Cache[wirenode.Node]
}

type DesiredAction

type DesiredAction string
const (
	DesiredActionCreate DesiredAction = "create"
	DesiredActionDelete DesiredAction = "delete"
)

type Dispatcher

type Dispatcher interface {
	Write(workerNsn types.NamespacedName, e state.WorkerEvent) error
}

func NewDispatcher

func NewDispatcher(wc wirer.Cache[Worker]) Dispatcher

type EpResp

type EpResp struct {
	*endpointpb.EndpointResponse
}

func (*EpResp) UpdateStatus

func (r *EpResp) UpdateStatus(newState state.State, eventCtx *state.EventCtx)

type EvaluateName

type EvaluateName string
const (
	EvaluateClusterName  EvaluateName = "clusterName"
	EvaluateHostNodeName EvaluateName = "hostNodeName"
	EvaluateNodeName     EvaluateName = "nodeName"
)

type NodeEndpoint

type NodeEndpoint struct {
	wirer.Object
	NodeEpReq  *NodeEpReq
	NodeEpResp *EpResp
	State      state.State
	// contains filtered or unexported fields
}

Endoint provides the

func NewNodeEndpoint

func NewNodeEndpoint(ctx context.Context, d Dispatcher, req *NodeEpReq) *NodeEndpoint

func (*NodeEndpoint) GetAdditionalState

func (r *NodeEndpoint) GetAdditionalState(eventCtx *state.EventCtx) []state.StateCtx

GetAdditionalState returns no additional state, since there is only 1 endpoint

func (*NodeEndpoint) GetResponse

func (r *NodeEndpoint) GetResponse() *endpointpb.EndpointResponse

func (*NodeEndpoint) HandleEvent

func (r *NodeEndpoint) HandleEvent(ctx context.Context, event state.Event, eventCtx *state.EventCtx)

func (*NodeEndpoint) Transition

func (r *NodeEndpoint) Transition(ctx context.Context, newState state.State, eventCtx *state.EventCtx, generatedEvents ...state.WorkerAction)

type NodeEpReq

type NodeEpReq struct {
	*endpointpb.EndpointRequest
}

func (*NodeEpReq) CompareName

func (r *NodeEpReq) CompareName(evaluate EvaluateName, name string) bool

func (*NodeEpReq) GetHostNodeName

func (r *NodeEpReq) GetHostNodeName() string

func (*NodeEpReq) GetNSN

func (r *NodeEpReq) GetNSN() types.NamespacedName

func (*NodeEpReq) IsResolved

func (r *NodeEpReq) IsResolved() bool

func (*NodeEpReq) Resolve

func (r *NodeEpReq) Resolve(res *resolve.Data)

func (*NodeEpReq) Unresolve

func (r *NodeEpReq) Unresolve()

type Wire

type Wire struct {
	DesiredAction  DesiredAction
	WireReq        *WireReq
	WireResp       *WireResp
	EndpointsState []state.State
	// contains filtered or unexported fields
}

func NewWire

func NewWire(ctx context.Context, d Dispatcher, wreq *WireReq, vpnID uint32) *Wire

NewWire is like create link/wire, once the object exists, this is no longer required

func (*Wire) GetAdditionalState

func (r *Wire) GetAdditionalState(eventCtx *state.EventCtx) []state.StateCtx

GetAdditionalState returns the other endpoint state on the wire + its associated event context to handle further events on the adjacent endpoint

func (*Wire) GetWireResponse

func (r *Wire) GetWireResponse() *wirepb.WireResponse

func (*Wire) HandleEvent

func (r *Wire) HandleEvent(ctx context.Context, event state.Event, eventCtx *state.EventCtx)

func (*Wire) SetDesiredAction

func (r *Wire) SetDesiredAction(a DesiredAction)

func (*Wire) Transition

func (r *Wire) Transition(ctx context.Context, newState state.State, eventCtx *state.EventCtx, generatedEvents ...state.WorkerAction)

type WireCache

type WireCache interface {
	Get(types.NamespacedName) (*Wire, error)
	Upsert(context.Context, types.NamespacedName, *Wire)
	Delete(context.Context, types.NamespacedName)
	List() map[types.NamespacedName]*Wire
	SetDesiredAction(types.NamespacedName, DesiredAction)
	Resolve(ctx context.Context, nsn types.NamespacedName, resolvedData []*resolve.Data)
	UnResolve(ctx context.Context, nsn types.NamespacedName, epIdx int)
	HandleEvent(context.Context, types.NamespacedName, state.Event, *state.EventCtx) error
}

func NewWireCache

func NewWireCache(ctx context.Context, c wirer.Cache[*Wire], vxlanclient vxlanclient.Client) WireCache

type WireReq

type WireReq struct {
	*wirepb.WireRequest
}

func (*WireReq) Act

func (r *WireReq) Act(epIdx int) bool

func (*WireReq) AddVPN

func (r *WireReq) AddVPN(vpnID uint32)

func (*WireReq) CompareName

func (r *WireReq) CompareName(epIdx int, evaluate EvaluateName, name string) bool

TODO add the fn for the service lookup

func (*WireReq) GetClusterName

func (r *WireReq) GetClusterName(epIdx int) string

func (*WireReq) GetEndpoint

func (r *WireReq) GetEndpoint(epIdx int) *wirepb.Endpoint

func (*WireReq) GetEndpointNodeNSN

func (r *WireReq) GetEndpointNodeNSN(epIdx int) types.NamespacedName

func (*WireReq) GetHostNodeName

func (r *WireReq) GetHostNodeName(epIdx int) string

func (*WireReq) GetNSN

func (r *WireReq) GetNSN() types.NamespacedName

func (*WireReq) IsResolved

func (r *WireReq) IsResolved(epIdx int) bool

func (*WireReq) Resolve

func (r *WireReq) Resolve(resolvedData []*resolve.Data)

func (*WireReq) Unresolve

func (r *WireReq) Unresolve(epIdx int)

type WireResp

type WireResp struct {
	*wirepb.WireResponse
}

func (*WireResp) UpdateStatus

func (r *WireResp) UpdateStatus(newState state.State, eventCtx *state.EventCtx)

type Worker

type Worker interface {
	Start(ctx context.Context) error
	Stop()
	Write(e state.WorkerEvent)
	GetConfig() *client.Config
}

func NewWorker

func NewWorker(ctx context.Context, wireCache WireCache, epCache NodeEpCache, cfg *client.Config) (Worker, error)

Jump to

Keyboard shortcuts

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