gedis

package
v0.4.7-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: Apache-2.0 Imports: 7 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

This section is empty.

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

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

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

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

type Pool

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

Pool is interface for a redis pool

Jump to

Keyboard shortcuts

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