gateway

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	// ListFlavoursPath is the path to get the list of flavours.
	ListFlavoursPath = "/api/listflavours"
	// ListFlavourByIDPath is the path to get a flavour by ID.
	ListFlavourByIDPath = "/api/listflavours/"
	// ReserveFlavourPath is the path to reserve a flavour.
	ReserveFlavourPath = "/api/reserveflavour/"
	// PurchaseFlavourPath is the path to purchase a flavour.
	PurchaseFlavourPath = "/api/purchaseflavour/"
	// ListFlavoursBySelectorPath is the path to get the list of flavours by selector.
	ListFlavoursBySelectorPath = "/api/listflavours/selector"
)

Variables

This section is empty.

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) DiscoverFlavours

func (g *Gateway) DiscoverFlavours(ctx context.Context, selector *nodecorev1alpha1.FlavourSelector) ([]*nodecorev1alpha1.Flavour, error)

DiscoverFlavours is a function that returns an array of Flavour 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) PurchaseFlavour

func (g *Gateway) PurchaseFlavour(ctx context.Context, transactionID string, seller nodecorev1alpha1.NodeIdentity) (*models.ResponsePurchase, error)

PurchaseFlavour purchases a flavour with the given flavourID.

func (*Gateway) RegisterNodeIdentity

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

RegisterNodeIdentity registers the FLUIDOS Node identity into the Gateway.

func (*Gateway) ReserveFlavour

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

ReserveFlavour reserves a flavour with the given flavourID.

func (*Gateway) SearchTransaction

func (g *Gateway) SearchTransaction(buyerID, flavourID 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