Checkpoint networking code

This commit is contained in:
Asim Aslam
2019-07-01 11:55:15 +01:00
parent d8e998ad85
commit 0899282277
5 changed files with 895 additions and 23 deletions

View File

@@ -0,0 +1,21 @@
// Code generated by protoc-gen-micro. DO NOT EDIT.
// source: micro/go-micro/network/proto/network.proto
package go_micro_network
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
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.ProtoPackageIsVersion3 // please upgrade the proto package

197
network/proto/network.pb.go Normal file
View File

@@ -0,0 +1,197 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: micro/go-micro/network/proto/network.proto
package go_micro_network
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
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.ProtoPackageIsVersion3 // please upgrade the proto package
// A connect message is for connecting to the network
type Connect struct {
// Lease specifies an existing lease to indicate
// we don't need a new address, we just want to
// establish a link.
Lease *Lease `protobuf:"bytes,1,opt,name=lease,proto3" json:"lease,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Connect) Reset() { *m = Connect{} }
func (m *Connect) String() string { return proto.CompactTextString(m) }
func (*Connect) ProtoMessage() {}
func (*Connect) Descriptor() ([]byte, []int) {
return fileDescriptor_4daa91d05ddc28b6, []int{0}
}
func (m *Connect) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Connect.Unmarshal(m, b)
}
func (m *Connect) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Connect.Marshal(b, m, deterministic)
}
func (m *Connect) XXX_Merge(src proto.Message) {
xxx_messageInfo_Connect.Merge(m, src)
}
func (m *Connect) XXX_Size() int {
return xxx_messageInfo_Connect.Size(m)
}
func (m *Connect) XXX_DiscardUnknown() {
xxx_messageInfo_Connect.DiscardUnknown(m)
}
var xxx_messageInfo_Connect proto.InternalMessageInfo
func (m *Connect) GetLease() *Lease {
if m != nil {
return m.Lease
}
return nil
}
// A lease is returned to anyone attempting to connect.
type Lease struct {
// unique lease id
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// timestamp of lease
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// the node
Node *Node `protobuf:"bytes,3,opt,name=node,proto3" json:"node,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Lease) Reset() { *m = Lease{} }
func (m *Lease) String() string { return proto.CompactTextString(m) }
func (*Lease) ProtoMessage() {}
func (*Lease) Descriptor() ([]byte, []int) {
return fileDescriptor_4daa91d05ddc28b6, []int{1}
}
func (m *Lease) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Lease.Unmarshal(m, b)
}
func (m *Lease) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Lease.Marshal(b, m, deterministic)
}
func (m *Lease) XXX_Merge(src proto.Message) {
xxx_messageInfo_Lease.Merge(m, src)
}
func (m *Lease) XXX_Size() int {
return xxx_messageInfo_Lease.Size(m)
}
func (m *Lease) XXX_DiscardUnknown() {
xxx_messageInfo_Lease.DiscardUnknown(m)
}
var xxx_messageInfo_Lease proto.InternalMessageInfo
func (m *Lease) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func (m *Lease) GetTimestamp() int64 {
if m != nil {
return m.Timestamp
}
return 0
}
func (m *Lease) GetNode() *Node {
if m != nil {
return m.Node
}
return nil
}
// A node is the network node
type Node struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Node) Reset() { *m = Node{} }
func (m *Node) String() string { return proto.CompactTextString(m) }
func (*Node) ProtoMessage() {}
func (*Node) Descriptor() ([]byte, []int) {
return fileDescriptor_4daa91d05ddc28b6, []int{2}
}
func (m *Node) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Node.Unmarshal(m, b)
}
func (m *Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Node.Marshal(b, m, deterministic)
}
func (m *Node) XXX_Merge(src proto.Message) {
xxx_messageInfo_Node.Merge(m, src)
}
func (m *Node) XXX_Size() int {
return xxx_messageInfo_Node.Size(m)
}
func (m *Node) XXX_DiscardUnknown() {
xxx_messageInfo_Node.DiscardUnknown(m)
}
var xxx_messageInfo_Node proto.InternalMessageInfo
func (m *Node) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func (m *Node) GetAddress() string {
if m != nil {
return m.Address
}
return ""
}
func init() {
proto.RegisterType((*Connect)(nil), "go.micro.network.Connect")
proto.RegisterType((*Lease)(nil), "go.micro.network.Lease")
proto.RegisterType((*Node)(nil), "go.micro.network.Node")
}
func init() {
proto.RegisterFile("micro/go-micro/network/proto/network.proto", fileDescriptor_4daa91d05ddc28b6)
}
var fileDescriptor_4daa91d05ddc28b6 = []byte{
// 192 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x8f, 0x3d, 0x4b, 0xc0, 0x30,
0x10, 0x86, 0xe9, 0x97, 0xa5, 0x27, 0x88, 0x64, 0xd0, 0x0c, 0x0e, 0xa5, 0x53, 0x29, 0x34, 0x15,
0x5d, 0xdc, 0x5d, 0xc5, 0x21, 0xff, 0x20, 0x36, 0x47, 0x09, 0xda, 0x5c, 0x49, 0x02, 0xfe, 0x7d,
0xe9, 0xd5, 0x0f, 0xb0, 0x5b, 0x9e, 0x37, 0xcf, 0xdd, 0xcb, 0xc1, 0xb0, 0xba, 0x39, 0xd0, 0xb4,
0xd0, 0x78, 0x3c, 0x3c, 0xa6, 0x4f, 0x0a, 0xef, 0xd3, 0x16, 0x28, 0xfd, 0x92, 0x62, 0x12, 0xd7,
0x0b, 0x29, 0xb6, 0xd4, 0x77, 0xde, 0x3d, 0x41, 0xfd, 0x4c, 0xde, 0xe3, 0x9c, 0xc4, 0x08, 0xd5,
0x07, 0x9a, 0x88, 0x32, 0x6b, 0xb3, 0xfe, 0xf2, 0xe1, 0x56, 0xfd, 0x97, 0xd5, 0xcb, 0xfe, 0xad,
0x0f, 0xab, 0x33, 0x50, 0x31, 0x8b, 0x2b, 0xc8, 0x9d, 0xe5, 0xa1, 0x46, 0xe7, 0xce, 0x8a, 0x3b,
0x68, 0x92, 0x5b, 0x31, 0x26, 0xb3, 0x6e, 0x32, 0x6f, 0xb3, 0xbe, 0xd0, 0x7f, 0x81, 0x18, 0xa0,
0xf4, 0x64, 0x51, 0x16, 0x5c, 0x72, 0x73, 0x2e, 0x79, 0x25, 0x8b, 0x9a, 0x9d, 0xee, 0x1e, 0xca,
0x9d, 0x4e, 0x0d, 0x12, 0x6a, 0x63, 0x6d, 0xc0, 0x18, 0x79, 0x7f, 0xa3, 0x7f, 0xf0, 0xed, 0x82,
0xef, 0x7c, 0xfc, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x48, 0x8c, 0x11, 0x91, 0x15, 0x01, 0x00, 0x00,
}

View File

@@ -0,0 +1,27 @@
syntax = "proto3";
package go.micro.network;
// A connect message is for connecting to the network
message Connect {
// Lease specifies an existing lease to indicate
// we don't need a new address, we just want to
// establish a link.
Lease lease = 1;
}
// A lease is returned to anyone attempting to connect.
message Lease {
// unique lease id
string id = 1;
// timestamp of lease
int64 timestamp = 2;
// the node
Node node = 3;
}
// A node is the network node
message Node {
string id = 1;
string address = 2;
}