-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (35 loc) · 1.05 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"context"
"net/http"
"time"
"github.com/eagraf/synchronizer/coordinator"
"github.com/eagraf/synchronizer/messenger"
"github.com/eagraf/synchronizer/selector"
"github.com/eagraf/synchronizer/service"
"google.golang.org/grpc"
)
// TestServer implementation
type TestServerImpl struct{}
func (tsi *TestServerImpl) TestRPC(ctx context.Context, in *service.Ping, opts ...grpc.CallOption) (*service.Pong, error) {
res := &service.Pong{
Message: "Hello",
}
return res, nil
}
// Test service external API handler
func testEndpoint(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hell"))
}
func main() {
sp := service.NewServicePool(4000, service.DefaultTopology)
selector.NewSelector(sp)
selector.NewSelector(sp)
selector.NewSelector(sp)
coordinator.NewCoordinator(sp)
time.Sleep(5 * time.Second)
messenger.NewTestClient("http://localhost:4000/websocket/", "client1")
messenger.NewTestClient("http://localhost:4002/websocket/", "client2")
messenger.NewTestClient("http://localhost:4004/websocket/", "client3")
select {}
}