functions

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.

Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.

Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.

Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.

Package functions implements core logic for active monitoring, load balancing, and auto-scaling of back-end services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AMLB

func AMLB()

Active Monitoring Load Balancer (AMLB) periodically monitors the containers and decides whether to scale up or down based on CPU and memory usage. It enforces the minimum and maximum replica counts and performs a single scaling action at a time. The check is done every ScaleInterval (default is 15s).

func AutoScaler

func AutoScaler()

AutoScaler periodically checks the request volume and adjusts the number of replicas according to the configured thresholds. If the request count is greater than the scale up threshold and there are less than the maximum number of replicas, it starts a new replica. If the request count is less than the scale down threshold and there are more than the minimum number of replicas, it removes one replica. The check is done every ScaleInterval (default is 15s).

func CallContainers

func CallContainers()

CallContainers loads the containers of the returned project by loadComposeFile. it creates one set of db, and n sets of the api.

func CloseReplicas

func CloseReplicas(containerID string) (string, error)

CloseReplicas closes the replica with the given id, it first stop the container and then shut it down

func CreateReplicas

func CreateReplicas(imageName string, containerPort string, networkName string) (*structers.Backend, error)

CreateReplicas spins up one new container instance of your API, listening on the given hostPort, and returns a Backend pointing to it.

func GetInfoAboutReplica

func GetInfoAboutReplica(containerID string) (*structers.ReplicaStats, error)

gets the cpu and memory of a given container id

func NextAPISuffix

func NextAPISuffix(cli *client.Client, ctx context.Context, serviceName, parentName string) (int, error)

NextAPISuffix it extract the name of the container, and gets the number of the last created one. Note: it needs the container to follow this formate <parentName>-<N> (Docker compose/ microservice)

func ProxyHandler

func ProxyHandler() http.HandlerFunc

ProxyHandler it handles the traffic and direct it to the selected backend from pickBackendAndIncrement and passes the request to it

func ScaleDown

func ScaleDown()

ScaleDown tears down the newest container—never going below MinReplicas.

func ScaleUp

func ScaleUp()

ScaleUp launches one more container and registers it.

func StartHealthChecker

func StartHealthChecker()

Types

This section is empty.

Jump to

Keyboard shortcuts

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