add p2c peak ewma load balancer

This commit is contained in:
kevin
2020-08-06 20:55:38 +08:00
parent c7544d0e60
commit 63583d4744
24 changed files with 304 additions and 282 deletions

View File

@@ -28,12 +28,7 @@ func main() {
for {
select {
case <-ticker.C:
conn, ok := client.Next()
if !ok {
time.Sleep(time.Second)
break
}
conn := client.Conn()
greet := unary.NewGreeterClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
resp, err := greet.Greet(ctx, &unary.Request{

View File

@@ -0,0 +1,37 @@
package main
import (
"context"
"fmt"
"time"
"zero/core/discov"
"zero/example/rpc/remote/unary"
"zero/rpcx"
)
func main() {
cli := rpcx.MustNewClient(rpcx.RpcClientConf{
Etcd: discov.EtcdConf{
Hosts: []string{"localhost:2379"},
Key: "rpcx",
},
})
greet := unary.NewGreeterClient(cli.Conn())
ticker := time.NewTicker(time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
resp, err := greet.Greet(context.Background(), &unary.Request{
Name: "kevin",
})
if err != nil {
fmt.Println("X", err.Error())
} else {
fmt.Println("=>", resp.Greet)
}
}
}
}

View File

@@ -26,11 +26,7 @@ func main() {
log.Fatal(err)
}
conn, ok := client.Next()
if !ok {
log.Fatal("no server")
}
conn := client.Conn()
greet := stream.NewStreamGreeterClient(conn)
stm, err := greet.Greet(context.Background())
if err != nil {

View File

@@ -4,7 +4,6 @@ import (
"context"
"flag"
"fmt"
"log"
"time"
"zero/core/conf"
@@ -25,11 +24,7 @@ func main() {
for {
select {
case <-ticker.C:
conn, ok := client.Next()
if !ok {
log.Fatal("no server")
}
conn := client.Conn()
greet := unary.NewGreeterClient(conn)
resp, err := greet.Greet(context.Background(), &unary.Request{
Name: "kevin",

View File

@@ -1,17 +1,13 @@
{
"Name": "rpc.unary",
"MetricsUrl": "http://localhost:2222/add",
"Log": {
"Mode": "volume"
},
"ListenOn": "localhost:3457",
"Auth": false,
"Etcd": {
"Hosts": [
"localhost:2379"
],
"Key": "rpcx"
},
"Redis": {
"Host": "localhost:6379",
"Type": "node",
"Key": "apps"
}
}