Hochwasser/rpc/dottir.go

43 lines
763 B
Go
Raw Normal View History

package rpc
import (
"fmt"
"log"
2020-02-11 14:46:58 +01:00
"net"
"net/rpc"
)
2020-02-11 14:46:58 +01:00
// const handshake_magick = "Sæl!"
func ConnectHevring(ránAddress string) {
2020-02-11 14:46:58 +01:00
rpc.Register(new(Hevring))
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)
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-11 14:46:58 +01:00
type Hevring struct {}
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
}