-
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.
Signed-off-by: lrq619 <[email protected]>
- Loading branch information
Showing
7 changed files
with
499 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
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,55 @@ | ||
package grpcclient | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
pb "github.com/vhive-serverless/vSwarm-proto/proto/parking" | ||
) | ||
|
||
type ParkingGenerator struct { | ||
GeneratorBase | ||
} | ||
|
||
func (g *ParkingGenerator) 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 = "Let's do spright parking" | ||
} | ||
return pkt | ||
} | ||
|
||
func (c *ParkingClient) GetGenerator() Generator { | ||
return new(ParkingGenerator) | ||
} | ||
|
||
type ParkingClient struct { | ||
ClientBase | ||
client pb.ParkingClient | ||
} | ||
|
||
func (c *ParkingClient) Init(ctx context.Context, ip, port string) error { | ||
log.Printf("Connect to: %s:%s\n", ip, port) | ||
err := c.Connect(ctx, ip, port) | ||
if err != nil { | ||
return err | ||
} | ||
c.client = pb.NewParkingClient(c.conn) | ||
return nil | ||
} | ||
|
||
func (c *ParkingClient) Request(ctx context.Context, req Input) (string, error) { | ||
|
||
r, err := c.client.DoParking(ctx, &pb.ParkingRequest{Name: req.Value}) | ||
if err != nil { | ||
return "", err | ||
} | ||
return r.GetResult(), nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
syntax = "proto3"; | ||
|
||
option go_package = "github.com/vhive-serverless/vSwarm-proto/proto/parking"; | ||
|
||
package parking; | ||
|
||
service Parking { | ||
rpc DoParking(ParkingRequest) returns (ParkingReply) {} | ||
} | ||
|
||
message ParkingRequest { | ||
string name = 1; | ||
} | ||
|
||
message ParkingReply { | ||
string result = 1; | ||
} |
Oops, something went wrong.