pk/pb: add initial proto for the new contact endpoints (#2948)

* add init contact proto

* make 2 svcs

* add geenerated proto code

* fux conflict with NodeRequest name

* use correct version on proto

* rm extra node fields

* add protolock

* update field names so they are better

* rm node id since we dont need it
This commit is contained in:
Jess G 2019-09-04 10:07:06 -07:00 committed by GitHub
parent 05e9916b9c
commit f7bae57e5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 469 additions and 0 deletions

351
pkg/pb/contact.pb.go Normal file
View File

@ -0,0 +1,351 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: contact.proto
package pb
import (
context "context"
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
grpc "google.golang.org/grpc"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type CheckinRequest struct {
Address *NodeAddress `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
Capacity *NodeCapacity `protobuf:"bytes,3,opt,name=capacity,proto3" json:"capacity,omitempty"`
Operator *NodeOperator `protobuf:"bytes,4,opt,name=operator,proto3" json:"operator,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CheckinRequest) Reset() { *m = CheckinRequest{} }
func (m *CheckinRequest) String() string { return proto.CompactTextString(m) }
func (*CheckinRequest) ProtoMessage() {}
func (*CheckinRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_a5036fff2565fb15, []int{0}
}
func (m *CheckinRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CheckinRequest.Unmarshal(m, b)
}
func (m *CheckinRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CheckinRequest.Marshal(b, m, deterministic)
}
func (m *CheckinRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_CheckinRequest.Merge(m, src)
}
func (m *CheckinRequest) XXX_Size() int {
return xxx_messageInfo_CheckinRequest.Size(m)
}
func (m *CheckinRequest) XXX_DiscardUnknown() {
xxx_messageInfo_CheckinRequest.DiscardUnknown(m)
}
var xxx_messageInfo_CheckinRequest proto.InternalMessageInfo
func (m *CheckinRequest) GetAddress() *NodeAddress {
if m != nil {
return m.Address
}
return nil
}
func (m *CheckinRequest) GetCapacity() *NodeCapacity {
if m != nil {
return m.Capacity
}
return nil
}
func (m *CheckinRequest) GetOperator() *NodeOperator {
if m != nil {
return m.Operator
}
return nil
}
type CheckinResponse struct {
PingNodeSuccess bool `protobuf:"varint,1,opt,name=ping_node_success,json=pingNodeSuccess,proto3" json:"ping_node_success,omitempty"`
PingErrorMessage string `protobuf:"bytes,2,opt,name=ping_error_message,json=pingErrorMessage,proto3" json:"ping_error_message,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *CheckinResponse) Reset() { *m = CheckinResponse{} }
func (m *CheckinResponse) String() string { return proto.CompactTextString(m) }
func (*CheckinResponse) ProtoMessage() {}
func (*CheckinResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_a5036fff2565fb15, []int{1}
}
func (m *CheckinResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CheckinResponse.Unmarshal(m, b)
}
func (m *CheckinResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_CheckinResponse.Marshal(b, m, deterministic)
}
func (m *CheckinResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_CheckinResponse.Merge(m, src)
}
func (m *CheckinResponse) XXX_Size() int {
return xxx_messageInfo_CheckinResponse.Size(m)
}
func (m *CheckinResponse) XXX_DiscardUnknown() {
xxx_messageInfo_CheckinResponse.DiscardUnknown(m)
}
var xxx_messageInfo_CheckinResponse proto.InternalMessageInfo
func (m *CheckinResponse) GetPingNodeSuccess() bool {
if m != nil {
return m.PingNodeSuccess
}
return false
}
func (m *CheckinResponse) GetPingErrorMessage() string {
if m != nil {
return m.PingErrorMessage
}
return ""
}
type ContactPingRequest struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ContactPingRequest) Reset() { *m = ContactPingRequest{} }
func (m *ContactPingRequest) String() string { return proto.CompactTextString(m) }
func (*ContactPingRequest) ProtoMessage() {}
func (*ContactPingRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_a5036fff2565fb15, []int{2}
}
func (m *ContactPingRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ContactPingRequest.Unmarshal(m, b)
}
func (m *ContactPingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ContactPingRequest.Marshal(b, m, deterministic)
}
func (m *ContactPingRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContactPingRequest.Merge(m, src)
}
func (m *ContactPingRequest) XXX_Size() int {
return xxx_messageInfo_ContactPingRequest.Size(m)
}
func (m *ContactPingRequest) XXX_DiscardUnknown() {
xxx_messageInfo_ContactPingRequest.DiscardUnknown(m)
}
var xxx_messageInfo_ContactPingRequest proto.InternalMessageInfo
type ContactPingResponse struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ContactPingResponse) Reset() { *m = ContactPingResponse{} }
func (m *ContactPingResponse) String() string { return proto.CompactTextString(m) }
func (*ContactPingResponse) ProtoMessage() {}
func (*ContactPingResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_a5036fff2565fb15, []int{3}
}
func (m *ContactPingResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ContactPingResponse.Unmarshal(m, b)
}
func (m *ContactPingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ContactPingResponse.Marshal(b, m, deterministic)
}
func (m *ContactPingResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContactPingResponse.Merge(m, src)
}
func (m *ContactPingResponse) XXX_Size() int {
return xxx_messageInfo_ContactPingResponse.Size(m)
}
func (m *ContactPingResponse) XXX_DiscardUnknown() {
xxx_messageInfo_ContactPingResponse.DiscardUnknown(m)
}
var xxx_messageInfo_ContactPingResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*CheckinRequest)(nil), "contact.CheckinRequest")
proto.RegisterType((*CheckinResponse)(nil), "contact.CheckinResponse")
proto.RegisterType((*ContactPingRequest)(nil), "contact.ContactPingRequest")
proto.RegisterType((*ContactPingResponse)(nil), "contact.ContactPingResponse")
}
func init() { proto.RegisterFile("contact.proto", fileDescriptor_a5036fff2565fb15) }
var fileDescriptor_a5036fff2565fb15 = []byte{
// 292 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xb1, 0x4e, 0xc3, 0x30,
0x10, 0x86, 0x95, 0x12, 0x91, 0x70, 0x08, 0x4a, 0x0d, 0x88, 0x28, 0x30, 0x54, 0x99, 0x2a, 0x40,
0x19, 0xca, 0xca, 0x02, 0xa1, 0x23, 0x10, 0x99, 0x8d, 0x25, 0x72, 0x1d, 0x2b, 0x44, 0x15, 0xb6,
0xb1, 0xdd, 0x81, 0x87, 0xe1, 0x5d, 0x91, 0x63, 0x27, 0x55, 0x29, 0x63, 0xff, 0xef, 0xbb, 0xbf,
0x97, 0x33, 0x1c, 0x51, 0xc1, 0x0d, 0xa1, 0x26, 0x97, 0x4a, 0x18, 0x81, 0x22, 0xff, 0x33, 0x05,
0x2e, 0x6a, 0xe6, 0xc2, 0xec, 0x27, 0x80, 0xe3, 0xe2, 0x83, 0xd1, 0x55, 0xcb, 0x31, 0xfb, 0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00, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xc7, 0x98, 0x61,
0x04, 0x02, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// ContactClient is the client API for Contact service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ContactClient interface {
PingNode(ctx context.Context, in *ContactPingRequest, opts ...grpc.CallOption) (*ContactPingResponse, error)
}
type contactClient struct {
cc *grpc.ClientConn
}
func NewContactClient(cc *grpc.ClientConn) ContactClient {
return &contactClient{cc}
}
func (c *contactClient) PingNode(ctx context.Context, in *ContactPingRequest, opts ...grpc.CallOption) (*ContactPingResponse, error) {
out := new(ContactPingResponse)
err := c.cc.Invoke(ctx, "/contact.Contact/PingNode", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ContactServer is the server API for Contact service.
type ContactServer interface {
PingNode(context.Context, *ContactPingRequest) (*ContactPingResponse, error)
}
func RegisterContactServer(s *grpc.Server, srv ContactServer) {
s.RegisterService(&_Contact_serviceDesc, srv)
}
func _Contact_PingNode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ContactPingRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ContactServer).PingNode(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/contact.Contact/PingNode",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ContactServer).PingNode(ctx, req.(*ContactPingRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Contact_serviceDesc = grpc.ServiceDesc{
ServiceName: "contact.Contact",
HandlerType: (*ContactServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "PingNode",
Handler: _Contact_PingNode_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "contact.proto",
}
// NodeClient is the client API for Node service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type NodeClient interface {
Checkin(ctx context.Context, in *CheckinRequest, opts ...grpc.CallOption) (*CheckinResponse, error)
}
type nodeClient struct {
cc *grpc.ClientConn
}
func NewNodeClient(cc *grpc.ClientConn) NodeClient {
return &nodeClient{cc}
}
func (c *nodeClient) Checkin(ctx context.Context, in *CheckinRequest, opts ...grpc.CallOption) (*CheckinResponse, error) {
out := new(CheckinResponse)
err := c.cc.Invoke(ctx, "/contact.Node/Checkin", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// NodeServer is the server API for Node service.
type NodeServer interface {
Checkin(context.Context, *CheckinRequest) (*CheckinResponse, error)
}
func RegisterNodeServer(s *grpc.Server, srv NodeServer) {
s.RegisterService(&_Node_serviceDesc, srv)
}
func _Node_Checkin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CheckinRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NodeServer).Checkin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/contact.Node/Checkin",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NodeServer).Checkin(ctx, req.(*CheckinRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Node_serviceDesc = grpc.ServiceDesc{
ServiceName: "contact.Node",
HandlerType: (*NodeServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Checkin",
Handler: _Node_Checkin_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "contact.proto",
}

34
pkg/pb/contact.proto Normal file
View File

@ -0,0 +1,34 @@
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
syntax = "proto3";
option go_package = "pb";
package contact;
import "node.proto";
service Contact {
rpc PingNode(ContactPingRequest) returns (ContactPingResponse);
}
service Node {
rpc Checkin(CheckinRequest) returns (CheckinResponse);
}
message CheckinRequest {
node.NodeAddress address = 1;
node.NodeCapacity capacity = 3;
node.NodeOperator operator = 4;
}
message CheckinResponse {
bool ping_node_success = 1;
string ping_error_message = 2;
}
message ContactPingRequest {
}
message ContactPingResponse {
}

View File

@ -152,6 +152,90 @@
]
}
},
{
"protopath": "pkg:/:pb:/:contact.proto",
"def": {
"messages": [
{
"name": "CheckinRequest",
"fields": [
{
"id": 1,
"name": "address",
"type": "node.NodeAddress"
},
{
"id": 3,
"name": "capacity",
"type": "node.NodeCapacity"
},
{
"id": 4,
"name": "operator",
"type": "node.NodeOperator"
}
]
},
{
"name": "CheckinResponse",
"fields": [
{
"id": 1,
"name": "ping_node_success",
"type": "bool"
},
{
"id": 2,
"name": "ping_error_message",
"type": "string"
}
]
},
{
"name": "ContactPingRequest"
},
{
"name": "ContactPingResponse"
}
],
"services": [
{
"name": "Contact",
"rpcs": [
{
"name": "PingNode",
"in_type": "ContactPingRequest",
"out_type": "ContactPingResponse"
}
]
},
{
"name": "Node",
"rpcs": [
{
"name": "Checkin",
"in_type": "CheckinRequest",
"out_type": "CheckinResponse"
}
]
}
],
"imports": [
{
"path": "node.proto"
}
],
"package": {
"name": "contact"
},
"options": [
{
"name": "go_package",
"value": "pb"
}
]
}
},
{
"protopath": "pkg:/:pb:/:datarepair.proto",
"def": {