-
Notifications
You must be signed in to change notification settings - Fork 136
/
server.go
46 lines (35 loc) · 851 Bytes
/
server.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
45
46
package main
import (
"context"
"flag"
example "github.com/rpcxio/rpcx-examples"
"github.com/smallnest/rpcx/server"
)
var (
addr1 = flag.String("addr1", "localhost:8972", "server address")
addr2 = flag.String("addr2", "localhost:8973", "server address")
)
type Arith int
func (t *Arith) Mul(ctx context.Context, args *example.Args, reply *example.Reply) error {
reply.C = args.A * args.B
return nil
}
type Arith2 int
func (t *Arith2) Mul(ctx context.Context, args *example.Args, reply *example.Reply) error {
reply.C = args.A * args.B * 100
return nil
}
func main() {
flag.Parse()
go func() {
s := server.NewServer()
s.RegisterName("Arith", new(Arith), "")
s.Serve("reuseport", *addr1)
}()
go func() {
s := server.NewServer()
s.RegisterName("Arith", new(Arith2), "")
s.Serve("reuseport", *addr2)
}()
select {}
}