Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added proto files and client for gaminganywhere #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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"

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/helloworld"

Check failure on line 8 in grpcclient/gaminganywhere_client.go

View workflow job for this annotation

GitHub Actions / GolangCI Lint

could not import github.com/vhive-serverless/vSwarm-proto/proto/helloworld (-: C++ source files not allowed when not using cgo or SWIG: helloworld.pb.cc) (typecheck)
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
Loading