Migrate to gRPC rather than REST with swagger
Will also be adding in a RESTful endpoint to the server as well so it can consume both types
This commit is contained in:
parent
b815284199
commit
7ababb79f6
23 changed files with 1110 additions and 1101 deletions
|
@ -67,9 +67,6 @@ func (m *RegisterInfo) GetName() string {
|
|||
|
||||
// RegisterResponse is the response information from registering an account
|
||||
type RegisterResponse struct {
|
||||
// The error value should only be populated if success is false
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
|
@ -100,20 +97,6 @@ func (m *RegisterResponse) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_RegisterResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *RegisterResponse) GetSuccess() bool {
|
||||
if m != nil {
|
||||
return m.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *RegisterResponse) GetError() string {
|
||||
if m != nil {
|
||||
return m.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// DataKeyValue represents a simple key value pair to assign to an account
|
||||
type DataKeyValue struct {
|
||||
// The account to assign the new key value pair to
|
||||
|
@ -172,54 +155,37 @@ func (m *DataKeyValue) GetValue() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
// Response is a simple response with success and error
|
||||
type Response struct {
|
||||
// error should only be populated if success is false
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
|
||||
// DataKeyResponse is a simple response
|
||||
type DataKeyResponse struct {
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Response) Reset() { *m = Response{} }
|
||||
func (m *Response) String() string { return proto.CompactTextString(m) }
|
||||
func (*Response) ProtoMessage() {}
|
||||
func (*Response) Descriptor() ([]byte, []int) {
|
||||
func (m *DataKeyResponse) Reset() { *m = DataKeyResponse{} }
|
||||
func (m *DataKeyResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DataKeyResponse) ProtoMessage() {}
|
||||
func (*DataKeyResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e1e7723af4c007b7, []int{3}
|
||||
}
|
||||
|
||||
func (m *Response) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Response.Unmarshal(m, b)
|
||||
func (m *DataKeyResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DataKeyResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Response.Marshal(b, m, deterministic)
|
||||
func (m *DataKeyResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DataKeyResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Response) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Response.Merge(m, src)
|
||||
func (m *DataKeyResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DataKeyResponse.Merge(m, src)
|
||||
}
|
||||
func (m *Response) XXX_Size() int {
|
||||
return xxx_messageInfo_Response.Size(m)
|
||||
func (m *DataKeyResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_DataKeyResponse.Size(m)
|
||||
}
|
||||
func (m *Response) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Response.DiscardUnknown(m)
|
||||
func (m *DataKeyResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DataKeyResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Response proto.InternalMessageInfo
|
||||
|
||||
func (m *Response) GetSuccess() bool {
|
||||
if m != nil {
|
||||
return m.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *Response) GetError() string {
|
||||
if m != nil {
|
||||
return m.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
var xxx_messageInfo_DataKeyResponse proto.InternalMessageInfo
|
||||
|
||||
// DataKey describes a simple key value with an account, for fetching
|
||||
type DataKey struct {
|
||||
|
@ -273,9 +239,6 @@ func (m *DataKey) GetKey() string {
|
|||
|
||||
// DataResponse describes a data fetch response
|
||||
type DataResponse struct {
|
||||
// error should only be populated if success is false
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
|
||||
// The value of the key
|
||||
Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
|
@ -308,20 +271,6 @@ func (m *DataResponse) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_DataResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *DataResponse) GetSuccess() bool {
|
||||
if m != nil {
|
||||
return m.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *DataResponse) GetError() string {
|
||||
if m != nil {
|
||||
return m.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *DataResponse) GetValue() string {
|
||||
if m != nil {
|
||||
return m.Value
|
||||
|
@ -333,7 +282,7 @@ func init() {
|
|||
proto.RegisterType((*RegisterInfo)(nil), "accounts.RegisterInfo")
|
||||
proto.RegisterType((*RegisterResponse)(nil), "accounts.RegisterResponse")
|
||||
proto.RegisterType((*DataKeyValue)(nil), "accounts.DataKeyValue")
|
||||
proto.RegisterType((*Response)(nil), "accounts.Response")
|
||||
proto.RegisterType((*DataKeyResponse)(nil), "accounts.DataKeyResponse")
|
||||
proto.RegisterType((*DataKey)(nil), "accounts.DataKey")
|
||||
proto.RegisterType((*DataResponse)(nil), "accounts.DataResponse")
|
||||
}
|
||||
|
@ -343,26 +292,25 @@ func init() {
|
|||
}
|
||||
|
||||
var fileDescriptor_e1e7723af4c007b7 = []byte{
|
||||
// 298 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x4f, 0x4b, 0xc3, 0x40,
|
||||
0x10, 0xc5, 0x8d, 0x55, 0x1b, 0xc7, 0x22, 0x75, 0x11, 0x09, 0x39, 0xc9, 0x8a, 0xe0, 0x29, 0x01,
|
||||
0x45, 0x04, 0xbd, 0xd8, 0x22, 0x88, 0x78, 0x91, 0x20, 0x1e, 0xbc, 0x6d, 0xe3, 0x18, 0x43, 0x9b,
|
||||
0xdd, 0xb0, 0x7f, 0x0a, 0xf5, 0xf3, 0xf9, 0xc1, 0x24, 0xbb, 0xd9, 0x1a, 0xac, 0x17, 0x7b, 0xdb,
|
||||
0x17, 0xe6, 0xf7, 0xe6, 0xcd, 0x4c, 0x60, 0x9f, 0xe5, 0xb9, 0x30, 0x5c, 0xab, 0xa4, 0x96, 0x42,
|
||||
0x0b, 0x12, 0x7a, 0x4d, 0x29, 0x0c, 0x32, 0x2c, 0x4a, 0xa5, 0x51, 0x3e, 0xf0, 0x77, 0x41, 0x08,
|
||||
0x6c, 0x71, 0x56, 0x61, 0x14, 0x1c, 0x07, 0x67, 0xbb, 0x99, 0x7d, 0xd3, 0x31, 0x0c, 0x7d, 0x4d,
|
||||
0x86, 0xaa, 0x16, 0x5c, 0x21, 0x89, 0xa0, 0xaf, 0x4c, 0x9e, 0xa3, 0x52, 0xb6, 0x34, 0xcc, 0xbc,
|
||||
0x24, 0x87, 0xb0, 0x8d, 0x52, 0x0a, 0x19, 0x6d, 0x5a, 0x0b, 0x27, 0xe8, 0x13, 0x0c, 0xee, 0x98,
|
||||
0x66, 0x8f, 0xb8, 0x78, 0x61, 0x33, 0x63, 0xf9, 0x36, 0x43, 0xdb, 0xca, 0x4b, 0x32, 0x84, 0xde,
|
||||
0x14, 0x17, 0x2d, 0xdd, 0x3c, 0x1b, 0xc7, 0x79, 0x03, 0x45, 0x3d, 0xe7, 0x68, 0x05, 0xbd, 0x86,
|
||||
0x70, 0xed, 0x34, 0x97, 0xd0, 0x6f, 0xd3, 0xfc, 0x27, 0x08, 0x7d, 0x76, 0x43, 0xac, 0xdb, 0xf6,
|
||||
0xef, 0x41, 0xce, 0xbf, 0x02, 0x80, 0x91, 0xeb, 0xc9, 0xb8, 0x26, 0xb7, 0xcd, 0x5c, 0x6e, 0xdb,
|
||||
0xe4, 0x28, 0x59, 0x1e, 0xae, 0x7b, 0xa5, 0x38, 0x5e, 0xfd, 0xee, 0x43, 0xd1, 0x0d, 0x72, 0x03,
|
||||
0x7b, 0x23, 0xa5, 0xca, 0x82, 0xbb, 0x55, 0x77, 0x4c, 0xba, 0x27, 0x88, 0x49, 0xd7, 0x64, 0x09,
|
||||
0x5f, 0x41, 0x78, 0x8f, 0xda, 0x91, 0x07, 0x2b, 0x64, 0xfc, 0xcb, 0xec, 0x07, 0x1c, 0x9f, 0xbe,
|
||||
0x9e, 0x14, 0xa5, 0xfe, 0x30, 0x93, 0x24, 0x17, 0x55, 0x5a, 0xbd, 0x95, 0x33, 0xf3, 0x99, 0x4a,
|
||||
0x31, 0xc7, 0xb4, 0x9e, 0x16, 0xa9, 0xa7, 0x26, 0x3b, 0xf6, 0x0f, 0xbc, 0xf8, 0x0e, 0x00, 0x00,
|
||||
0xff, 0xff, 0xef, 0x53, 0xc6, 0xba, 0x93, 0x02, 0x00, 0x00,
|
||||
// 276 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0x41, 0x4b, 0xc3, 0x40,
|
||||
0x10, 0x85, 0x8d, 0x55, 0x1b, 0xc7, 0xa2, 0xed, 0x20, 0x12,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 0xe1, 0x0c, 0x0e, 0xa6, 0x4a, 0xa5, 0x89, 0x30, 0x89,
|
||||
0x74, 0x20, 0xdd, 0xa4, 0xfc, 0xd3, 0x9e, 0xde, 0x61, 0xdc, 0x81, 0xfb, 0x48, 0xda, 0x00, 0x26,
|
||||
0xbd, 0x41, 0xff, 0x0f, 0xf3, 0xd7, 0x38, 0xbb, 0x7c, 0x3b, 0x4f, 0x52, 0xfd, 0x59, 0xce, 0x83,
|
||||
0x58, 0x66, 0x61, 0xf6, 0x9e, 0x2e, 0xcb, 0xaf, 0xb0, 0x90, 0x2b, 0x0a, 0xf3, 0x45, 0x12, 0x5a,
|
||||
0xd7, 0x7c, 0xaf, 0xfe, 0xff, 0x9b, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x22, 0x35, 0x31, 0x6f,
|
||||
0x11, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
@ -381,7 +329,7 @@ type AccountantClient interface {
|
|||
// It will return an error if the account already exists
|
||||
Register(ctx context.Context, in *RegisterInfo, opts ...grpc.CallOption) (*RegisterResponse, error)
|
||||
// AssignValue assigns a key-value pair to an account, or overwrites an existing key
|
||||
AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*Response, error)
|
||||
AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*DataKeyResponse, error)
|
||||
// GetValue will get the value for a key for an account
|
||||
GetValue(ctx context.Context, in *DataKey, opts ...grpc.CallOption) (*DataResponse, error)
|
||||
}
|
||||
|
@ -403,8 +351,8 @@ func (c *accountantClient) Register(ctx context.Context, in *RegisterInfo, opts
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *accountantClient) AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*Response, error) {
|
||||
out := new(Response)
|
||||
func (c *accountantClient) AssignValue(ctx context.Context, in *DataKeyValue, opts ...grpc.CallOption) (*DataKeyResponse, error) {
|
||||
out := new(DataKeyResponse)
|
||||
err := c.cc.Invoke(ctx, "/accounts.Accountant/AssignValue", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -427,7 +375,7 @@ type AccountantServer interface {
|
|||
// It will return an error if the account already exists
|
||||
Register(context.Context, *RegisterInfo) (*RegisterResponse, error)
|
||||
// AssignValue assigns a key-value pair to an account, or overwrites an existing key
|
||||
AssignValue(context.Context, *DataKeyValue) (*Response, error)
|
||||
AssignValue(context.Context, *DataKeyValue) (*DataKeyResponse, error)
|
||||
// GetValue will get the value for a key for an account
|
||||
GetValue(context.Context, *DataKey) (*DataResponse, error)
|
||||
}
|
||||
|
@ -439,7 +387,7 @@ type UnimplementedAccountantServer struct {
|
|||
func (*UnimplementedAccountantServer) Register(ctx context.Context, req *RegisterInfo) (*RegisterResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
|
||||
}
|
||||
func (*UnimplementedAccountantServer) AssignValue(ctx context.Context, req *DataKeyValue) (*Response, error) {
|
||||
func (*UnimplementedAccountantServer) AssignValue(ctx context.Context, req *DataKeyValue) (*DataKeyResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AssignValue not implemented")
|
||||
}
|
||||
func (*UnimplementedAccountantServer) GetValue(ctx context.Context, req *DataKey) (*DataResponse, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue