Skip to content

yogyrahmawan/consistenthashing

Repository files navigation

Build Status Coverage Status

ConsistentHasing

Reference

Short Introduction

  • Hash Function : fnv1a
  • Data structure : bst

usage example

package main
  
import (
        "fmt"
        "log"

        ch "github.com/yogyrahmawan/consistenthashing"
)

func main() {
        r := ch.Init()
        r.Insert("a", "10.88.10.200:8000")
        r.Insert("b", "10.88.10.201:8001")
        fmt.Println(r.GetAllElmt())

        // get assigned node
        assigned, err := r.Get("cde")
        if err != nil {
                log.Fatalf("error getting assigned node, err = %v \n", err)
        }
        fmt.Println(assigned)

        // removing node
        r.Remove("a")

        fmt.Println(r.GetAllElmt())
}

About

simple and straightforward consistent hashing in go

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages