client

package
v0.0.0-...-7c6133f Latest Latest
Warning

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

Go to latest
Published: May 30, 2016 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package client is responsible for client-replica communication. In Goxos, a client can connect to the service and send requests. These requests will usually be run by the service, generating a response, which is sent back to the client.

Clients are handled through the use of ClientConn and ClientHandler. The ClientHandler listens on a socket for connections from clients, does a handshake with the client, and then creates a ClientConn -- which is responsible for further handling of each specific client.

To recompile the Protobuf msg.proto file, use the command: protoc msg.proto --go_out=.

Index

Constants

This section is empty.

Variables

View Source
var Request_Type_name = map[int32]string{
	1: "HELLO",
	2: "EXEC",
}
View Source
var Request_Type_value = map[string]int32{
	"HELLO": 1,
	"EXEC":  2,
}
View Source
var Response_Error_name = map[int32]string{
	0:  "NONE",
	1:  "REDIRECT",
	2:  "INVALID_ID",
	3:  "MISSING_ID",
	4:  "MISSING_TAG",
	5:  "MISSING_VAL",
	6:  "OLD_CMD",
	15: "OTHER",
}
View Source
var Response_Error_value = map[string]int32{
	"NONE":        0,
	"REDIRECT":    1,
	"INVALID_ID":  2,
	"MISSING_ID":  3,
	"MISSING_TAG": 4,
	"MISSING_VAL": 5,
	"OLD_CMD":     6,
	"OTHER":       15,
}
View Source
var Response_Protocol_name = map[int32]string{
	0: "UNKNOWN",
	1: "MULTIPAXOS",
	2: "FASTPAXOS",
	3: "BATCHPAXOS",
}
View Source
var Response_Protocol_value = map[string]int32{
	"UNKNOWN":    0,
	"MULTIPAXOS": 1,
	"FASTPAXOS":  2,
	"BATCHPAXOS": 3,
}
View Source
var Response_Type_name = map[int32]string{
	1: "HELLO_RESP",
	2: "EXEC_RESP",
}
View Source
var Response_Type_value = map[string]int32{
	"HELLO_RESP": 1,
	"EXEC_RESP":  2,
}

Functions

func MembID

func MembID(members []string) []byte

MembId returns the membership identifier for the given membership. The membership identifier is expected to be identical for the same membership. Thus, it does not distinguish between two versions of the same membership that may have existed at different times during an execution.

func MembIDEqual

func MembIDEqual(aID, bID []byte) bool

MembIdEqual returns true if aId and bId are equal.

Types

type BatchConnection

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

func (*BatchConnection) Close

func (batchConn *BatchConnection) Close() error

func (*BatchConnection) Send

func (batchConn *BatchConnection) Send(request []byte) <-chan ResponseData

type ClientConn

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

A ClientConn is the server-side represention a connection between a replica and a client. Connected is set to true/false depending on the status of the connection.

func NewClientConn

func NewClientConn(c net.Conn, reqch chan<- *Request) *ClientConn

Create a new ClientConn. A low-level socket structure must be passed in along with a string-based id and the channel where requests are sent.

func (*ClientConn) Close

func (cc *ClientConn) Close()

func (*ClientConn) Serve

func (cc *ClientConn) Serve()

Start serving this ClientConn. Reads a Request from the connection, which gets sent to Goxos for agreement.

func (*ClientConn) String

func (cc *ClientConn) String() string

func (*ClientConn) WriteAsync

func (cc *ClientConn) WriteAsync(resp *Response)

Write a Response to the ClientConn. This method gets called when a Request has been executed.

type ClientHandler

type ClientHandler interface {
	Start()
	Stop()
	ForwardResponse(resp *Response)
}

type ClientHandlerMock

type ClientHandlerMock struct{}

func (*ClientHandlerMock) ForwardResponse

func (chm *ClientHandlerMock) ForwardResponse(resp *Response)

func (*ClientHandlerMock) Start

func (chm *ClientHandlerMock) Start()

func (*ClientHandlerMock) Stop

func (chm *ClientHandlerMock) Stop()

type ClientHandlerTCP

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

The ClientHandler module maintains all of the connections that a replica has with its clients.

func NewClientHandlerTCP

func NewClientHandlerTCP(id grp.ID, paxosType string, gm grp.GroupManager,
	ld liveness.LeaderDetector, propChan chan<- *Request,
	stopCheckIn *sync.WaitGroup) *ClientHandlerTCP

Create a new ClientHandler.

func (*ClientHandlerTCP) ForwardResponse

func (ch *ClientHandlerTCP) ForwardResponse(resp *Response)

Forward a response to the ClientHandler. The response will be routed back to the correct ClientConn which the request was received from.

func (*ClientHandlerTCP) Start

func (ch *ClientHandlerTCP) Start()

Start handling new client connections. Spawns two goroutines, one for handshaking with new connections, and the other for handling requests and responses from other modules.

func (*ClientHandlerTCP) Stop

func (ch *ClientHandlerTCP) Stop()

Shut down the ClientHandler module.

type FastConnection

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

func (*FastConnection) Close

func (c *FastConnection) Close() error

func (*FastConnection) Send

func (c *FastConnection) Send(request []byte) <-chan ResponseData

type ReplicaConn

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

func (*ReplicaConn) Close

func (c *ReplicaConn) Close() error

func (*ReplicaConn) Send

func (c *ReplicaConn) Send(request []byte) <-chan ResponseData

type Request

type Request struct {
	Type             *Request_Type `protobuf:"varint,1,req,name=type,enum=client.Request_Type" json:"type,omitempty"`
	Id               *string       `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"`
	Seq              *uint32       `protobuf:"varint,3,opt,name=seq" json:"seq,omitempty"`
	Val              []byte        `protobuf:"bytes,4,opt,name=val" json:"val,omitempty"`
	XXX_unrecognized []byte        `json:"-"`
}

func (*Request) Equal

func (r *Request) Equal(other Request) bool

Check whether two Requests are equal.

func (*Request) FullString

func (r *Request) FullString() string

Display the Request in its full glory.

func (*Request) GetId

func (this *Request) GetId() string

func (*Request) GetSeq

func (this *Request) GetSeq() uint32

func (*Request) GetType

func (this *Request) GetType() Request_Type

func (*Request) GetVal

func (this *Request) GetVal() []byte

func (*Request) Hash

func (r *Request) Hash() uint32

Do a FNV hash of a Request.

func (*Request) IsIDInvalid

func (r *Request) IsIDInvalid() bool

IsInvalid returns true if the request's ID field is invalid.

func (*Request) ProtoMessage

func (*Request) ProtoMessage()

func (*Request) Reset

func (this *Request) Reset()

func (*Request) SimpleString

func (r *Request) SimpleString() string

Display the Request in truncated string form.

func (*Request) String

func (this *Request) String() string

type Request_Type

type Request_Type int32
const (
	Request_HELLO Request_Type = 1
	Request_EXEC  Request_Type = 2
)

func (Request_Type) Enum

func (x Request_Type) Enum() *Request_Type

func (Request_Type) MarshalJSON

func (x Request_Type) MarshalJSON() ([]byte, error)

func (Request_Type) String

func (x Request_Type) String() string

func (*Request_Type) UnmarshalJSON

func (x *Request_Type) UnmarshalJSON(data []byte) error

type Response

type Response struct {
	Type             *Response_Type     `protobuf:"varint,1,req,name=type,enum=client.Response_Type" json:"type,omitempty"`
	Id               *string            `protobuf:"bytes,2,opt,name=id" json:"id,omitempty"`
	Seq              *uint32            `protobuf:"varint,3,opt,name=seq" json:"seq,omitempty"`
	Val              []byte             `protobuf:"bytes,4,opt,name=val" json:"val,omitempty"`
	Protocol         *Response_Protocol `protobuf:"varint,5,opt,name=protocol,enum=client.Response_Protocol" json:"protocol,omitempty"`
	ErrorCode        *Response_Error    `protobuf:"varint,14,opt,name=error_code,enum=client.Response_Error,def=0" json:"error_code,omitempty"`
	ErrorDetail      *string            `protobuf:"bytes,15,opt,name=error_detail" json:"error_detail,omitempty"`
	XXX_unrecognized []byte             `json:"-"`
}

func (*Response) FullString

func (r *Response) FullString() string

Display the Response in its fully glory.

func (*Response) GetErrorCode

func (this *Response) GetErrorCode() Response_Error

func (*Response) GetErrorDetail

func (this *Response) GetErrorDetail() string

func (*Response) GetId

func (this *Response) GetId() string

func (*Response) GetProtocol

func (this *Response) GetProtocol() Response_Protocol

func (*Response) GetSeq

func (this *Response) GetSeq() uint32

func (*Response) GetType

func (this *Response) GetType() Response_Type

func (*Response) GetVal

func (this *Response) GetVal() []byte

func (*Response) HasError

func (r *Response) HasError() bool

Check whether the response contains an error.

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) Reset

func (this *Response) Reset()

func (*Response) SimpleString

func (r *Response) SimpleString() string

Display the Response in truncated string form.

func (*Response) String

func (this *Response) String() string

type ResponseData

type ResponseData struct {
	Value                 []byte
	SendTime, ReceiveTime time.Time
	Err                   error
}

type Response_Error

type Response_Error int32
const (
	Response_NONE        Response_Error = 0
	Response_REDIRECT    Response_Error = 1
	Response_INVALID_ID  Response_Error = 2
	Response_MISSING_ID  Response_Error = 3
	Response_MISSING_TAG Response_Error = 4
	Response_MISSING_VAL Response_Error = 5
	Response_OLD_CMD     Response_Error = 6
	Response_OTHER       Response_Error = 15
)
const Default_Response_ErrorCode Response_Error = Response_NONE

func (Response_Error) Enum

func (x Response_Error) Enum() *Response_Error

func (Response_Error) MarshalJSON

func (x Response_Error) MarshalJSON() ([]byte, error)

func (Response_Error) String

func (x Response_Error) String() string

func (*Response_Error) UnmarshalJSON

func (x *Response_Error) UnmarshalJSON(data []byte) error

type Response_Protocol

type Response_Protocol int32
const (
	Response_UNKNOWN    Response_Protocol = 0
	Response_MULTIPAXOS Response_Protocol = 1
	Response_FASTPAXOS  Response_Protocol = 2
	Response_BATCHPAXOS Response_Protocol = 3
)

func (Response_Protocol) Enum

func (Response_Protocol) MarshalJSON

func (x Response_Protocol) MarshalJSON() ([]byte, error)

func (Response_Protocol) String

func (x Response_Protocol) String() string

func (*Response_Protocol) UnmarshalJSON

func (x *Response_Protocol) UnmarshalJSON(data []byte) error

type Response_Type

type Response_Type int32
const (
	Response_HELLO_RESP Response_Type = 1
	Response_EXEC_RESP  Response_Type = 2
)

func (Response_Type) Enum

func (x Response_Type) Enum() *Response_Type

func (Response_Type) MarshalJSON

func (x Response_Type) MarshalJSON() ([]byte, error)

func (Response_Type) String

func (x Response_Type) String() string

func (*Response_Type) UnmarshalJSON

func (x *Response_Type) UnmarshalJSON(data []byte) error

type ServiceConn

type ServiceConn interface {
	Send(request []byte) <-chan ResponseData
	Close() error
}

func Dial

func Dial(conf *config.Config) (ServiceConn, error)

func NewBatchConn

func NewBatchConn(conn *ReplicaConn, connections []net.Conn) ServiceConn

func NewFastConn

func NewFastConn(conn *ReplicaConn, connections []net.Conn) ServiceConn

Jump to

Keyboard shortcuts

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