gateway

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package gateway contains the HTTP Server and the utility functions for the REAR Gateway

Index

Constants

View Source
const (
	// ListFlavorsPath is the path to get the list of flavors.
	ListFlavorsPath = "/api/listflavors"
	// ListFlavorByIDPath is the path to get a flavor by ID.
	ListFlavorByIDPath = "/api/listflavors/"
	// ReserveFlavorPath is the path to reserve a flavor.
	ReserveFlavorPath = "/api/reserveflavor/"
	// PurchaseFlavorPath is the path to purchase a flavor.
	PurchaseFlavorPath = "/api/purchaseflavor/"
	// ListFlavorsBySelectorPath is the path to get the list of flavors by selector.
	ListFlavorsBySelectorPath = "/api/listflavors/selector"
)

Variables

View Source
var Routes = struct {
	// Flavors is the route to get all the flavors.
	Flavors string
	// K8SliceFlavors is the route to get all the K8Slice flavors.
	K8SliceFlavors string
	// VMFlavors is the route to get all the VM flavors.
	VMFlavors string
	// ServiceFlavors is the route to get all the service flavors.
	ServiceFlavors string
	// SensorsFlavors is the route to get all the sensors flavors.
	SensorsFlavors string
	// Reserve is the route to reserve a flavor.
	Reserve string
	// Purchase is the route to purchase a flavor.
	Purchase string
}{
	Flavors:        "/api/v2/flavors",
	K8SliceFlavors: "/api/v2/flavors/k8slice",
	VMFlavors:      "/api/v2/flavors/vm",
	ServiceFlavors: "/api/v2/flavors/service",
	SensorsFlavors: "/api/v2/flavors/sensors",
	Reserve:        "/api/v2/reservations",
	Purchase:       "/api/v2/transactions/{transactionID}/purchase",
}

Routes defines the routes for the rear controller.

Functions

This section is empty.

Types

type Gateway

type Gateway struct {
	// NodeIdentity is the identity of the FLUIDOS Node
	ID *nodecorev1alpha1.NodeIdentity

	// Transactions is a map of Transaction
	Transactions map[string]*models.Transaction

	// Readyness of the Gateway. It is set when liqo is installed
	LiqoReady bool

	// The Liqo ClusterID
	ClusterID string
	// contains filtered or unexported fields
}

Gateway is the object that contains all the logical data stractures of the REAR Gateway.

func NewGateway

func NewGateway(c client.Client) *Gateway

NewGateway creates a new Gateway object.

func (*Gateway) CacheRefresher

func (g *Gateway) CacheRefresher(interval time.Duration) func(ctx context.Context) error

CacheRefresher is a function that periodically checks the cache and removes expired transactions.

func (*Gateway) DiscoverFlavors added in v0.1.0

func (g *Gateway) DiscoverFlavors(ctx context.Context, selector *nodecorev1alpha1.Selector) ([]*nodecorev1alpha1.Flavor, error)

DiscoverFlavors is a function that returns an array of Flavor that fit the Selector by performing a get request to an http server.

func (*Gateway) GetTransaction

func (g *Gateway) GetTransaction(transactionID string) (models.Transaction, error)

GetTransaction returns a transaction from the transactions map.

func (*Gateway) LiqoChecker

func (g *Gateway) LiqoChecker(interval time.Duration) func(ctx context.Context) error

LiqoChecker is a function that periodically checks if Liqo is ready.

func (*Gateway) PurchaseFlavor added in v0.1.0

func (g *Gateway) PurchaseFlavor(ctx context.Context, transactionID string,
	seller nodecorev1alpha1.NodeIdentity, buyerLiqoCredentials *models.LiqoCredentials) (*models.Contract, error)

PurchaseFlavor purchases a flavor with the given flavorID.

func (*Gateway) RegisterNodeIdentity

func (g *Gateway) RegisterNodeIdentity(nodeIdentity *nodecorev1alpha1.NodeIdentity)

RegisterNodeIdentity registers the FLUIDOS Node identity into the Gateway.

func (*Gateway) ReserveFlavor added in v0.1.0

func (g *Gateway) ReserveFlavor(ctx context.Context, reservation *reservationv1alpha1.Reservation, flavorID string) (*models.Transaction, error)

ReserveFlavor reserves a flavor with the given flavorID.

func (*Gateway) SearchTransaction

func (g *Gateway) SearchTransaction(buyerID, flavorID string) (*models.Transaction, bool)

SearchTransaction returns a transaction from the transactions map.

func (*Gateway) Start

func (g *Gateway) Start(ctx context.Context) error

Start starts a new HTTP server.

Jump to

Keyboard shortcuts

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