modata

package
v0.0.0-...-704c7b2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2013 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK       = "OK"
	NOTFOUND = "NOTFOUND"
	NOTOK    = "NOTOK"
	ERROR    = "ERROR"
)

Response codes

View Source
const Alpha = 3
View Source
const IDLength = 20

Bytes are 8 bits, so a size 20 byte array means a 160 bit nodeid

View Source
const REPL_INTERVAL = 10 * time.Second

Variables

This section is empty.

Functions

func BuildKeyMap

func BuildKeyMap(contacts ContactList) map[string][]string

func Compare

func Compare(a *NodeID, b *NodeID) int

func Hash

func Hash(value string) []byte

SHA1s a string

func HashByte

func HashByte(value []byte) []byte

func HexNodeID

func HexNodeID(id NodeID) string

func KeyValue

func KeyValue(key string, value string) map[string]string

Creates a dictionary with a single key and a single value

func MakeByteArray

func MakeByteArray(str string) []byte

func MakeByteSlice

func MakeByteSlice(id NodeID) []byte

func MakeGUID

func MakeGUID() []byte

GUID generation

func MakeHex

func MakeHex(barray []byte) string

String -> []Byte and visaversa

func Pretty

func Pretty(v interface{}) string

func RespondNotFound

func RespondNotFound() string

func RespondNotOk

func RespondNotOk() string

func RespondOk

func RespondOk() string

func RespondWithData

func RespondWithData(data interface{}) string

func RespondWithStatus

func RespondWithStatus(status string, data interface{}) string

REST convenience to marshall all the things to json

func VerifyKV

func VerifyKV(key string, value string) bool

Types

type BlockServer

type BlockServer struct {
	// contains filtered or unexported fields
}

func StartBlockServer

func StartBlockServer(name string) *BlockServer

func (*BlockServer) Contact

func (bs *BlockServer) Contact() Contact

func (*BlockServer) FindNode

func (bs *BlockServer) FindNode(c *web.Context, node string) string

Locally find a node

func (*BlockServer) FindValue

func (bs *BlockServer) FindValue(c *web.Context, key string) string

Locally find a value

func (*BlockServer) IterativeFindNode

func (bs *BlockServer) IterativeFindNode(c *web.Context, node string) string

Do a distributed find node

func (*BlockServer) IterativeFindValue

func (bs *BlockServer) IterativeFindValue(c *web.Context, key string) (value string)

Do a distributed lookup, first does a distributed find node to find places it should query, then either it looks for values and stores any that are missing

func (*BlockServer) IterativeStore

func (bs *BlockServer) IterativeStore(c *web.Context) string

Do a distributed store

func (*BlockServer) Store

func (bs *BlockServer) Store(c *web.Context) string

Store a key,value pair locally

func (*BlockServer) UpdateContact

func (bs *BlockServer) UpdateContact(contact Contact)

type Bucket

type Bucket struct {
	list.List
}

type Contact

type Contact struct {
	ID   NodeID
	Addr string
	Port int
}

func DecodeModataHeaders

func DecodeModataHeaders(header http.Header) (Contact, error)

func JsonGet

func JsonGet(uri string, self Contact) (string, interface{}, Contact)

REST convenience to unmarshall all the things from json

func JsonPost

func JsonPost(uri string, data map[string]string, self Contact) (string, interface{}, Contact)

func JsonPostUrl

func JsonPostUrl(uri string, self Contact) (string, interface{}, Contact)

func MakeContact

func MakeContact(v interface{}) Contact

func (*Contact) ToHttpAddress

func (c *Contact) ToHttpAddress() string

type ContactDistance

type ContactDistance struct {
	Contact  Contact
	Distance NodeID
}

func MakeContactDistance

func MakeContactDistance(v interface{}) ContactDistance

type ContactDistanceList

type ContactDistanceList []ContactDistance

func MakeContactDistanceList

func MakeContactDistanceList(m []interface{}) ContactDistanceList

func (ContactDistanceList) Len

func (l ContactDistanceList) Len() int

func (ContactDistanceList) Less

func (l ContactDistanceList) Less(i, j int) bool

func (*ContactDistanceList) Peek

func (l *ContactDistanceList) Peek() interface{}

func (*ContactDistanceList) Pop

func (l *ContactDistanceList) Pop() interface{}

func (*ContactDistanceList) Push

func (l *ContactDistanceList) Push(x interface{})

func (ContactDistanceList) Swap

func (l ContactDistanceList) Swap(i, j int)

type ContactList

type ContactList []Contact

func MakeContactList

func MakeContactList(m []interface{}) ContactList

func (ContactList) Len

func (l ContactList) Len() int

func (ContactList) Less

func (l ContactList) Less(i, j int) bool

func (ContactList) Swap

func (l ContactList) Swap(i, j int)

type Key

type Key NodeID

Keys are also 160 bit, so that they can be compared with Keys

func MakeKey

func MakeKey(source []byte) Key

type KeyInfo

type KeyInfo struct {
	ClosestNodes ContactList
}

type NodeID

type NodeID [IDLength]byte

NodeIDs are 160 bit identifiers

func Distance

func Distance(a *NodeID, b *NodeID) (d NodeID)

func MakeNode

func MakeNode(source []byte) NodeID

func MakeNodeID

func MakeNodeID(str string) (id NodeID)

func (*NodeID) Equals

func (a *NodeID) Equals(b *NodeID) bool

func (*NodeID) GreaterThan

func (a *NodeID) GreaterThan(b *NodeID) bool

func (*NodeID) LessThan

func (a *NodeID) LessThan(b *NodeID) bool

type ReplicationServer

type ReplicationServer struct {
	MyContact Contact
	// contains filtered or unexported fields
}

func StartReplicationServer

func StartReplicationServer(name string, bs *BlockServer) *ReplicationServer

func (*ReplicationServer) IntelligentReplication

func (rs *ReplicationServer) IntelligentReplication()

func (*ReplicationServer) KeyMap

func (rs *ReplicationServer) KeyMap(c *web.Context) string

type RoutingTable

type RoutingTable struct {
	// contains filtered or unexported fields
}

func NewRoutingTable

func NewRoutingTable(k int, id []byte) (rt *RoutingTable)

func (*RoutingTable) AllContacts

func (rt *RoutingTable) AllContacts() ContactList

func (*RoutingTable) BucketForNode

func (rt *RoutingTable) BucketForNode(n NodeID) (i int)

func (*RoutingTable) FindClosest

func (rt *RoutingTable) FindClosest(k NodeID, alpha int) ContactDistanceList

func (*RoutingTable) Init

func (rt *RoutingTable) Init()

func (*RoutingTable) Remove

func (rt *RoutingTable) Remove(c Contact)

func (*RoutingTable) Update

func (rt *RoutingTable) Update(c Contact)

Jump to

Keyboard shortcuts

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