network

package
v0.0.0-...-22f7c09 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionProvider

type ConnectionProvider interface {
	// Call returns true if and only if the call was successful
	Call(server string, svcName string, svcMeth string, args interface{}, reply interface{}) bool
	// Me returns the address of this Host
	Me() string
	NumPeers() int
}
Serves as an additional abstraction over labrpc/networking. Raft + the client

identify servers by indices. This interface is responsible for taking a call, translating the index into either a 'labrpc' end or an actual network connection and executing the rpc just as labrpc does. Using this class should let us maintain a similar interface in our code but swap out whether we want to use labrpc or real ip addresses

func New

func New(peers []*labrpc.ClientEnd, me int) ConnectionProvider

type LabrpcConnectionProvider

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

Implements the ConnectionProvider interface using the laprpc library

func (*LabrpcConnectionProvider) Call

func (cp *LabrpcConnectionProvider) Call(server string, svcName string, svcMeth string, args interface{}, reply interface{}) bool

func (*LabrpcConnectionProvider) Me

func (*LabrpcConnectionProvider) NumPeers

func (cp *LabrpcConnectionProvider) NumPeers() int

type Libp2pConnectionProvider

type Libp2pConnectionProvider struct {
	Host   host.Host
	Client *gorpc.Client
	Server *gorpc.Server
}

Libp2pConnectionProvider implements the ConnectionProvider interface using libp2p

func NewLibp2p

func NewLibp2p() *Libp2pConnectionProvider

func (*Libp2pConnectionProvider) Call

func (cp *Libp2pConnectionProvider) Call(server string, svcName string, svcMeth string, args interface{}, reply interface{}) bool

func (*Libp2pConnectionProvider) Me

func (*Libp2pConnectionProvider) NumPeers

func (cp *Libp2pConnectionProvider) NumPeers() int

Jump to

Keyboard shortcuts

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