client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WRITE_MODE = "write"
	READ_MODE  = "read"
)

Page access mode types

View Source
const (
	INVALIDATE         = "invalidate"
	READ               = "read_request"
	READ_FORWARD       = "read_forward"
	WRITE_FORWARD      = "write_forward"
	WRITE              = "write_request"
	WRITE_CONFIRMATION = "write_confirmation"
	EMPTY              = "empty"
	JOIN               = "join"
	COPY               = "copy"
	WRITE_COPY         = "write_copy"
	FIRST              = "first" // When you're the first node requesting read access to the page, so you can directly set it's
	ACK                = "ack"
	I_HAVE_COPY        = "i_have_copy"
	NEW_SERVER         = "new_server"
)

Message types

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	IP         string
	Cache      map[int]Page // List of pages in its cache. pageId -> Page{Content, Access Mode}
	ServerIP   string
	Clientlist []string
	Timestamp  int // scalar clock to indicate when the request was made. If there are concurrent requests, then we need to break ties
}

func (*Client) CallCentralRPC

func (client *Client) CallCentralRPC(msg message.Message, IP string) message.Message

func (*Client) CallRPC

func (client *Client) CallRPC(msg message.Message, IP string) message.Message

func (*Client) HandleIncomingMessage

func (client *Client) HandleIncomingMessage(msg *message.Message, reply *message.Message) error

The default method called by all RPCs. This method receives different types of requests, and calls the appropriate functions.

func (*Client) JoinNetwork

func (client *Client) JoinNetwork(helper string)

func (*Client) PrintCentralIP

func (client *Client) PrintCentralIP()

func (*Client) PrintClientList

func (client *Client) PrintClientList()

func (*Client) PrintPages added in v1.0.0

func (client *Client) PrintPages()

func (*Client) ReadRequest

func (client *Client) ReadRequest()

A requesting node will first

func (*Client) WriteRequest

func (client *Client) WriteRequest()

type Page

type Page struct {
	Content    int    // Content in the page. For the purpose of this implementation, we will make it a simple integer.
	AccessMode string // READ | WRITE
}

Jump to

Keyboard shortcuts

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