kvuR

module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT

README

kvuR

A Go implementation of Raft Algorithm & A fault-tolerant primary/backup K/V storage system that use the implementation.

Raft

To see the paper: In Search of an Understandable Consensus Algorithm(Extended Version)
To see the implementation: raft

Primary/backup K/V storage system

Example

Run three k/v storage server instances

go run server/kvserver.go example/config/server1.yml
go run server/kvserver.go example/config/server2.yml
go run server/kvserver.go example/config/server3.yml

The number of servers must be odd and greater than or equal to 3.

# example/config/server1.yml

servers: # address list of all k/v servers
  - ip: 127.0.0.1
    port: 10001
  - ip: 127.0.0.1
    port: 10002
  - ip: 127.0.0.1
    port: 10003
me: 0 # index of my address in address list

You can use the simple command line client to communicate with k/v storage service

go run cli/kvcli.go example/config/client.yml
# example/config/client.yml

servers: # address list of all k/v servers
  - ip: 127.0.0.1
    port: 10001
  - ip: 127.0.0.1
    port: 10002
  - ip: 127.0.0.1
    port: 10003

Or use the client api

package main

import (
	"fmt"
	"kvuR/kv"
)

func main() {
	clientEnds := kv.GetClientEnds("example/config/client.yml")

	clerk := kv.MakeClerk(clientEnds)

	fmt.Printf("k1=%v\n", clerk.Get("k1"))

	clerk.Put("k1", "3")
	fmt.Printf("k1=%v\n", clerk.Get("k1"))

	clerk.Append("k1", "4")
	fmt.Printf("k1=%v\n", clerk.Get("k1"))
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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