Giter Site home page Giter Site logo

gosixdegrees's People

Contributors

chan-kelv avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

gosixdegrees's Issues

Node to Node RPC

Multiple instances of the server will be spun up to share the work of web crawling. One is designated as the master (with a command prompt flag -m) and the others as slaves (-s). On startup, the master node begins an rpc listen on a port to allow for the connection of slave nodes. Slave nodes must connect to the master to connect to the master.

  • Master must keep track of all nodes connected to it
  • May need to add command arg to let slaves know of master's IP:port
  • RPC setup needs to occur BEFORE http requests can be made.

Listening example:
https://parthdesai.me/articles/2016/05/20/go-rpc-server/
https://golang.org/pkg/net/rpc/

go func() {
//turn serverIp into tcp address
listen, err := net.Listen("tcp", serverIp)
//Register new server with ability to handle MServer RPC methods
mServer := new(MServer)
server := rpc.NewServer()
server.Register(mServer)
for {
conn, err := listen.Accept()
//TODO - save the conn
}
}()

Slave connection example:

/*
Connect to a server. The server will keep a record of the worker who dialed
TODO - save the client that is returned
*/
func createClientToServer(serverIp string) (client *net.TCPConn, err error) {
address, err := net.ResolveTCPAddr("tcp", serverIp)
if err != nil {
fmt.Println("Worker client error", err)
err = fmt.Errorf("Worker client error", err)
}
client, err = net.DialTCP("tcp", nil, address)
if err != nil {
fmt.Println("Worker client error", err)
err = fmt.Errorf("Worker client error", err)
}
return client, nil
}

func setWorkerListenToServer(conn *net.TCPConn) {
server := rpc.NewServer()
workerRpc := new(WorkerRpc)
server.Register(workerRpc)
server.ServeConn(conn) //this hangs while connecting to the conn obj
fmt.Println("Server connection broken") //this executes after connection breaks
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.