stuffs
This commit is contained in:
23
grain-server.go
Normal file
23
grain-server.go
Normal 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))
|
||||
}
|
||||
Reference in New Issue
Block a user