concurrent

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package concurrent contains the logic to manage same gateway replicas. They are managed using an active/passive approach. The gateway container try to acquire the active role using the controller manager lease. Then, the active gateway is labeled with the ActiveGatewayKey and ActiveGatewayValue, and the passive gateways are unlabeled. The gateway service target the active gateway using the ActiveGatewayKey and ActiveGatewayValue labels. In order to cohordinate the sidecar containers, the gateway uses a unix socket to manage the IPC, and to start the sidecars when it becomes leader.

Index

Constants

View Source
const (
	// ActiveGatewayKey is the key used to label the active pod gateway.
	ActiveGatewayKey = "networking.liqo.io/active"
	// ActiveGatewayValue is the value used to label the active pod gateway.
	ActiveGatewayValue = "true"
)

Variables

This section is empty.

Functions

func AddActiveGatewayLabel

func AddActiveGatewayLabel(ctx context.Context, cl client.Client, key client.ObjectKey) error

AddActiveGatewayLabel adds the active gateway label to the pod.

func ListAllGatewaysReplicas

func ListAllGatewaysReplicas(ctx context.Context, cl client.Client, namespace, gatewayName string) ([]corev1.Pod, error)

ListAllGatewaysReplicas returns the list of all the gateways replicas of the same gateway.

func RemoveActiveGatewayLabel

func RemoveActiveGatewayLabel(ctx context.Context, cl client.Client, key client.ObjectKey) error

RemoveActiveGatewayLabel removes the active gateway label from the pod.

Types

type RunnableGateway

type RunnableGateway struct {
	Client client.Client

	PodName     string
	GatewayName string
	Namespace   string

	Socket           net.Listener
	GuestConnections ipc.GuestConnections
}

RunnableGateway is a RunnableGateway that manages concurrency.

func NewRunnableGatewayStartup

func NewRunnableGatewayStartup(cl client.Client, podName, gatewayName, namespace string, containerNames []string) (*RunnableGateway, error)

NewRunnableGatewayStartup creates a new Runnable.

func (*RunnableGateway) Close

func (rg *RunnableGateway) Close()

Close closes the Runnable.

func (*RunnableGateway) Start

func (rg *RunnableGateway) Start(ctx context.Context) error

Start starts the ConcurrentRunnable.

type RunnableGuest

type RunnableGuest struct {
	GuestID    string
	Connection net.Conn
}

RunnableGuest is a RunnableGuest that manages concurrency.

func NewRunnableGuest

func NewRunnableGuest(guestID string) (*RunnableGuest, error)

NewRunnableGuest creates a new Runnable.

func (*RunnableGuest) Close

func (rg *RunnableGuest) Close()

Close closes the Runnable.

func (*RunnableGuest) Start

func (rg *RunnableGuest) Start(_ context.Context) error

Start starts the ConcurrentRunnable.

Jump to

Keyboard shortcuts

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