DevourTech / christmasdb

A key value store to explore on database and storage internals
MIT License
1 stars 3 forks source link

[Raft] Implement TCP Client and server modules for RPC communication #28

Open rohan23chhabra opened 2 years ago

rohan23chhabra commented 2 years ago

Create an interface RPC:

type RPC interface {
    Write([]byte) error
    Read() (byte[], error)
}

Implement a struct tcpClient which implements the RPC interface.

Some boilerplate code:

type tcpClient struct {
    // state of the tcp client
}

func NewClient(<some config parameters>) RPC {
    // instantiate a new client
}

func (client *tcpClient) Read() ([]byte, error) {
    // read the data from the end point
}

func (client *tcpClient) Write(b []byte) error {
    // write the data to the end point
}

Refer to these links: https://gist.github.com/adeekshith/34c20eb45bebe41f5247 https://www.linode.com/docs/guides/developing-udp-and-tcp-clients-and-servers-in-go/