2020-02-07 12:20:53 +01:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2020-02-11 14:46:58 +01:00
|
|
|
"net"
|
2020-02-07 12:20:53 +01:00
|
|
|
"net/rpc"
|
|
|
|
)
|
|
|
|
|
2020-02-11 14:46:58 +01:00
|
|
|
// const handshake_magick = "Sæl!"
|
|
|
|
|
2020-02-07 12:20:53 +01:00
|
|
|
func ConnectHevring(ránAddress string) {
|
2020-02-11 14:46:58 +01:00
|
|
|
rpc.Register(new(Hevring))
|
2020-02-07 12:20:53 +01:00
|
|
|
|
2020-02-11 14:46:58 +01:00
|
|
|
fmt.Printf("[hevring] greeting Rán at %s\n", ránAddress)
|
|
|
|
conn, err := net.Dial("tcp", ránAddress)
|
2020-02-07 12:20:53 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2020-02-11 14:46:58 +01:00
|
|
|
go rpc.ServeConn(conn)
|
|
|
|
fmt.Printf("[hevring] awaiting task from Rán\n")
|
|
|
|
}
|
2020-02-07 12:20:53 +01:00
|
|
|
|
2020-02-11 14:46:58 +01:00
|
|
|
type Hevring struct {}
|
2020-02-07 12:20:53 +01:00
|
|
|
|
2020-02-11 14:46:58 +01:00
|
|
|
type FlutAck struct{ Ok bool }
|
|
|
|
|
|
|
|
func (h *Hevring) Flut(job RánJob, reply *FlutAck) error {
|
|
|
|
fmt.Printf("[hevring] Rán gave us /w o r k/! %v\n", job)
|
|
|
|
reply.Ok = true
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Hevring) Status(x int, reply *FlutAck) error {
|
|
|
|
reply.Ok = true
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Hevring) Stop(x int, reply *FlutAck) error {
|
|
|
|
reply.Ok = true
|
|
|
|
return nil
|
2020-02-07 12:20:53 +01:00
|
|
|
}
|