This commit is contained in:
matst80
2024-11-07 22:57:18 +01:00
parent 0f23ae0e9a
commit ae421674d2
9 changed files with 542 additions and 112 deletions

23
grain-server.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"fmt"
"net"
"net/rpc"
)
type GrainServer struct {
Host string
}
func NewServer(hostname string) *GrainServer {
return &GrainServer{
Host: hostname,
}
}
func (s *GrainServer) Start(port int, instance Grain) (net.Listener, error) {
rpc.Register(instance)
rpc.HandleHTTP()
return net.Listen("tcp", fmt.Sprintf(":%d", port))
}