types

package
v0.2.2-rc7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FarmCollection db collection name
	FarmCollection = "farm"
)
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 NodeCreate

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

NodeCreate creates a new farm

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