networkdb

package
v0.0.0-...-a79519d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2018 License: Apache-2.0, Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package networkdb is a generated protocol buffer package.

It is generated from these files:

networkdb.proto

It has these top-level messages:

GossipMessage
NodeEvent
NetworkEvent
NetworkEntry
NetworkPushPull
TableEvent
BulkSyncMessage
CompoundMessage

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthNetworkdb = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowNetworkdb   = fmt.Errorf("proto: integer overflow")
)
View Source
var MessageType_name = map[int32]string{
	0: "INVALID",
	1: "NETWORK_EVENT",
	2: "TABLE_EVENT",
	3: "PUSH_PULL",
	4: "BULK_SYNC",
	5: "COMPOUND",
	6: "NODE_EVENT",
}
View Source
var MessageType_value = map[string]int32{
	"INVALID":       0,
	"NETWORK_EVENT": 1,
	"TABLE_EVENT":   2,
	"PUSH_PULL":     3,
	"BULK_SYNC":     4,
	"COMPOUND":      5,
	"NODE_EVENT":    6,
}
View Source
var NetworkEvent_Type_name = map[int32]string{
	0: "INVALID",
	1: "JOIN",
	2: "LEAVE",
}
View Source
var NetworkEvent_Type_value = map[string]int32{
	"INVALID": 0,
	"JOIN":    1,
	"LEAVE":   2,
}
View Source
var NodeEvent_Type_name = map[int32]string{
	0: "INVALID",
	1: "JOIN",
	2: "LEAVE",
}
View Source
var NodeEvent_Type_value = map[string]int32{
	"INVALID": 0,
	"JOIN":    1,
	"LEAVE":   2,
}
View Source
var TableEvent_Type_name = map[int32]string{
	0: "INVALID",
	1: "CREATE",
	2: "UPDATE",
	3: "DELETE",
}
View Source
var TableEvent_Type_value = map[string]int32{
	"INVALID": 0,
	"CREATE":  1,
	"UPDATE":  2,
	"DELETE":  3,
}

Functions

This section is empty.

Types

type BulkSyncMessage

type BulkSyncMessage struct {
	// Lamport time when this bulk sync was initiated.
	LTime github_com_hashicorp_serf_serf.LamportTime `protobuf:"varint,1,opt,name=l_time,json=lTime,proto3,customtype=github.com/hashicorp/serf/serf.LamportTime" json:"l_time"`
	// Indicates if this bulksync is a response to a bulk sync
	// request from a peer node.
	Unsolicited bool `protobuf:"varint,2,opt,name=unsolicited,proto3" json:"unsolicited,omitempty"`
	// Name of the node which is producing this bulk sync message.
	NodeName string `protobuf:"bytes,3,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
	// List of network names whose table entries are getting
	// bulksynced as part of the bulksync.
	Networks []string `protobuf:"bytes,4,rep,name=networks" json:"networks,omitempty"`
	// Bulksync payload
	Payload []byte `protobuf:"bytes,5,opt,name=payload,proto3" json:"payload,omitempty"`
}

BulkSync message payload definition.

func (*BulkSyncMessage) Descriptor

func (*BulkSyncMessage) Descriptor() ([]byte, []int)

func (*BulkSyncMessage) GoString

func (this *BulkSyncMessage) GoString() string

func (*BulkSyncMessage) Marshal

func (m *BulkSyncMessage) Marshal() (data []byte, err error)

func (*BulkSyncMessage) MarshalTo

func (m *BulkSyncMessage) MarshalTo(data []byte) (int, error)

func (*BulkSyncMessage) ProtoMessage

func (*BulkSyncMessage) ProtoMessage()

func (*BulkSyncMessage) Reset

func (m *BulkSyncMessage) Reset()

func (*BulkSyncMessage) Size

func (m *BulkSyncMessage) Size() (n int)

func (*BulkSyncMessage) String

func (this *BulkSyncMessage) String() string

func (*BulkSyncMessage) Unmarshal

func (m *BulkSyncMessage) Unmarshal(data []byte) error

type CompoundMessage

type CompoundMessage struct {
	// A list of simple messages.
	Messages []*CompoundMessage_SimpleMessage `protobuf:"bytes,1,rep,name=messages" json:"messages,omitempty"`
}

Compound message payload definition.

func (*CompoundMessage) Descriptor

func (*CompoundMessage) Descriptor() ([]byte, []int)

func (*CompoundMessage) GetMessages

func (m *CompoundMessage) GetMessages() []*CompoundMessage_SimpleMessage

func (*CompoundMessage) GoString

func (this *CompoundMessage) GoString() string

func (*CompoundMessage) Marshal

func (m *CompoundMessage) Marshal() (data []byte, err error)

func (*CompoundMessage) MarshalTo

func (m *CompoundMessage) MarshalTo(data []byte) (int, error)

func (*CompoundMessage) ProtoMessage

func (*CompoundMessage) ProtoMessage()

func (*CompoundMessage) Reset

func (m *CompoundMessage) Reset()

func (*CompoundMessage) Size

func (m *CompoundMessage) Size() (n int)

func (*CompoundMessage) String

func (this *CompoundMessage) String() string

func (*CompoundMessage) Unmarshal

func (m *CompoundMessage) Unmarshal(data []byte) error

type CompoundMessage_SimpleMessage

type CompoundMessage_SimpleMessage struct {
	// Bytestring payload of a message constructed using
	// other message type definitions.
	Payload []byte `protobuf:"bytes,1,opt,name=Payload,json=payload,proto3" json:"Payload,omitempty"`
}

func (*CompoundMessage_SimpleMessage) Descriptor

func (*CompoundMessage_SimpleMessage) Descriptor() ([]byte, []int)

func (*CompoundMessage_SimpleMessage) GoString

func (this *CompoundMessage_SimpleMessage) GoString() string

func (*CompoundMessage_SimpleMessage) Marshal

func (m *CompoundMessage_SimpleMessage) Marshal() (data []byte, err error)

func (*CompoundMessage_SimpleMessage) MarshalTo

func (m *CompoundMessage_SimpleMessage) MarshalTo(data []byte) (int, error)

func (*CompoundMessage_SimpleMessage) ProtoMessage

func (*CompoundMessage_SimpleMessage) ProtoMessage()

func (*CompoundMessage_SimpleMessage) Reset

func (m *CompoundMessage_SimpleMessage) Reset()

func (*CompoundMessage_SimpleMessage) Size

func (m *CompoundMessage_SimpleMessage) Size() (n int)

func (*CompoundMessage_SimpleMessage) String

func (this *CompoundMessage_SimpleMessage) String() string

func (*CompoundMessage_SimpleMessage) Unmarshal

func (m *CompoundMessage_SimpleMessage) Unmarshal(data []byte) error

type Config

type Config struct {
	// NodeName is the cluster wide unique name for this node.
	NodeName string

	// BindAddr is the IP on which networkdb listens. It can be
	// 0.0.0.0 to listen on all addresses on the host.
	BindAddr string

	// AdvertiseAddr is the node's IP address that we advertise for
	// cluster communication.
	AdvertiseAddr string

	// BindPort is the local node's port to which we bind to for
	// cluster communication.
	BindPort int

	// Keys to be added to the Keyring of the memberlist. Key at index
	// 0 is the primary key
	Keys [][]byte
}

Config represents the configuration of the networdb instance and can be passed by the caller.

type CreateEvent

type CreateEvent event

CreateEvent generates a table entry create event to the watchers

type DeleteEvent

type DeleteEvent event

DeleteEvent generates a table entry delete event to the watchers

type GossipMessage

type GossipMessage struct {
	Type MessageType `protobuf:"varint,1,opt,name=type,proto3,enum=networkdb.MessageType" json:"type,omitempty"`
	Data []byte      `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
}

GossipMessage is a basic message header used by all messages types.

func (*GossipMessage) Descriptor

func (*GossipMessage) Descriptor() ([]byte, []int)

func (*GossipMessage) GoString

func (this *GossipMessage) GoString() string

func (*GossipMessage) Marshal

func (m *GossipMessage) Marshal() (data []byte, err error)

func (*GossipMessage) MarshalTo

func (m *GossipMessage) MarshalTo(data []byte) (int, error)

func (*GossipMessage) ProtoMessage

func (*GossipMessage) ProtoMessage()

func (*GossipMessage) Reset

func (m *GossipMessage) Reset()

func (*GossipMessage) Size

func (m *GossipMessage) Size() (n int)

func (*GossipMessage) String

func (this *GossipMessage) String() string

func (*GossipMessage) Unmarshal

func (m *GossipMessage) Unmarshal(data []byte) error

type MessageType

type MessageType int32

MessageType enum defines all the core message types that networkdb uses to communicate to peers.

const (
	MessageTypeInvalid MessageType = 0
	// NetworEvent message type is used to communicate network
	// attachments on the node.
	MessageTypeNetworkEvent MessageType = 1
	// TableEvent message type is used to communicate any table
	// CRUD event that happened on the node.
	MessageTypeTableEvent MessageType = 2
	// PushPull message type is used to syncup all network
	// attachments on a peer node either during startup of this
	// node or with a random peer node periodically thereafter.
	MessageTypePushPull MessageType = 3
	// BulkSync message is used to bulksync the whole networkdb
	// state with a peer node during startup of this node or with
	// a random peer node periodically thereafter.
	MessageTypeBulkSync MessageType = 4
	// Compound message type is used to form a compound message
	// which is a pack of many message of above types, packed into
	// a single compound message.
	MessageTypeCompound MessageType = 5
	// NodeEvent message type is used to communicare node
	// join/leave events in the cluster
	MessageTypeNodeEvent MessageType = 6
)

func (MessageType) EnumDescriptor

func (MessageType) EnumDescriptor() ([]byte, []int)

func (MessageType) String

func (x MessageType) String() string

type NetworkDB

type NetworkDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NetworkDB instance drives the networkdb cluster and acts the broker for cluster-scoped and network-scoped gossip and watches.

func New

func New(c *Config) (*NetworkDB, error)

New creates a new instance of NetworkDB using the Config passed by the caller.

func (*NetworkDB) Close

func (nDB *NetworkDB) Close()

Close destroys this NetworkDB instance by leave the cluster, stopping timers, canceling goroutines etc.

func (*NetworkDB) CreateEntry

func (nDB *NetworkDB) CreateEntry(tname, nid, key string, value []byte) error

CreateEntry creates a table entry in NetworkDB for given (network, table, key) tuple and if the NetworkDB is part of the cluster propogates this event to the cluster. It is an error to create an entry for the same tuple for which there is already an existing entry.

func (*NetworkDB) DeleteEntry

func (nDB *NetworkDB) DeleteEntry(tname, nid, key string) error

DeleteEntry deletes a table entry in NetworkDB for given (network, table, key) tuple and if the NetworkDB is part of the cluster propogates this event to the cluster.

func (*NetworkDB) GetEntry

func (nDB *NetworkDB) GetEntry(tname, nid, key string) ([]byte, error)

GetEntry retrieves the value of a table entry in a given (network, table, key) tuple

func (*NetworkDB) Join

func (nDB *NetworkDB) Join(members []string) error

Join joins this NetworkDB instance with a list of peer NetworkDB instances passed by the caller in the form of addr:port

func (*NetworkDB) JoinNetwork

func (nDB *NetworkDB) JoinNetwork(nid string) error

JoinNetwork joins this node to a given network and propogates this event across the cluster. This triggers this node joining the sub-cluster of this network and participates in the network-scoped gossip and bulk sync for this network.

func (*NetworkDB) LeaveNetwork

func (nDB *NetworkDB) LeaveNetwork(nid string) error

LeaveNetwork leaves this node from a given network and propogates this event across the cluster. This triggers this node leaving the sub-cluster of this network and as a result will no longer participate in the network-scoped gossip and bulk sync for this network. Also remove all the table entries for this network from networkdb

func (*NetworkDB) RemoveKey

func (nDB *NetworkDB) RemoveKey(key []byte)

RemoveKey removes a key from the key ring. The key being removed can't be the primary key

func (*NetworkDB) SetKey

func (nDB *NetworkDB) SetKey(key []byte)

SetKey adds a new key to the key ring

func (*NetworkDB) SetPrimaryKey

func (nDB *NetworkDB) SetPrimaryKey(key []byte)

SetPrimaryKey sets the given key as the primary key. This should have been added apriori through SetKey

func (*NetworkDB) UpdateEntry

func (nDB *NetworkDB) UpdateEntry(tname, nid, key string, value []byte) error

UpdateEntry updates a table entry in NetworkDB for given (network, table, key) tuple and if the NetworkDB is part of the cluster propogates this event to the cluster. It is an error to update a non-existent entry.

func (*NetworkDB) WalkTable

func (nDB *NetworkDB) WalkTable(tname string, fn func(string, string, []byte) bool) error

WalkTable walks a single table in NetworkDB and invokes the passed function for each entry in the table passing the network, key, value. The walk stops if the passed function returns a true.

func (*NetworkDB) Watch

func (nDB *NetworkDB) Watch(tname, nid, key string) (chan events.Event, func())

Watch creates a watcher with filters for a particular table or network or key or any combination of the tuple. If any of the filter is an empty string it acts as a wildcard for that field. Watch returns a channel of events, where the events will be sent.

type NetworkEntry

type NetworkEntry struct {
	// ID of the network
	NetworkID string `protobuf:"bytes,1,opt,name=network_id,json=networkId,proto3" json:"network_id,omitempty"`
	// Latest lamport time of the network attachment when this
	// network event was recorded.
	LTime github_com_hashicorp_serf_serf.LamportTime `protobuf:"varint,2,opt,name=l_time,json=lTime,proto3,customtype=github.com/hashicorp/serf/serf.LamportTime" json:"l_time"`
	// Source node name where this network attachment happened.
	NodeName string `protobuf:"bytes,3,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
	// Indicates if a leave from this network is in progress.
	Leaving bool `protobuf:"varint,4,opt,name=leaving,proto3" json:"leaving,omitempty"`
}

NetworkEntry for push pull of networks.

func (*NetworkEntry) Descriptor

func (*NetworkEntry) Descriptor() ([]byte, []int)

func (*NetworkEntry) GoString

func (this *NetworkEntry) GoString() string

func (*NetworkEntry) Marshal

func (m *NetworkEntry) Marshal() (data []byte, err error)

func (*NetworkEntry) MarshalTo

func (m *NetworkEntry) MarshalTo(data []byte) (int, error)

func (*NetworkEntry) ProtoMessage

func (*NetworkEntry) ProtoMessage()

func (*NetworkEntry) Reset

func (m *NetworkEntry) Reset()

func (*NetworkEntry) Size

func (m *NetworkEntry) Size() (n int)

func (*NetworkEntry) String

func (this *NetworkEntry) String() string

func (*NetworkEntry) Unmarshal

func (m *NetworkEntry) Unmarshal(data []byte) error

type NetworkEvent

type NetworkEvent struct {
	Type NetworkEvent_Type `protobuf:"varint,1,opt,name=type,proto3,enum=networkdb.NetworkEvent_Type" json:"type,omitempty"`
	// Lamport time using a network lamport clock indicating the
	// time this event was generated on the node where it was
	// generated.
	LTime github_com_hashicorp_serf_serf.LamportTime `protobuf:"varint,2,opt,name=l_time,json=lTime,proto3,customtype=github.com/hashicorp/serf/serf.LamportTime" json:"l_time"`
	// Source node name.
	NodeName string `protobuf:"bytes,3,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
	// ID of the network for which the event is generated.
	NetworkID string `protobuf:"bytes,4,opt,name=network_id,json=networkId,proto3" json:"network_id,omitempty"`
}

NetworkEvent message payload definition.

func (*NetworkEvent) Descriptor

func (*NetworkEvent) Descriptor() ([]byte, []int)

func (*NetworkEvent) GoString

func (this *NetworkEvent) GoString() string

func (*NetworkEvent) Marshal

func (m *NetworkEvent) Marshal() (data []byte, err error)

func (*NetworkEvent) MarshalTo

func (m *NetworkEvent) MarshalTo(data []byte) (int, error)

func (*NetworkEvent) ProtoMessage

func (*NetworkEvent) ProtoMessage()

func (*NetworkEvent) Reset

func (m *NetworkEvent) Reset()

func (*NetworkEvent) Size

func (m *NetworkEvent) Size() (n int)

func (*NetworkEvent) String

func (this *NetworkEvent) String() string

func (*NetworkEvent) Unmarshal

func (m *NetworkEvent) Unmarshal(data []byte) error

type NetworkEvent_Type

type NetworkEvent_Type int32
const (
	NetworkEventTypeInvalid NetworkEvent_Type = 0
	// Join event is generated when this node joins a network.
	NetworkEventTypeJoin NetworkEvent_Type = 1
	// Leave event is generated when this node leaves a network.
	NetworkEventTypeLeave NetworkEvent_Type = 2
)

func (NetworkEvent_Type) EnumDescriptor

func (NetworkEvent_Type) EnumDescriptor() ([]byte, []int)

func (NetworkEvent_Type) String

func (x NetworkEvent_Type) String() string

type NetworkPushPull

type NetworkPushPull struct {
	// Lamport time when this push pull was initiated.
	LTime    github_com_hashicorp_serf_serf.LamportTime `protobuf:"varint,1,opt,name=l_time,json=lTime,proto3,customtype=github.com/hashicorp/serf/serf.LamportTime" json:"l_time"`
	Networks []*NetworkEntry                            `protobuf:"bytes,2,rep,name=networks" json:"networks,omitempty"`
	// Name of the node sending this push pull payload.
	NodeName string `protobuf:"bytes,3,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
}

NetworkPushpull message payload definition.

func (*NetworkPushPull) Descriptor

func (*NetworkPushPull) Descriptor() ([]byte, []int)

func (*NetworkPushPull) GetNetworks

func (m *NetworkPushPull) GetNetworks() []*NetworkEntry

func (*NetworkPushPull) GoString

func (this *NetworkPushPull) GoString() string

func (*NetworkPushPull) Marshal

func (m *NetworkPushPull) Marshal() (data []byte, err error)

func (*NetworkPushPull) MarshalTo

func (m *NetworkPushPull) MarshalTo(data []byte) (int, error)

func (*NetworkPushPull) ProtoMessage

func (*NetworkPushPull) ProtoMessage()

func (*NetworkPushPull) Reset

func (m *NetworkPushPull) Reset()

func (*NetworkPushPull) Size

func (m *NetworkPushPull) Size() (n int)

func (*NetworkPushPull) String

func (this *NetworkPushPull) String() string

func (*NetworkPushPull) Unmarshal

func (m *NetworkPushPull) Unmarshal(data []byte) error

type NodeEvent

type NodeEvent struct {
	Type NodeEvent_Type `protobuf:"varint,1,opt,name=type,proto3,enum=networkdb.NodeEvent_Type" json:"type,omitempty"`
	// Lamport time using a network lamport clock indicating the
	// time this event was generated on the node where it was
	// generated.
	LTime github_com_hashicorp_serf_serf.LamportTime `protobuf:"varint,2,opt,name=l_time,json=lTime,proto3,customtype=github.com/hashicorp/serf/serf.LamportTime" json:"l_time"`
	// Source node name.
	NodeName string `protobuf:"bytes,3,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
}

NodeEvent message payload definition.

func (*NodeEvent) Descriptor

func (*NodeEvent) Descriptor() ([]byte, []int)

func (*NodeEvent) GoString

func (this *NodeEvent) GoString() string

func (*NodeEvent) Marshal

func (m *NodeEvent) Marshal() (data []byte, err error)

func (*NodeEvent) MarshalTo

func (m *NodeEvent) MarshalTo(data []byte) (int, error)

func (*NodeEvent) ProtoMessage

func (*NodeEvent) ProtoMessage()

func (*NodeEvent) Reset

func (m *NodeEvent) Reset()

func (*NodeEvent) Size

func (m *NodeEvent) Size() (n int)

func (*NodeEvent) String

func (this *NodeEvent) String() string

func (*NodeEvent) Unmarshal

func (m *NodeEvent) Unmarshal(data []byte) error

type NodeEvent_Type

type NodeEvent_Type int32
const (
	NodeEventTypeInvalid NodeEvent_Type = 0
	// Join event is generated when this node joins the cluster.
	NodeEventTypeJoin NodeEvent_Type = 1
	// Leave event is generated when this node leaves the cluster.
	NodeEventTypeLeave NodeEvent_Type = 2
)

func (NodeEvent_Type) EnumDescriptor

func (NodeEvent_Type) EnumDescriptor() ([]byte, []int)

func (NodeEvent_Type) String

func (x NodeEvent_Type) String() string

type TableEvent

type TableEvent struct {
	Type TableEvent_Type `protobuf:"varint,1,opt,name=type,proto3,enum=networkdb.TableEvent_Type" json:"type,omitempty"`
	// Lamport time when this event was generated.
	LTime github_com_hashicorp_serf_serf.LamportTime `protobuf:"varint,2,opt,name=l_time,json=lTime,proto3,customtype=github.com/hashicorp/serf/serf.LamportTime" json:"l_time"`
	// Node name where this event originated.
	NodeName string `protobuf:"bytes,3,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"`
	// ID of the network to which this table entry belongs.
	NetworkID string `protobuf:"bytes,4,opt,name=network_id,json=networkId,proto3" json:"network_id,omitempty"`
	// Name of the table to which this table entry belongs.
	TableName string `protobuf:"bytes,5,opt,name=table_name,json=tableName,proto3" json:"table_name,omitempty"`
	// Entry key.
	Key string `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"`
	// Entry value.
	Value []byte `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"`
}

TableEvent message payload definition.

func (*TableEvent) Descriptor

func (*TableEvent) Descriptor() ([]byte, []int)

func (*TableEvent) GoString

func (this *TableEvent) GoString() string

func (*TableEvent) Marshal

func (m *TableEvent) Marshal() (data []byte, err error)

func (*TableEvent) MarshalTo

func (m *TableEvent) MarshalTo(data []byte) (int, error)

func (*TableEvent) ProtoMessage

func (*TableEvent) ProtoMessage()

func (*TableEvent) Reset

func (m *TableEvent) Reset()

func (*TableEvent) Size

func (m *TableEvent) Size() (n int)

func (*TableEvent) String

func (this *TableEvent) String() string

func (*TableEvent) Unmarshal

func (m *TableEvent) Unmarshal(data []byte) error

type TableEvent_Type

type TableEvent_Type int32
const (
	TableEventTypeInvalid TableEvent_Type = 0
	// Create signifies that this table entry was just
	// created.
	TableEventTypeCreate TableEvent_Type = 1
	// Update signifies that this table entry was just
	// updated.
	TableEventTypeUpdate TableEvent_Type = 2
	// Delete signifies that this table entry was just
	// updated.
	TableEventTypeDelete TableEvent_Type = 3
)

func (TableEvent_Type) EnumDescriptor

func (TableEvent_Type) EnumDescriptor() ([]byte, []int)

func (TableEvent_Type) String

func (x TableEvent_Type) String() string

type UpdateEvent

type UpdateEvent event

UpdateEvent generates a table entry update event to the watchers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL