-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added gaminganywhere client and generate c++ helloworld proto
- Loading branch information
Showing
3 changed files
with
1,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/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() | ||
} |
Oops, something went wrong.