creditdb

package module
v0.0.0-...-6d4ea17 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2023 License: MIT Imports: 8 Imported by: 5

README

CreditDB Client for Go

This package provides a client library for CreditDB, a fast and efficient key-value database built in Typescript.

Installation

go get github.com/creditdb/go-creditdb

Usage

Import the package into your code:

import "github.com/creditdb/go-creditdb"
func main(){
    client := creditdb.NewClient().WithPage(1)
    ctx:=context.Background()
	defer client.Close(ctx)
	x, err:=client.Ping(ctx)
	if err != nil {
		log.Fatal(err)
		return
	}
	log.Println(x)
}

License

MIT

Author

Documentation

Index

Constants

View Source
const (
	CategoryNotFound           = "NotFound"
	CategoryBadRequest         = "BadRequest"
	CategoryTimeout            = "Timeout"
	CategoryServiceUnavailable = "ServiceUnavailable"
	CategoryInternalError      = "InternalError"
)

Variables

View Source
var (
	ErrNotFound           = NewError("key not found", CategoryNotFound)
	ErrBadRequest         = NewError("bad request", CategoryBadRequest)
	ErrInternalError      = NewError("internal server error", CategoryInternalError)
	ErrTimeout            = NewError("timeout", CategoryTimeout)
	ErrServiceUnavailable = NewError("service unavailable", CategoryServiceUnavailable)
)

Functions

This section is empty.

Types

type CreditDB

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

func NewClient

func NewClient() *CreditDB

func (*CreditDB) Close

func (c *CreditDB) Close(ctx context.Context) error

func (*CreditDB) DeleteLine

func (c *CreditDB) DeleteLine(ctx context.Context, key string) error

func (*CreditDB) Exists

func (c *CreditDB) Exists(ctx context.Context, key string) (bool, error)

func (*CreditDB) Flush

func (c *CreditDB) Flush(ctx context.Context) error

func (*CreditDB) GetAllLines

func (c *CreditDB) GetAllLines(ctx context.Context) ([]Line, error)

func (*CreditDB) GetCurrentPage

func (c *CreditDB) GetCurrentPage() uint

func (*CreditDB) GetLine

func (c *CreditDB) GetLine(ctx context.Context, key string) (*Line, error)

func (*CreditDB) Health

func (c *CreditDB) Health(ctx context.Context) error

func (*CreditDB) Ping

func (c *CreditDB) Ping(ctx context.Context) (string, error)

func (*CreditDB) SetLine

func (c *CreditDB) SetLine(ctx context.Context, key, value string) error

func (*CreditDB) WithHost

func (c *CreditDB) WithHost(host string) *CreditDB

func (*CreditDB) WithPage

func (c *CreditDB) WithPage(page uint) *CreditDB

type Error

type Error struct {
	Message  string
	Category string
}

func NewError

func NewError(message string, category string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) StatusCode

func (e *Error) StatusCode() int

type Line

type Line struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Page

type Page struct {
	Status string `json:"status"`
	Page   uint   `json:"pagenumber"`
	Result []Line `json:"result"`
}

Jump to

Keyboard shortcuts

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