Skip to content

Commit

Permalink
Added gaminganywhere client and generate c++ helloworld proto
Browse files Browse the repository at this point in the history
  • Loading branch information
yankai14 committed Mar 31, 2024
1 parent 70781f2 commit e6bd188
Show file tree
Hide file tree
Showing 3 changed files with 1,187 additions and 0 deletions.
52 changes: 52 additions & 0 deletions grpcclient/gaminganywhere_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package grpcclient

import (
"context"
"fmt"

Check failure on line 5 in grpcclient/gaminganywhere_client.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint

"fmt" imported and not used (typecheck)
"math/rand"

Check failure on line 6 in grpcclient/gaminganywhere_client.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint

"math/rand" imported and not used (typecheck)

pb "github.com/vhive-serverless/vSwarm-proto/proto/fibonacci"
log "github.com/sirupsen/logrus"
)

type GamingAnywhereGenerator struct {
GeneratorBase
}

func (g *GamingAnywhereGenerator) Next() Input {
var pkt = g.defaultInput
switch g.GeneratorBase.generator {
case Unique:
pkt.Value = "A unique message"
case Linear:
// g.count = g.count + 1
// pkt.Value = fmt.Sprintf("%d", g.count)
pkt.Value = "A linear message"
case Random:
pkt.Value = "A random message"
}
return pkt
}

func (c *GamingAnywhereClient) GetGenerator() Generator {
return new(GamingAnywhereGenerator)
}

type GamingAnywhereClient struct {
ClientBase
client pb.GreeterClient
}

func (c *GamingAnywhereClient) Init(ctx context.Context, ip, port string) {
c.Connect(ctx, ip, port)
c.client = pb.NewGreeterClient(c.conn)
}

func (c *GamingAnywhereClient) Request(ctx context.Context, req Input) string {
var message = req.Value
r, err := c.client.SayHello(ctx, &pb.HelloRequest{Name: message})
if err != nil {
log.Fatalf("could not greet: %v", err)
}
return r.GetMessage()
}
Loading

0 comments on commit e6bd188

Please sign in to comment.