gedis

package
v0.2.2-rc3 Latest Latest
Warning

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

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

README

types generation

./generate.sh <path-to-tomls-directory> <generate-pkg-name>

Documentation

Overview

Package gedis implements a client for Gedis (https://github.com/threefoldtech/digitalmeX/tree/master/docs/Gedis)

Index

Constants

This section is empty.

Variables

View Source
var (
	// Bytes is a helper that converts a command reply to a slice of bytes. If err
	// is not equal to nil, then Bytes returns nil, err. Otherwise Bytes converts
	// the reply to a slice of bytes as follows:
	//
	//  Reply type      Result
	//  bulk string     reply, nil
	//  simple string   []byte(reply), nil
	//  nil             nil, ErrNil
	//  other           nil, error
	Bytes = redis.Bytes

	// Bool is a helper that converts a command reply to a boolean. If err is not
	// equal to nil, then Bool returns false, err. Otherwise Bool converts the
	// reply to boolean as follows:
	//
	//  Reply type      Result
	//  integer         value != 0, nil
	//  bulk string     strconv.ParseBool(reply)
	//  nil             false, ErrNil
	//  other           false, error
	Bool = redis.Bool
)

Functions

func ReservationToSchemaType

func ReservationToSchemaType(r *provision.Reservation) (types.TfgridReservation1, error)

ReservationToSchemaType creates a TfgridReservation1 from zos provision types

Types

type Args

type Args map[string]interface{}

Args is a helper to create map easily

type Error

type Error struct {
	Message  string `json:"message,omitempty"`
	Level    uint   `json:"level,omitempty"`
	Context  string `json:"context,omitempty"`
	Category string `json:"cat,omitempty"`
}

Error is an error returned by a gedis server

func (Error) Error

func (err Error) Error() string

type Gedis

type Gedis struct {
	// contains filtered or unexported fields
}

Gedis struct represent a client to a gedis server

func New

func New(address, password string) (*Gedis, error)

New creates a new Gedis client

func (*Gedis) Close

func (g *Gedis) Close() error

Close closes all connection to the gedis server and stops the close the connection pool

func (*Gedis) Delete

func (g *Gedis) Delete(id string) error

Delete marks a reservation to be deleted

func (*Gedis) Deleted

func (g *Gedis) Deleted(nodeID, id string) error

Deleted implements provision.Feedbacker

func (*Gedis) Feedback

func (g *Gedis) Feedback(nodeID string, r *provision.Result) error

Feedback implements provision.Feedbacker

func (*Gedis) Get

func (g *Gedis) Get(id string) (*provision.Reservation, error)

Get implements provision.ReservationGetter

func (*Gedis) GetFarm

func (g *Gedis) GetFarm(farm pkg.Identifier) (*network.Farm, error)

GetFarm implements pkg.IdentityManager interface

func (*Gedis) GetNode

func (g *Gedis) GetNode(nodeID pkg.Identifier) (*types.Node, error)

GetNode implements pkg.IdentityManager interface

func (*Gedis) GetPubIface

func (g *Gedis) GetPubIface(node pkg.Identifier) (*types.PubIface, error)

GetPubIface gets public config of a node

func (*Gedis) ListFarm

func (g *Gedis) ListFarm(country string, city string) ([]network.Farm, error)

ListFarm implements pkg.IdentityManager interface

func (*Gedis) ListNode

func (g *Gedis) ListNode(farmID pkg.FarmID, country string, city string) ([]types.Node, error)

ListNode implements pkg.IdentityManager interface

func (*Gedis) Ping

func (g *Gedis) Ping() (string, error)

Ping sends a ping to the server. it should return pong

func (*Gedis) Poll

func (g *Gedis) Poll(nodeID pkg.Identifier, from uint64) ([]*provision.Reservation, error)

Poll retrieves reservations from BCDB. from acts like a cursor, first call should use 0 to retrieve everything. Next calls should use the last (MAX) ID of the previous poll. Note that from is a reservation ID not a workload ID. so user the Reservation.SplitID() method to get the reservation part.

func (*Gedis) PublishInterfaces

func (g *Gedis) PublishInterfaces(local pkg.Identifier, ifaces []types.IfaceInfo) error

PublishInterfaces implements network.TNoDB interface

func (*Gedis) PublishWGPort

func (g *Gedis) PublishWGPort(node pkg.Identifier, ports []uint) error

PublishWGPort implements network.TNoDB interface

func (*Gedis) RegisterFarm

func (g *Gedis) RegisterFarm(tid uint64, name string, email string, wallet []string) (pkg.FarmID, error)

RegisterFarm implements pkg.IdentityManager interface

func (*Gedis) RegisterNode

func (g *Gedis) RegisterNode(nodeID pkg.Identifier, farmID pkg.FarmID, version string, location geoip.Location) (string, error)

RegisterNode implements pkg.IdentityManager interface

func (*Gedis) Reserve

func (g *Gedis) Reserve(r *provision.Reservation) (string, error)

Reserve provision.Reserver

func (*Gedis) Send

func (g *Gedis) Send(actor, method string, args Args) (interface{}, error)

Send send a command and read response. args, is a map with argument name, and value as defined by the actor schema. Usually you need to process the returned value through `Bytes`, `Bool` or other wrappers based on the expected return value

func (*Gedis) SendHardwareProof

func (g *Gedis) SendHardwareProof(node pkg.Identifier, dmi interface{}, disks interface{}, hypervisor []string) error

SendHardwareProof sends a dump of hardware and disks to BCDB

func (*Gedis) SetPublicIface

func (g *Gedis) SetPublicIface(node pkg.Identifier, pub *types.PubIface) error

SetPublicIface implements network.TNoDB interface

func (*Gedis) UpdateReservedNodeCapacity

func (g *Gedis) UpdateReservedNodeCapacity(node pkg.Identifier, mru, cru, hru, sru uint64) error

UpdateReservedNodeCapacity implements pkg.IdentityManager interface

func (*Gedis) UpdateReservedResources

func (g *Gedis) UpdateReservedResources(nodeID string, c provision.Counters) error

UpdateReservedResources sends current reserved resources

func (*Gedis) UpdateTotalNodeCapacity

func (g *Gedis) UpdateTotalNodeCapacity(node pkg.Identifier, mru, cru, hru, sru uint64) error

UpdateTotalNodeCapacity implements pkg.IdentityManager interface

func (*Gedis) UpdateUsedNodeCapacity

func (g *Gedis) UpdateUsedNodeCapacity(node pkg.Identifier, mru, cru, hru, sru uint64) error

UpdateUsedNodeCapacity implements pkg.IdentityManager interface

func (*Gedis) UptimeUpdate

func (g *Gedis) UptimeUpdate(nodeID pkg.Identifier, uptime uint64) error

UptimeUpdate send the uptime of the node to BCDB

type Pool

type Pool interface {
	Get() redis.Conn
	Close() error
}

Pool is interface for a redis pool

Directories

Path Synopsis
types

Jump to

Keyboard shortcuts

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