rafted: github.com/zonas/rafted/comm Index | Files

package comm

import "github.com/zonas/rafted/comm"

Index

Package Files

comm.go http.go memory.go rpc.go socket.go todo.go

Constants

const (
    DefaultTransportBufferSize = 16
)

Variables

var (
    MemoryTransportReadTimeout error = errors.New(
        "timeout on memory transport read")
    MemoryTransportWriteTimeout error = errors.New(
        "timeout on memory transport write")
)
var (
    RPCErrorInvalidRequest        error = errors.New("invalid rpc request")
    RPCErrorInvalidResponse             = errors.New("invalid rpc response")
    RPCErrorNoConnectionForTarget       = errors.New("no connection for this target")
)

func BytesCopy Uses

func BytesCopy(dest []byte, src []byte) int

func FirstAddr Uses

func FirstAddr(multiAddr ps.MultiAddr) ps.Addr

func MultiAddrToRPCMap Uses

func MultiAddrToRPCMap(addr ps.MultiAddr) map[string]string

func ReadN Uses

func ReadN(reader io.Reader, b []byte) (int, error)

func ReadRequest Uses

func ReadRequest(
    reader *bufio.Reader,
    decoder Decoder) (ev.RequestEvent, error)

func ReadResponse Uses

func ReadResponse(
    reader *bufio.Reader,
    decoder Decoder) (ev.Event, error)

func WriteEvent Uses

func WriteEvent(
    writer *bufio.Writer,
    encoder Encoder,
    event ev.Event) error

func WriteN Uses

func WriteN(writer io.Writer, b []byte) (int, error)

type BufferedTransport Uses

type BufferedTransport struct{}

TODO to impl Transport

type Client Uses

type Client interface {
    CallRPCTo(
        target ps.MultiAddr, request ev.Event) (response ev.Event, err error)
    io.Closer
}

type Connection Uses

type Connection interface {
    Open() error
    io.Closer

    PeerAddr() ps.MultiAddr
    CallRPC(request ev.Event) (response ev.Event, err error)
}

type Decoder Uses

type Decoder interface {
    Decode(e interface{}) error
}

type Encoder Uses

type Encoder interface {
    Encode(e interface{}) error
}

type EventHandler Uses

type EventHandler func(ev.Event)

type FileTransport Uses

type FileTransport struct{}

TODO to impl Transport

type FramedTransport Uses

type FramedTransport struct{}

TODO to impl Transport

type HTTPTransport Uses

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

func NewHTTPTransport Uses

func NewHTTPTransport(url string) *HTTPTransport

func (*HTTPTransport) Close Uses

func (self *HTTPTransport) Close() error

func (*HTTPTransport) Open Uses

func (self *HTTPTransport) Open() error

func (*HTTPTransport) Read Uses

func (self *HTTPTransport) Read(b []byte) (int, error)

func (*HTTPTransport) Write Uses

func (self *HTTPTransport) Write(b []byte) (int, error)

type MemoryClient Uses

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

func NewMemoryClient Uses

func NewMemoryClient(
    poolSize int,
    timeout time.Duration,
    register *MemoryTransportRegister) *MemoryClient

func (*MemoryClient) CallRPCTo Uses

func (self *MemoryClient) CallRPCTo(
    target ps.MultiAddr, request ev.Event) (response ev.Event, err error)

func (*MemoryClient) Close Uses

func (self *MemoryClient) Close() error

type MemoryConnection Uses

type MemoryConnection struct {
    *MemoryTransport
    // contains filtered or unexported fields
}

func NewMemoryConnection Uses

func NewMemoryConnection(
    addr ps.MultiAddr,
    timeout time.Duration,
    register *MemoryTransportRegister) *MemoryConnection

func (*MemoryConnection) CallRPC Uses

func (self *MemoryConnection) CallRPC(
    request ev.Event) (response ev.Event, err error)

type MemoryServer Uses

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

func NewMemoryServer Uses

func NewMemoryServer(
    bindAddr ps.MultiAddr,
    timeout time.Duration,
    eventHandler RequestEventHandler,
    register *MemoryTransportRegister,
    logger logging.Logger) *MemoryServer

func (*MemoryServer) Close Uses

func (self *MemoryServer) Close() error

func (*MemoryServer) Serve Uses

func (self *MemoryServer) Serve()

type MemoryServerTransport Uses

type MemoryServerTransport struct {
    ConsumeCh  chan *TransportChunk
    ResponseCh chan []byte
    // contains filtered or unexported fields
}

func NewMemoryServerTransport Uses

func NewMemoryServerTransport(
    addr ps.MultiAddr,
    timeout time.Duration,
    register *MemoryTransportRegister) *MemoryServerTransport

func (*MemoryServerTransport) Addr Uses

func (self *MemoryServerTransport) Addr() ps.MultiAddr

func (*MemoryServerTransport) Close Uses

func (self *MemoryServerTransport) Close() error

func (*MemoryServerTransport) Open Uses

func (self *MemoryServerTransport) Open() error

func (*MemoryServerTransport) Read Uses

func (self *MemoryServerTransport) Read(p []byte) (int, error)

func (*MemoryServerTransport) ReadChunk Uses

func (self *MemoryServerTransport) ReadChunk() (*TransportChunk, error)

func (*MemoryServerTransport) ReadNextMessage Uses

func (self *MemoryServerTransport) ReadNextMessage() *TransportChunk

func (*MemoryServerTransport) Write Uses

func (self *MemoryServerTransport) Write(p []byte) (int, error)

func (*MemoryServerTransport) WriteChunk Uses

func (self *MemoryServerTransport) WriteChunk(chunk *TransportChunk) error

type MemoryTransport Uses

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

func NewMemoryTransport Uses

func NewMemoryTransport(
    addr ps.MultiAddr,
    timeout time.Duration,
    register *MemoryTransportRegister) *MemoryTransport

func (*MemoryTransport) Close Uses

func (self *MemoryTransport) Close() error

func (*MemoryTransport) Open Uses

func (self *MemoryTransport) Open() error

func (*MemoryTransport) PeerAddr Uses

func (self *MemoryTransport) PeerAddr() ps.MultiAddr

func (*MemoryTransport) Read Uses

func (self *MemoryTransport) Read(b []byte) (int, error)

func (*MemoryTransport) Write Uses

func (self *MemoryTransport) Write(b []byte) (int, error)

type MemoryTransportRegister Uses

type MemoryTransportRegister struct {
    sync.RWMutex
    // contains filtered or unexported fields
}

func NewMemoryTransportRegister Uses

func NewMemoryTransportRegister() *MemoryTransportRegister

func (*MemoryTransportRegister) Get Uses

func (self *MemoryTransportRegister) Get(
    id string) (transport *MemoryServerTransport, ok bool)

func (*MemoryTransportRegister) Register Uses

func (self *MemoryTransportRegister) Register(
    id string, transport *MemoryServerTransport)

func (*MemoryTransportRegister) Reset Uses

func (self *MemoryTransportRegister) Reset() error

func (*MemoryTransportRegister) String Uses

func (self *MemoryTransportRegister) String() string

func (*MemoryTransportRegister) Unregister Uses

func (self *MemoryTransportRegister) Unregister(id string) error

type RPCAppendEntriesRequest Uses

type RPCAppendEntriesRequest ev.AppendEntriesRequest

type RPCAppendEntriesResponse Uses

type RPCAppendEntriesResponse struct {
    Response *ev.AppendEntriesResponse
}

type RPCAuth Uses

type RPCAuth struct {
    User     string
    Password string
}

type RPCClient Uses

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

func NewRPCClient Uses

func NewRPCClient(timeout time.Duration, auth *RPCAuth) *RPCClient

func (*RPCClient) CallRPCTo Uses

func (self *RPCClient) CallRPCTo(
    target ps.MultiAddr, request ev.Event) (response ev.Event, err error)

func (*RPCClient) Close Uses

func (self *RPCClient) Close() error

type RPCClientAppendRequest Uses

type RPCClientAppendRequest ev.ClientAppendRequest

type RPCClientChangeConfigRequest Uses

type RPCClientChangeConfigRequest ev.ClientChangeConfigRequest

type RPCClientGetConfigRequest Uses

type RPCClientGetConfigRequest ev.ClientGetConfigRequest

type RPCClientReadOnlyRequest Uses

type RPCClientReadOnlyRequest ev.ClientReadOnlyRequest

type RPCClientResponse Uses

type RPCClientResponse struct {
    Result RPCResultType
    Data   []byte
    Conf   *ps.Config
    Leader *ps.ServerAddress
    Error  string
}

type RPCClientService Uses

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

func NewRPCClientService Uses

func NewRPCClientService(eventHandler RequestEventHandler) *RPCClientService

func (*RPCClientService) Append Uses

func (self *RPCClientService) Append(
    args *RPCClientAppendRequest, reply *RPCClientResponse) error

func (*RPCClientService) ChangeConfig Uses

func (self *RPCClientService) ChangeConfig(
    args *RPCClientChangeConfigRequest, reply *RPCClientResponse) error

func (*RPCClientService) GetConfig Uses

func (self *RPCClientService) GetConfig(
    args *RPCClientGetConfigRequest, reply *RPCClientResponse) error

func (*RPCClientService) ReadOnly Uses

func (self *RPCClientService) ReadOnly(
    args *RPCClientReadOnlyRequest, reply *RPCClientResponse) error

type RPCConnection Uses

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

func NewRPCConnection Uses

func NewRPCConnection(
    addr ps.MultiAddr, timeout time.Duration, auth *RPCAuth) *RPCConnection

func (*RPCConnection) CallRPC Uses

func (self *RPCConnection) CallRPC(
    request ev.Event) (response ev.Event, err error)

func (*RPCConnection) Close Uses

func (self *RPCConnection) Close() error

func (*RPCConnection) Open Uses

func (self *RPCConnection) Open() error

func (*RPCConnection) PeerAddr Uses

func (self *RPCConnection) PeerAddr() ps.MultiAddr

type RPCInstallSnapshotRequest Uses

type RPCInstallSnapshotRequest ev.InstallSnapshotRequest

type RPCInstallSnapshotResponse Uses

type RPCInstallSnapshotResponse struct {
    Response *ev.InstallSnapshotResponse
}

type RPCRaftService Uses

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

func NewRPCRaftService Uses

func NewRPCRaftService(eventHandler RequestEventHandler) *RPCRaftService

func (*RPCRaftService) AppendEntries Uses

func (self *RPCRaftService) AppendEntries(
    args *RPCAppendEntriesRequest, reply *RPCAppendEntriesResponse) error

func (*RPCRaftService) InstallStapshot Uses

func (self *RPCRaftService) InstallStapshot(
    args *RPCInstallSnapshotRequest, reply *RPCInstallSnapshotResponse) error

func (*RPCRaftService) RequestVote Uses

func (self *RPCRaftService) RequestVote(
    args *RPCRequestVoteRequest, reply *RPCRequestVoteResponse) error

type RPCRequestVoteRequest Uses

type RPCRequestVoteRequest ev.RequestVoteRequest

type RPCRequestVoteResponse Uses

type RPCRequestVoteResponse struct {
    Response *ev.RequestVoteResponse
}

type RPCResultType Uses

type RPCResultType int
const (
    RPCResultUnknown RPCResultType = iota
    RPCResultSuccess
    RPCResultFail
    RPCResultLeaderUnknown
    RPCResultLeaderUnsync
    RPCResultLeaderRedirect
    RPCResultLeaderInMemberChange
    RPCResultPersistError
    RPCResultGetConfig
)

type RPCServer Uses

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

func NewRPCServer Uses

func NewRPCServer(
    bindAddr ps.MultiAddr,
    timeout time.Duration,
    rpcAuth *RPCAuth,
    eventHandler RequestEventHandler,
    logger logging.Logger) (*RPCServer, error)

func (*RPCServer) Close Uses

func (self *RPCServer) Close() error

func (*RPCServer) Serve Uses

func (self *RPCServer) Serve()

func (*RPCServer) SetReadTimeout Uses

func (self *RPCServer) SetReadTimeout(timeout time.Duration)

func (*RPCServer) SetWriteTimeout Uses

func (self *RPCServer) SetWriteTimeout(timeout time.Duration)

type RequestEventHandler Uses

type RequestEventHandler func(ev.RequestEvent)

type Server Uses

type Server interface {
    Serve()
    io.Closer
}

type SocketClient Uses

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

func NewSocketClient Uses

func NewSocketClient(poolSize int, timeout time.Duration) *SocketClient

func (*SocketClient) CallRPCTo Uses

func (self *SocketClient) CallRPCTo(
    target1 ps.MultiAddr, request ev.Event) (response ev.Event, err error)

func (*SocketClient) Close Uses

func (self *SocketClient) Close() error

type SocketConnection Uses

type SocketConnection struct {
    *SocketTransport
    // contains filtered or unexported fields
}

func NewSocketConnection Uses

func NewSocketConnection(
    addr net.Addr, timeout time.Duration) *SocketConnection

func (*SocketConnection) CallRPC Uses

func (self *SocketConnection) CallRPC(
    request ev.Event) (response ev.Event, err error)

type SocketNetworkLayer Uses

type SocketNetworkLayer struct {
    *SocketClient
    *SocketServer
}

func NewSocketNetworkLayer Uses

func NewSocketNetworkLayer(
    client *SocketClient,
    server *SocketServer) *SocketNetworkLayer

type SocketServer Uses

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

func NewSocketServer Uses

func NewSocketServer(
    bindAddr net.Addr,
    timeout time.Duration,
    eventHandler RequestEventHandler,
    logger logging.Logger) (*SocketServer, error)

func (*SocketServer) Close Uses

func (self *SocketServer) Close() error

func (*SocketServer) Serve Uses

func (self *SocketServer) Serve()

func (*SocketServer) SetReadTimeout Uses

func (self *SocketServer) SetReadTimeout(timeout time.Duration)

func (*SocketServer) SetWriteTimeout Uses

func (self *SocketServer) SetWriteTimeout(timeout time.Duration)

type SocketTransport Uses

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

func NewSocketTransport Uses

func NewSocketTransport(addr net.Addr, timeout time.Duration) *SocketTransport

func (*SocketTransport) Close Uses

func (self *SocketTransport) Close() error

func (*SocketTransport) Open Uses

func (self *SocketTransport) Open() error

func (*SocketTransport) PeerAddr Uses

func (self *SocketTransport) PeerAddr() net.Addr

func (*SocketTransport) Read Uses

func (self *SocketTransport) Read(b []byte) (int, error)

func (*SocketTransport) SetReadTimeout Uses

func (self *SocketTransport) SetReadTimeout(timeout time.Duration)

func (*SocketTransport) SetWriteTimeout Uses

func (self *SocketTransport) SetWriteTimeout(timeout time.Duration)

func (*SocketTransport) Write Uses

func (self *SocketTransport) Write(b []byte) (int, error)

type TcpKeepAliveListener Uses

type TcpKeepAliveListener struct {
    *net.TCPListener
}
Copied from net.http.server.go

tcpKeepAliveListener sets TCP keep-alive timeouts on accepted connections. It's used by ListenAndServe and ListenAndServeTLS so dead TCP connections (e.g. closing laptop mid-download) eventually go away.

func (TcpKeepAliveListener) Accept Uses

func (ln TcpKeepAliveListener) Accept() (c net.Conn, err error)

type Transport Uses

type Transport interface {
    Open() error
    io.Closer

    io.Reader
    io.Writer
}

type TransportChunk Uses

type TransportChunk struct {
    Data     []byte
    SourceCh chan []byte
}

Package comm imports 18 packages (graph). Updated 2016-07-23. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).

The go get command cannot install this package because of the following issues: