Documentation ¶
Index ¶
- Constants
- func FarmCreate(ctx context.Context, db *mongo.Database, farm Farm) (schema.ID, error)
- func FarmUpdate(ctx context.Context, db *mongo.Database, id schema.ID, farm Farm) error
- func FarmsForNodes(ctx context.Context, db *mongo.Database, nodeID ...string) (farms []directory.Farm, err error)
- func GatewayCreate(ctx context.Context, db *mongo.Database, gw Gateway) (schema.ID, error)
- func GatewayUpdateReservedResources(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func GatewayUpdateUptime(ctx context.Context, db *mongo.Database, nodeID string, uptime int64) error
- func GatewayUpdateWorkloadsAmount(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func NodeCreate(ctx context.Context, db *mongo.Database, node Node) (schema.ID, error)
- func NodeDelete(ctx context.Context, db *mongo.Database, nodeID string) error
- func NodePushProof(ctx context.Context, db *mongo.Database, nodeID string, proof generated.Proof) error
- func NodeSetInterfaces(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func NodeSetPublicConfig(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func NodeSetWGPorts(ctx context.Context, db *mongo.Database, nodeID string, ports []uint) error
- func NodeUpdateFreeToUse(ctx context.Context, db *mongo.Database, nodeID string, freeToUse bool) error
- func NodeUpdateReservedResources(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func NodeUpdateTotalResources(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func NodeUpdateUptime(ctx context.Context, db *mongo.Database, nodeID string, uptime int64) error
- func NodeUpdateUsedResources(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func NodeUpdateWorkloadsAmount(ctx context.Context, db *mongo.Database, nodeID string, ...) error
- func Setup(ctx context.Context, db *mongo.Database) error
- type Farm
- type FarmFilter
- func (f FarmFilter) Count(ctx context.Context, db *mongo.Database) (int64, error)
- func (f FarmFilter) Delete(ctx context.Context, db *mongo.Database) (err error)
- func (f FarmFilter) Find(ctx context.Context, db *mongo.Database, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (f FarmFilter) Get(ctx context.Context, db *mongo.Database) (farm Farm, err error)
- func (f FarmFilter) WithFarmQuery(q FarmQuery) FarmFilter
- func (f FarmFilter) WithID(id schema.ID) FarmFilter
- func (f FarmFilter) WithName(name string) FarmFilter
- func (f FarmFilter) WithOwner(tid int64) FarmFilter
- type FarmQuery
- type Gateway
- type GatewayFilter
- func (f GatewayFilter) Count(ctx context.Context, db *mongo.Database) (int64, error)
- func (f GatewayFilter) Delete(ctx context.Context, db *mongo.Database) error
- func (f GatewayFilter) Find(ctx context.Context, db *mongo.Database, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (f GatewayFilter) Get(ctx context.Context, db *mongo.Database) (gateway Gateway, err error)
- func (f GatewayFilter) WithFarmID(id int) GatewayFilter
- func (f GatewayFilter) WithFreeToUse(freeToUse bool) GatewayFilter
- func (f GatewayFilter) WithGWID(id string) GatewayFilter
- func (f GatewayFilter) WithGWIDs(ids []string) GatewayFilter
- func (f GatewayFilter) WithID(id schema.ID) GatewayFilter
- func (f GatewayFilter) WithLocation(country, city string) GatewayFilter
- type Node
- type NodeFilter
- func (f NodeFilter) Count(ctx context.Context, db *mongo.Database) (int64, error)
- func (f NodeFilter) Delete(ctx context.Context, db *mongo.Database) error
- func (f NodeFilter) ExcludeDeleted() NodeFilter
- func (f NodeFilter) Find(ctx context.Context, db *mongo.Database, opts ...*options.FindOptions) (*mongo.Cursor, error)
- func (f NodeFilter) Get(ctx context.Context, db *mongo.Database, includeproofs bool) (node Node, err error)
- func (f NodeFilter) WithFarmID(id schema.ID) NodeFilter
- func (f NodeFilter) WithFreeToUse(freeToUse bool) NodeFilter
- func (f NodeFilter) WithID(id schema.ID) NodeFilter
- func (f NodeFilter) WithLocation(country, city string) NodeFilter
- func (f NodeFilter) WithNodeID(id string) NodeFilter
- func (f NodeFilter) WithNodeIDs(ids []string) NodeFilter
- func (f NodeFilter) WithTotalCap(cru, mru, hru, sru int64) NodeFilter
Constants ¶
const (
// FarmCollection db collection name
FarmCollection = "farm"
)
const (
// GatewayCollection db collection name
GatewayCollection = "gateway"
)
const (
// NodeCollection db collection name
NodeCollection = "node"
)
Variables ¶
This section is empty.
Functions ¶
func FarmCreate ¶
FarmCreate creates a new farm
func FarmUpdate ¶
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 ¶
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 ¶
NodeCreate creates a new farm
func NodeDelete ¶
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 ¶
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 ¶
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
Types ¶
type FarmFilter ¶
FarmFilter type
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) 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 GatewayFilter ¶
GatewayFilter type
func (GatewayFilter) Find ¶
func (f GatewayFilter) Find(ctx context.Context, db *mongo.Database, opts ...*options.FindOptions) (*mongo.Cursor, error)
Find run the filter and return a cursor result
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 NodeFilter ¶
NodeFilter type
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