registry

package module
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: GPL-3.0 Imports: 14 Imported by: 13

README

go-registry

simple socket registry client for simple-dict-server

Documentation

Index

Constants

View Source
const (
	CMDGET uint8 = iota
	CMDCAT
	CMDMD5
	CMDACK
	CMDEND
	CMDSET
	CMDDEL
	CMDDAT
)
View Source
const (
	ACKNONE uint8 = iota<<4 + 3
	ACKSUCC
	ACKDATA
	ACKNULL
	ACKNEQU
	ACKERRO
)

Variables

View Source
var (
	ErrGetKeyTooLong    = errors.New("reg: get key too long")
	ErrDecAck           = errors.New("reg: decrypt ack error")
	ErrInternalServer   = errors.New("reg: internal server error")
	ErrPermissionDenied = errors.New("reg: permission denied")
	ErrSetKeyTooLong    = errors.New("reg: set key too long")
	ErrSetValTooLong    = errors.New("reg: set val too long")
	ErrUnknownAck       = errors.New("reg: unknown ack error")
	ErrNoSuchKey        = errors.New("reg: no such key")
	ErrRawDataTooLong   = errors.New("reg: raw data too long")
	ErrMd5NotEqual      = errors.New("reg: md5 not equal")
	ErrInvalidCatData   = errors.New("reg: invalid cat data")
	ErrNilStorData      = errors.New("reg: nil stor data")
)
View Source
var (
	ErrMd5Mismatch = errors.New("cmd: md5 mismatch")
)

Functions

func BytesToString added in v0.0.3

func BytesToString(b []byte) string

BytesToString 没有内存开销的转换

func StringToBytes added in v0.0.3

func StringToBytes(s string) (b []byte)

StringToBytes 没有内存开销的转换

Types

type CmdPacket

type CmdPacket struct {
	io.ReaderFrom

	Data []byte
	// contains filtered or unexported fields
}

func NewCmdPacket

func NewCmdPacket(cmd uint8, data []byte, t *tea.TEA) (c *CmdPacket)

func ParseCmdPacket

func ParseCmdPacket(data []byte, t *tea.TEA) (c *CmdPacket)

func ReadCmdPacket added in v0.1.0

func ReadCmdPacket(f io.Reader, t *tea.TEA) (c *CmdPacket, err error)

func (*CmdPacket) Decrypt

func (c *CmdPacket) Decrypt(seq uint8) error

func (*CmdPacket) Encrypt

func (c *CmdPacket) Encrypt(seq uint8) (raw []byte)

func (*CmdPacket) Put added in v0.1.0

func (c *CmdPacket) Put()

func (*CmdPacket) ReadFrom added in v0.1.0

func (c *CmdPacket) ReadFrom(f io.Reader) (n int64, err error)

func (*CmdPacket) Refresh added in v0.1.0

func (c *CmdPacket) Refresh(cmd uint8, data []byte, t *tea.TEA)

func (*CmdPacket) Write added in v0.1.0

func (c *CmdPacket) Write(buf []byte) (n int, err error)

Write should not be used due to the full-copy of buf

type Regedit

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

func NewRegReader

func NewRegReader(addr, stor, pwd string) *Regedit

func NewRegedit

func NewRegedit(addr, stor, pwd, sps string) *Regedit

func (*Regedit) Cat added in v0.2.0

func (r *Regedit) Cat() (*Storage, error)

func (*Regedit) Close

func (r *Regedit) Close() (err error)

func (*Regedit) Connect

func (r *Regedit) Connect() (err error)

func (*Regedit) ConnectIn added in v0.0.2

func (r *Regedit) ConnectIn(timeout time.Duration) (err error)

func (*Regedit) Del

func (r *Regedit) Del(key string) error

func (*Regedit) Get

func (r *Regedit) Get(key string) (string, error)

func (*Regedit) IsMd5Equal added in v0.2.0

func (r *Regedit) IsMd5Equal(m [md5.Size]byte) (bool, error)

func (*Regedit) Load added in v0.2.3

func (r *Regedit) Load() (*Storage, error)

func (*Regedit) Set

func (r *Regedit) Set(key, value string) error

type Storage added in v0.2.0

type Storage struct {
	Md5 [md5.Size]byte
	// contains filtered or unexported fields
}

func (*Storage) Get added in v0.2.0

func (s *Storage) Get(key string) (string, error)

Jump to

Keyboard shortcuts

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