node

package
v0.0.0-...-4d1606d Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MaxConnsPerHost     = 1
	MaxIdleConnsPerHost = 1
)
View Source
const LeaderPrefix = "LEADER:"

Variables

This section is empty.

Functions

func NewSnapshot

func NewSnapshot(db *DB) raft.Snapshot

Types

type Client

type Client struct {
	Fallback time.Duration
	// contains filtered or unexported fields
}

func NewClient

func NewClient(targets ...string) *Client

func (*Client) LeaseReadGet

func (c *Client) LeaseReadGet(key string) (value string, ok bool)

func (*Client) ReadIndexGet

func (c *Client) ReadIndexGet(key string) (value string, ok bool)

func (*Client) Set

func (c *Client) Set(key, value string) bool

type DB

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

func (*DB) Data

func (db *DB) Data() (raw []byte, err error)

func (*DB) Get

func (db *DB) Get(key string) (value string)

func (*DB) Set

func (db *DB) Set(key string, value string)

func (*DB) SetData

func (db *DB) SetData(raw []byte) (err error)

type Node

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

func NewNode

func NewNode(dataDir string, host string, httpPort, rpcPort, raftPort int, members []string, join bool) *Node

func (*Node) InitRPCProxy

func (n *Node) InitRPCProxy(MaxConnsPerHost int, MaxIdleConnsPerHost int)

func (*Node) ListenAndServe

func (n *Node) ListenAndServe() error

type Request

type Request struct {
	Key   string
	Value string
}

Request represents an RPC request.

func (*Request) Marshal

func (d *Request) Marshal() ([]byte, error)

Marshal returns the encoded bytes.

func (*Request) MarshalTo

func (d *Request) MarshalTo(buf []byte) (int, error)

MarshalTo marshals into buf and returns the number of bytes.

func (*Request) Size

func (d *Request) Size() int

Size returns the size of the buffer required to represent the data when encoded.

func (*Request) Unmarshal

func (d *Request) Unmarshal(data []byte) error

Unmarshal unmarshals from data.

type Response

type Response struct {
	Ok     bool
	Result string
	Leader string
}

Response represents an RPC response.

func (*Response) Marshal

func (d *Response) Marshal() ([]byte, error)

Marshal returns the encoded bytes.

func (*Response) MarshalTo

func (d *Response) MarshalTo(buf []byte) (int, error)

MarshalTo marshals into buf and returns the number of bytes.

func (*Response) Size

func (d *Response) Size() int

Size returns the size of the buffer required to represent the data when encoded.

func (*Response) Unmarshal

func (d *Response) Unmarshal(data []byte) error

Unmarshal unmarshals from data.

type Service

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

func (*Service) LGet

func (s *Service) LGet(req *Request, res *Response) error

func (*Service) RGet

func (s *Service) RGet(req *Request, res *Response) error

func (*Service) Set

func (s *Service) Set(req *Request, res *Response) error

type SetCommand

type SetCommand struct {
	Key   string
	Value string
}

SetCommand represents a set command.

func (*SetCommand) Do

func (c *SetCommand) Do(context interface{}) (interface{}, error)

func (*SetCommand) Marshal

func (d *SetCommand) Marshal() ([]byte, error)

Marshal returns the encoded bytes.

func (*SetCommand) MarshalTo

func (d *SetCommand) MarshalTo(buf []byte) (int, error)

MarshalTo marshals into buf and returns the number of bytes.

func (*SetCommand) Size

func (d *SetCommand) Size() int

Size returns the size of the buffer required to represent the data when encoded.

func (*SetCommand) Type

func (c *SetCommand) Type() uint64

func (*SetCommand) Unmarshal

func (d *SetCommand) Unmarshal(data []byte) error

Unmarshal unmarshals from data.

type Snapshot

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

func (*Snapshot) Recover

func (s *Snapshot) Recover(r io.Reader) (int, error)

func (*Snapshot) Save

func (s *Snapshot) Save(w io.Writer) (int, error)

Jump to

Keyboard shortcuts

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