Skip to content

Commit

Permalink
chore: update example in the code
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksezer committed Nov 9, 2022
1 parent ae9f2ab commit 7eb5636
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions consistent.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,33 @@
//
// Example Use:
//
// cfg := consistent.Config{
// PartitionCount: 71,
// ReplicationFactor: 20,
// Load: 1.25,
// Hasher: hasher{},
// }
// cfg := consistent.Config{
// PartitionCount: 71,
// ReplicationFactor: 20,
// Load: 1.25,
// Hasher: hasher{},
// }
//
// // Create a new consistent object
// // You may call this with a list of members
// // instead of adding them one by one.
// c := consistent.New(members, cfg)
// Now you can create a new Consistent instance. This function can take a list of the members.
//
// // myMember struct just needs to implement a String method.
// // New/Add/Remove distributes partitions among members using the algorithm
// // defined on Google Research Blog.
// c.Add(myMember)
// c := consistent.New(members, cfg)
//
// key := []byte("my-key")
// // LocateKey hashes the key and calculates partition ID with
// // this modulo operation: MOD(hash result, partition count)
// // The owner of the partition is already calculated by New/Add/Remove.
// // LocateKey just returns the member which's responsible for the key.
// member := c.LocateKey(key)
// In the following sample, you add a new Member to the consistent hash ring. myMember is just a Go struct that
// implements the Member interface. You should know that modifying the consistent hash ring distributes partitions among
// members using the algorithm defined on Google Research Blog.
//
// c.Add(myMember)
//
// Remove a member from the consistent hash ring:
//
// c.Remove(member-name)
//
// LocateKey hashes the key and calculates partition ID with this modulo operation: MOD(hash result, partition count)
// The owner of the partition is already calculated by New/Add/Remove. LocateKey just returns the member that is responsible
// for the key.
//
// key := []byte("my-key")
// member := c.LocateKey(key)
package consistent

import (
Expand Down

0 comments on commit 7eb5636

Please sign in to comment.