Skip to content

A ring hash implemented in Golang with some additional special features.

Notifications You must be signed in to change notification settings

ethanperry1/ringhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ringhash

Ringhash is a golang implementation of a ring hash data structure, with some additional special features:

  1. Generic key-value store
  2. Channel based notification system
  3. Optionally duplicate hashing keys
  4. Ordering mechanism for channel notifications
  5. Concurrency safe for every method
  6. "Empty Node," where keys are assigned when no nodes are present
  7. Virtual factor (vfactor) to increase key distribution amoung nodes
  8. Zero non-testing dependencies

Quickstart

import (
    "github.com/ethanperry1/ringhash"
)

func main() {
    ring, err := ringhash.New()
    if err != nil {
        // Handle error here -- error will be returned if vFactor is set to any value less than 1.
    }

    err = ring.CreateNode(Node{
		Identifier: "A",
		VFactor:    100,
	})
    if err != nil { /* Handle error */ }

    err = ring.Emplace(&Key[int]{
		InnerKey: &InnerKey{
			Key:   "2", // Key must be unique.
			Order: 0,
		}, Value: 184, // Value associated with this key.
	},
        "hash_key" // This optional key will be used to hash the key into the ring, and does not need to be unique.
    )
}

About

A ring hash implemented in Golang with some additional special features.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages