Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
"math/rand"

pb "github.com/vhive-serverless/vSwarm-proto/proto/helloworld"
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