types

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FarmCollection db collection name
	FarmCollection = "farm"
)
View Source
const (
	// GatewayCollection db collection name
	GatewayCollection = "gateway"
)
View Source
const (
	// NodeCollection db collection name
	NodeCollection = "node"
)

Variables

This section is empty.

Functions

func FarmCreate

func FarmCreate(ctx context.Context, db *mongo.Database, farm Farm) (schema.ID, error)

FarmCreate creates a new farm

func FarmUpdate

func FarmUpdate(ctx context.Context, db *mongo.Database, id schema.ID, farm Farm) error

FarmUpdate update an existing farm

func FarmsForNodes

func FarmsForNodes(ctx context.Context, db *mongo.Database, nodeID ...string) (farms []directory.Farm, err error)

FarmsForNodes return farm objects given node ids

func GatewayCreate

func GatewayCreate(ctx context.Context, db *mongo.Database, gw Gateway) (schema.ID, error)

GatewayCreate creates a new gateway

func GatewayUpdateReservedResources

func GatewayUpdateReservedResources(ctx context.Context, db *mongo.Database, nodeID string, capacity generated.ResourceAmount) error

GatewayUpdateReservedResources sets the node reserved resources

func GatewayUpdateUptime

func GatewayUpdateUptime(ctx context.Context, db *mongo.Database, nodeID string, uptime int64) error

GatewayUpdateUptime updates node uptime

func GatewayUpdateWorkloadsAmount

func GatewayUpdateWorkloadsAmount(ctx context.Context, db *mongo.Database, nodeID string, workloads generated.WorkloadAmount) error

GatewayUpdateWorkloadsAmount sets the node reserved resources

func NodeCreate

func NodeCreate(ctx context.Context, db *mongo.Database, node Node) (schema.ID, error)

NodeCreate creates a new farm

func NodeDelete

func NodeDelete(ctx context.Context, db *mongo.Database, nodeID string) error

NodeDelete marks a node as deleted in the database. The database entry is kept, and the node can still be looked up.

func NodePushProof

func NodePushProof(ctx context.Context, db *mongo.Database, nodeID string, proof generated.Proof) error

NodePushProof push proof to node

func NodeSetInterfaces

func NodeSetInterfaces(ctx context.Context, db *mongo.Database, nodeID string, ifaces []generated.Iface) error

NodeSetInterfaces updates node interfaces

func NodeSetPublicConfig

func NodeSetPublicConfig(ctx context.Context, db *mongo.Database, nodeID string, cfg generated.PublicIface) error

NodeSetPublicConfig sets node public config

func NodeSetWGPorts

func NodeSetWGPorts(ctx context.Context, db *mongo.Database, nodeID string, ports []uint) error

NodeSetWGPorts update wireguard ports

func NodeUpdateFreeToUse

func NodeUpdateFreeToUse(ctx context.Context, db *mongo.Database, nodeID string, freeToUse bool) error

NodeUpdateFreeToUse sets node free to use flag

func NodeUpdateReservedResources

func NodeUpdateReservedResources(ctx context.Context, db *mongo.Database, nodeID string, capacity generated.ResourceAmount) error

NodeUpdateReservedResources sets the node reserved resources

func NodeUpdateTotalResources

func NodeUpdateTotalResources(ctx context.Context, db *mongo.Database, nodeID string, capacity generated.ResourceAmount) error

NodeUpdateTotalResources sets the node total resources

func NodeUpdateUptime

func NodeUpdateUptime(ctx context.Context, db *mongo.Database, nodeID string, uptime int64) error

NodeUpdateUptime updates node uptime

func NodeUpdateUsedResources

func NodeUpdateUsedResources(ctx context.Context, db *mongo.Database, nodeID string, capacity generated.ResourceAmount) error

NodeUpdateUsedResources sets the node total resources

func NodeUpdateWorkloadsAmount

func NodeUpdateWorkloadsAmount(ctx context.Context, db *mongo.Database, nodeID string, workloads generated.WorkloadAmount) error

NodeUpdateWorkloadsAmount sets the node reserved resources

func Setup

func Setup(ctx context.Context, db *mongo.Database) error

Setup sets up indexes for types, must be called at least Onetime during the life time of the object

Types

type Farm

type Farm generated.Farm

Farm mongo db wrapper for generated TfgridDirectoryFarm

func (*Farm) Validate

func (f *Farm) Validate() error

Validate validates farm object

type FarmFilter

type FarmFilter bson.D

FarmFilter type

func (FarmFilter) Count

func (f FarmFilter) Count(ctx context.Context, db *mongo.Database) (int64, error)

Count number of documents matching

func (FarmFilter) Delete

func (f FarmFilter) Delete(ctx context.Context, db *mongo.Database) (err error)

Delete deletes one farm that match the filter

func (FarmFilter) Find

func (f FarmFilter) Find(ctx context.Context, db *mongo.Database, opts ...*options.FindOptions) (*mongo.Cursor, error)

Find run the filter and return a cursor result

func (FarmFilter) Get

func (f FarmFilter) Get(ctx context.Context, db *mongo.Database) (farm Farm, err error)

Get one farm that matches the filter

func (FarmFilter) WithFarmQuery

func (f FarmFilter) WithFarmQuery(q FarmQuery) FarmFilter

WithFarmQuery filter based on FarmQuery

func (FarmFilter) WithID

func (f FarmFilter) WithID(id schema.ID) FarmFilter

WithID filter farm with ID

func (FarmFilter) WithName

func (f FarmFilter) WithName(name string) FarmFilter

WithName filter farm with name

func (FarmFilter) WithOwner

func (f FarmFilter) WithOwner(tid int64) FarmFilter

WithOwner filter farm by owner ID

type FarmQuery

type FarmQuery struct {
	FarmName string
	OwnerID  int64
}

FarmQuery helper to parse query string

func (*FarmQuery) Parse

func (f *FarmQuery) Parse(r *http.Request) mw.Response

Parse querystring from request

type Gateway

type Gateway generated.Gateway

Gateway model

func (*Gateway) Validate

func (n *Gateway) Validate() error

Validate node

type GatewayFilter

type GatewayFilter bson.D

GatewayFilter type

func (GatewayFilter) Count

func (f GatewayFilter) Count(ctx context.Context, db *mongo.Database) (int64, error)

Count number of documents matching

func (GatewayFilter) Delete

func (f GatewayFilter) Delete(ctx context.Context, db *mongo.Database) error

Delete deletes a node by ID

func (GatewayFilter) Find

Find run the filter and return a cursor result

func (GatewayFilter) Get

func (f GatewayFilter) Get(ctx context.Context, db *mongo.Database) (gateway Gateway, err error)

Get one farm that matches the filter

func (GatewayFilter) WithFarmID

func (f GatewayFilter) WithFarmID(id int) GatewayFilter

WithFarmID search gateways with this node id

func (GatewayFilter) WithFreeToUse

func (f GatewayFilter) WithFreeToUse(freeToUse bool) GatewayFilter

WithFreeToUse search the nodes that free_to_use value is equal to freeToUse

func (GatewayFilter) WithGWID

func (f GatewayFilter) WithGWID(id string) GatewayFilter

WithGWID search gateways with this gateway id

func (GatewayFilter) WithGWIDs

func (f GatewayFilter) WithGWIDs(ids []string) GatewayFilter

WithGWIDs list gateways which ndoe_id is in ids slice

func (GatewayFilter) WithID

func (f GatewayFilter) WithID(id schema.ID) GatewayFilter

WithID filter gateway with ID

func (GatewayFilter) WithLocation

func (f GatewayFilter) WithLocation(country, city string) GatewayFilter

WithLocation search the nodes that are located in country and or city

type Node

type Node generated.Node

Node model

func (*Node) Validate

func (n *Node) Validate() error

Validate node

type NodeFilter

type NodeFilter bson.D

NodeFilter type

func (NodeFilter) Count

func (f NodeFilter) Count(ctx context.Context, db *mongo.Database) (int64, error)

Count number of documents matching

func (NodeFilter) Delete

func (f NodeFilter) Delete(ctx context.Context, db *mongo.Database) error

Delete deletes a node by ID

func (NodeFilter) ExcludeDeleted

func (f NodeFilter) ExcludeDeleted() NodeFilter

ExcludeDeleted search the nodes that are not marked as deleted

func (NodeFilter) Find

func (f NodeFilter) Find(ctx context.Context, db *mongo.Database, opts ...*options.FindOptions) (*mongo.Cursor, error)

Find run the filter and return a cursor result

func (NodeFilter) Get

func (f NodeFilter) Get(ctx context.Context, db *mongo.Database, includeproofs bool) (node Node, err error)

Get one farm that matches the filter

func (NodeFilter) WithFarmID

func (f NodeFilter) WithFarmID(id schema.ID) NodeFilter

WithFarmID search nodes with given farmID

func (NodeFilter) WithFreeToUse

func (f NodeFilter) WithFreeToUse(freeToUse bool) NodeFilter

WithFreeToUse search the nodes that free_to_use value is equal to freeToUse

func (NodeFilter) WithID

func (f NodeFilter) WithID(id schema.ID) NodeFilter

WithID filter node with ID

func (NodeFilter) WithLocation

func (f NodeFilter) WithLocation(country, city string) NodeFilter

WithLocation search the nodes that are located in country and or city

func (NodeFilter) WithNodeID

func (f NodeFilter) WithNodeID(id string) NodeFilter

WithNodeID search nodes with this node id

func (NodeFilter) WithNodeIDs

func (f NodeFilter) WithNodeIDs(ids []string) NodeFilter

WithNodeIDs list gateways which node_id is in ids slice

func (NodeFilter) WithTotalCap

func (f NodeFilter) WithTotalCap(cru, mru, hru, sru int64) NodeFilter

WithTotalCap filter with total cap only units that > 0 are used in the query

Jump to

Keyboard shortcuts

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