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

Add bert proto #59

Open
wants to merge 2 commits 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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.18
replace (
github.com/vhive-serverless/vSwarm-proto/proto/aes => ./proto/aes
github.com/vhive-serverless/vSwarm-proto/proto/auth => ./proto/auth
github.com/vhive-serverless/vSwarm-proto/proto/bert => ./proto/bert
github.com/vhive-serverless/vSwarm-proto/proto/fibonacci => ./proto/fibonacci
github.com/vhive-serverless/vSwarm-proto/proto/helloworld => ./proto/helloworld
github.com/vhive-serverless/vSwarm-proto/proto/hipstershop => ./proto/hipstershop
Expand Down
71 changes: 71 additions & 0 deletions grpcclient/bert_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// MIT License

// Copyright (c) 2022 EASE lab

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package grpcclient

import (
"context"
"fmt"

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

type BertGenerator struct {
GeneratorBase
}

func (g *BertGenerator) Next() Input {
var pkt = g.defaultInput
switch g.GeneratorBase.generator {
case Unique:
pkt.Value = "A unique message"
case Linear:
pkt.Value = "A linear message"
case Random:
pkt.Value = "random"
}
return pkt
}

func (c *BertClient) GetGenerator() Generator {
return new(BertGenerator)
}

type BertClient struct {
ClientBase
client pb.GreeterClient
}

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

func (c *BertClient) Request(ctx context.Context, req Input) string {
var bertMessage = req.Value
r, err := c.client.SayHello(ctx, &pb.HelloRequest{Name: bertMessage})
if err != nil {
log.Fatalf("could not greet: %v", err)
}
msg := fmt.Sprintf("inference time in ns: max: %d; min: %d; mean: %d", r.GetMaxLatency(),r.GetMinLatency(),r.GetMeanLatency())
return msg
}
26 changes: 26 additions & 0 deletions grpcclient/getclient.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
// MIT License

// Copyright (c) 2022 EASE lab

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
package grpcclient

import (
Expand All @@ -10,6 +31,8 @@ func FindServiceName(functionName string) string {
return "aes"
case "auth-go", "auth-python", "auth-nodejs":
return "auth"
case "bert-python":
return "bert"
case "fibonacci-go", "fibonacci-python", "fibonacci-nodejs", "fibonacci-cpp":
return "fibonacci"
default:
Expand All @@ -30,6 +53,9 @@ func FindGrpcClient(service_name string) GrpcClient {
case "auth":
log.Debug("Found Auth client")
return new(AuthClient)
case "bert":
log.Debug("Found Bert client")
return new(BertClient)
case "fibonacci":
log.Debug("Found Fibonacci client")
return new(FibonacciClient)
Expand Down
163 changes: 163 additions & 0 deletions proto/bert/bert.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions proto/bert/bert.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// MIT License

// Copyright (c) 2022 EASE lab

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

syntax = "proto3";

option go_package = "github.com/vhive-serverless/vSwarm-proto/proto/bert";

package bert;

// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}

// The request message containing the user's name.
message HelloRequest {
string name = 1;
}

// The response message containing the greetings
message HelloReply {
int64 min_latency = 1;
int64 max_latency = 2;
int64 mean_latency = 3;
}
Loading