-
Notifications
You must be signed in to change notification settings - Fork 0
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: sukhman-sukh <[email protected]>
- Loading branch information
1 parent
61130f9
commit 33ab052
Showing
6 changed files
with
1,015 additions
and
15 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,69 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"github.com/sdslabs/pinger/pkg/protobuf/pb" | ||
"google.golang.org/grpc" | ||
"net" | ||
) | ||
|
||
type server struct { | ||
pb.AlterServicesServer | ||
} | ||
|
||
func (s *server) CreateCheckService(ctx context.Context, req *pb.CreateCheckRequest) (*pb.Response, error) { | ||
if req.Check != "" { | ||
return &pb.Response{Response: "gRPC Code 0 : OK "}, nil | ||
} | ||
return nil, errors.New("Inavlid request") | ||
} | ||
|
||
func (s *server) DeleteCheckService(ctx context.Context, req *pb.DeleteCheckRequest) (*pb.Response, error) { | ||
if req.UserId != "" { | ||
return &pb.Response{Response: "gRPC Code 0 : OK "}, nil | ||
} | ||
return nil, errors.New("Inavlid request") | ||
} | ||
|
||
func (s *server) UpdateCheckService(ctx context.Context, req *pb.UpdateCheckRequest) (*pb.Response, error) { | ||
if req.UserId != "" { | ||
return &pb.Response{Response: "gRPC Code 0 : OK "}, nil | ||
} | ||
return nil, errors.New("Inavlid request") | ||
} | ||
|
||
func (s *server) CreatePageService(ctx context.Context, req *pb.CreatePageRequest) (*pb.Response, error) { | ||
if req.NewPageString != "" { | ||
return &pb.Response{Response: "gRPC Code 0 : OK "}, nil | ||
} | ||
return nil, errors.New("Inavlid request") | ||
} | ||
|
||
func (s *server) DeletePageService(ctx context.Context, req *pb.DeletePageRequest) (*pb.Response, error) { | ||
if req.PageId != "" { | ||
return &pb.Response{Response: "gRPC Code 0 : OK "}, nil | ||
} | ||
return nil, errors.New("Inavlid request") | ||
} | ||
|
||
func (s *server) UpdatePageService(ctx context.Context, req *pb.UpdatePageRequest) (*pb.Response, error) { | ||
if req.PageId != "" { | ||
return &pb.Response{Response: "gRPC Code 0 : OK "}, nil | ||
} | ||
return nil, errors.New("Inavlid request") | ||
} | ||
|
||
func main() { | ||
lis, err := net.Listen("tcp", ":5000") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
grpcServer := grpc.NewServer() | ||
pb.RegisterAlterServicesServer(grpcServer, &server{}) | ||
if err := grpcServer.Serve(lis); err != nil { | ||
panic(err) | ||
} | ||
grpcServer.Serve(lis) | ||
} |
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,40 @@ | ||
syntax = "proto3"; | ||
|
||
package alter; | ||
|
||
option go_package = "/pb"; | ||
|
||
message CreateCheckRequest { | ||
string Check = 1; | ||
string PageId = 2; | ||
} | ||
|
||
message DeleteCheckRequest { | ||
string UserId = 1; | ||
string CheckId = 2; | ||
string Role = 3; | ||
} | ||
|
||
message UpdateCheckRequest { | ||
string CheckId = 1; | ||
string UpdateCheckString = 2; | ||
string UserId = 3; | ||
string Role = 4; | ||
} | ||
|
||
message CreatePageRequest { string NewPageString = 1; } | ||
|
||
message DeletePageRequest { string PageId = 1; } | ||
|
||
message UpdatePageRequest { string PageId = 1; } | ||
|
||
message Response { string Response = 1; } | ||
|
||
service AlterServices { | ||
rpc CreateCheckService(CreateCheckRequest) returns (Response) {} | ||
rpc DeleteCheckService(DeleteCheckRequest) returns (Response) {} | ||
rpc UpdateCheckService(UpdateCheckRequest) returns (Response) {} | ||
rpc CreatePageService(CreatePageRequest) returns (Response) {} | ||
rpc DeletePageService(DeletePageRequest) returns (Response) {} | ||
rpc UpdatePageService(UpdatePageRequest) returns (Response) {} | ||
} |
Oops, something went wrong.