msgs

package
Version: v0.0.0-...-fc1e718 Latest Latest
Warning

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

Go to latest
Published: May 10, 2017 License: MIT Imports: 5 Imported by: 7

Documentation

Overview

Package msgs describes all I/O formatting

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Types

type Check

type Check struct {
	Request  CheckRequest
	Response CheckResponse
}

type CheckRequest

type CheckRequest struct {
	SenderID int
	Requests []ClientRequest
}

Check is used to see apply a read without the master

type CheckResponse

type CheckResponse struct {
	SenderID    int
	Success     bool
	CommitIndex int
	Replies     []ClientResponse
}

type Client

type Client struct {
	Request  ClientRequest
	Response ClientResponse
}

Client wraps a ClientRequest and ClientResponse.

type ClientNet

type ClientNet struct {
	IncomingRequests       chan ClientRequest
	OutgoingResponses      chan Client
	OutgoingRequestsFailed chan ClientRequest
}

func MakeClientNet

func MakeClientNet(buf int) *ClientNet

type ClientRequest

type ClientRequest struct {
	ClientID        int
	RequestID       int
	ForceViewChange bool
	ReadOnly        bool
	Request         string
}

ClientRequest desribes a request.

type ClientResponse

type ClientResponse struct {
	ClientID  int
	RequestID int
	Success   bool
	Response  string
}

ClientResponse desribes a request response.

type Commit

type Commit struct {
	Request  CommitRequest
	Response CommitResponse
}

Commit wraps a CommitRequest and CommitResponse.

type CommitRequest

type CommitRequest struct {
	SenderID         int
	ResponseRequired bool
	StartIndex       int
	EndIndex         int
	Entries          []Entry
}

CommitRequest describes a Commit messages.

type CommitResponse

type CommitResponse struct {
	SenderID    int
	Success     bool
	CommitIndex int
}

CommitResponse describes a Commit response messages.

type Coordinate

type Coordinate struct {
	Request  CoordinateRequest
	Response CoordinateResponse
}

type CoordinateRequest

type CoordinateRequest struct {
	SenderID   int
	View       int
	StartIndex int //inclusive
	EndIndex   int //exclusive
	Prepare    bool
	Entries    []Entry
}

type CoordinateResponse

type CoordinateResponse struct {
	SenderID int
	Success  bool
}

type Copy

type Copy struct {
	Request  CopyRequest
	Response CopyResponse
}

type CopyRequest

type CopyRequest struct {
	SenderID   int
	StartIndex int // inclusive
}

type CopyResponse

type CopyResponse struct {
	SenderID int
	View     int
	Success  bool
	Entries  []Entry
}

CopyResponse is not currently used

type DummyStorage

type DummyStorage struct{}

func MakeDummyStorage

func MakeDummyStorage() *DummyStorage

func (*DummyStorage) PersistLogUpdate

func (_ *DummyStorage) PersistLogUpdate(log LogUpdate) error

func (*DummyStorage) PersistSnapshot

func (_ *DummyStorage) PersistSnapshot(index int, snap []byte) error

func (*DummyStorage) PersistView

func (_ *DummyStorage) PersistView(view int) error

type Entry

type Entry struct {
	View      int
	Committed bool
	Requests  []ClientRequest
}

Entry describes a item stored in the replicated log.

type ExternalStorage

type ExternalStorage struct {
	ViewPersist      chan int
	ViewPersistFsync chan int
	LogPersist       chan LogUpdate
	LogPersistFsync  chan LogUpdate
}

func MakeExternalStorage

func MakeExternalStorage() *ExternalStorage

func (*ExternalStorage) PersistLogUpdate

func (s *ExternalStorage) PersistLogUpdate(logUpdate LogUpdate) error

func (*ExternalStorage) PersistSnapshot

func (s *ExternalStorage) PersistSnapshot(index int, snap []byte) error

func (*ExternalStorage) PersistView

func (s *ExternalStorage) PersistView(view int) error

type FailureNotifier

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

func NewFailureNotifier

func NewFailureNotifier(n int) *FailureNotifier

func (*FailureNotifier) IsConnected

func (f *FailureNotifier) IsConnected(id int) bool

func (*FailureNotifier) NextConnected

func (f *FailureNotifier) NextConnected(id int) int

Return the ID of the next connected node

func (*FailureNotifier) NotifyOnFailure

func (f *FailureNotifier) NotifyOnFailure(id int) chan bool

func (*FailureNotifier) NowConnected

func (f *FailureNotifier) NowConnected(id int) error

func (*FailureNotifier) NowDisconnected

func (f *FailureNotifier) NowDisconnected(id int)

type ForwardRequest

type ForwardRequest struct {
	SenderID int
	View     int
	Request  ClientRequest
}

type LogUpdate

type LogUpdate struct {
	StartIndex int
	EndIndex   int
	Entries    []Entry
}

type NewView

type NewView struct {
	Request  NewViewRequest
	Response NewViewResponse
}

type NewViewRequest

type NewViewRequest struct {
	SenderID int
	View     int
}

type NewViewResponse

type NewViewResponse struct {
	SenderID int
	View     int
	Index    int
}

type Notificator

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

func NewNotificator

func NewNotificator() *Notificator

func (*Notificator) IsSubscribed

func (n *Notificator) IsSubscribed(request ClientRequest) bool

func (*Notificator) Notify

func (n *Notificator) Notify(request ClientRequest, response ClientResponse)

func (*Notificator) Subscribe

func (n *Notificator) Subscribe(request ClientRequest) ClientResponse

Blocking call

type PeerNet

type PeerNet struct {
	Incoming          ProtoMsgs
	OutgoingBroadcast ProtoMsgs
	OutgoingUnicast   map[int]*ProtoMsgs
}

func MakePeerNet

func MakePeerNet(buf int, n int) *PeerNet

type Prepare

type Prepare struct {
	Request  PrepareRequest
	Response PrepareResponse
}

Prepare wraps a PrepareRequest and PrepareResponse.

type PrepareRequest

type PrepareRequest struct {
	SenderID   int
	View       int
	StartIndex int // inclusive
	EndIndex   int // exclusive
	Entries    []Entry
}

PrepareRequest describes a Prepare messages.

type PrepareResponse

type PrepareResponse struct {
	SenderID int
	Success  bool
}

PrepareResponse describes a Prepare response messages.

type ProtoMsgs

type ProtoMsgs struct {
	Requests  Requests
	Responses Responses
}

func MakeProtoMsgs

func MakeProtoMsgs(buf int) ProtoMsgs

func (*ProtoMsgs) BytesToProtoMsg

func (msgch *ProtoMsgs) BytesToProtoMsg(b []byte) error

func (*ProtoMsgs) Discard

func (from *ProtoMsgs) Discard()

Forward mesaages from one ProtoMsgs to another

func (*ProtoMsgs) Forward

func (to *ProtoMsgs) Forward(from *ProtoMsgs)

Forward mesaages from one ProtoMsgs to another

func (*ProtoMsgs) ProtoMsgToBytes

func (msgch *ProtoMsgs) ProtoMsgToBytes() ([]byte, error)

type Query

type Query struct {
	Request  QueryRequest
	Response QueryResponse
}

type QueryRequest

type QueryRequest struct {
	SenderID   int
	View       int
	StartIndex int // inclusive
	EndIndex   int // exclusive
}

type QueryResponse

type QueryResponse struct {
	SenderID int
	View     int
	Entries  []Entry
}

type Requests

type Requests struct {
	Prepare    chan PrepareRequest
	Commit     chan CommitRequest
	NewView    chan NewViewRequest
	Query      chan QueryRequest
	Copy       chan CopyRequest
	Coordinate chan CoordinateRequest
	Forward    chan ForwardRequest
	Check      chan CheckRequest
}

type Responses

type Responses struct {
	Prepare    chan Prepare
	Commit     chan Commit
	NewView    chan NewView
	Query      chan Query
	Copy       chan Copy
	Coordinate chan Coordinate
	Check      chan Check
}

type Storage

type Storage interface {
	PersistView(view int) error
	PersistLogUpdate(logUpdate LogUpdate) error
	PersistSnapshot(index int, snap []byte) error
}

Jump to

Keyboard shortcuts

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