com

package
v0.0.0-...-d20dd18 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP

func GetLocalIP() string

GetLocalIP returns a non-loopback localhost IP if any

func UDPRequest

func UDPRequest(addr string, timeout time.Duration) (response *protocol.AmAlive, err error)
UDP

UDPRequest sends an UDP request to the specified address with a timeout

Types

type CASOperation

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

func (*CASOperation) Wait

func (g *CASOperation) Wait() error

type Conn

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

Conn provides an interface to a possible buffered DB TCP client connection

func CreateConnection

func CreateConnection(addr string, onClose func()) (*Conn, error)

CreateConnection returns a new Conn

func (*Conn) AddServerToGroup

func (c *Conn) AddServerToGroup(addr string) error

AddServerToGroup request to add this server to the server group

func (*Conn) CAS

func (c *Conn) CAS(key []byte, value []byte, timeout time.Duration) CASOperation

func (*Conn) Close

func (c *Conn) Close()

Close this connection

func (*Conn) Del

func (c *Conn) Del(key []byte, value []byte, timeout time.Duration) DelOperation

Del deletes a key/value pair

func (*Conn) Get

func (c *Conn) Get(key []byte, timeout time.Duration) GetOperation

Get the value of key

func (*Conn) GetAccessInfo

func (c *Conn) GetAccessInfo() ([]byte, error)

GetAccessInfo request DB access info

func (*Conn) GetChunkInfo

func (c *Conn) GetChunkInfo(chunkID int) (size uint64, err error)

GetChunkInfo request chunk info

func (*Conn) Protect

func (c *Conn) Protect(chunkID int) error

func (*Conn) Set

func (c *Conn) Set(key []byte, value []byte, timeout time.Duration) SetOperation

Set a new key/value pair

func (*Conn) SetBuffered

func (c *Conn) SetBuffered()

func (*Conn) SetNoDelay

func (c *Conn) SetNoDelay()

func (*Conn) Transfer

func (c *Conn) Transfer(addr string, chunkID int) error

Transfer a chunk

type DelOperation

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

func (*DelOperation) Wait

func (g *DelOperation) Wait() error

type GetOperation

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

func (*GetOperation) Wait

func (g *GetOperation) Wait() result

type Server

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

Server listen to TCP & UDP, accepting connections and responding to clients using callback functions

func Start

func Start(localIP string, localPort int, tcpCallback func(protocol.Message) (response protocol.Message), udpCallback UDPCallback) *Server

Start a Treeless server

func (*Server) IsStopped

func (s *Server) IsStopped() bool

IsStopped returns true if the server is not running

func (*Server) Stop

func (s *Server) Stop()

Stop the server, close all TCP/UDP connections

type SetOperation

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

func (*SetOperation) Wait

func (g *SetOperation) Wait() error

type TCPCallback

type TCPCallback func(protocol.Message) (response protocol.Message)

TCPCallback is the main callback, it returns a response message, if the response message type is 0 the response will be dropped

type UDPCallback

type UDPCallback func() protocol.AmAlive

UDPCallback function should respond to incoming UDP pings

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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