networkdb

package
v0.8.0-dev.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

	// BindAddr is the local node's IP address that we bind to for
	// cluster communication.
	BindAddr string

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

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 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.

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 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