Skip to content

go-xline is an official xline client sdk, written in Go.

License

Notifications You must be signed in to change notification settings

xline-kv/go-xline

Repository files navigation

Go-Xline

Apache 2.0 licensed codecov Build Status

Go-Xline is an official xline client sdk, written in Go.

Features

go-xline runs the CURP protocol on the client side for maximal performance.

Supported APIs

  • KV
    • Put
    • Range
    • Delete
    • Txn
    • Compact
  • Auth
    • AuthEnable
    • AuthDisable
    • AuthStatus
    • Authenticate
    • UserAdd
    • UserAddWithOptions
    • UserGet
    • UserList
    • UserDelete
    • UserChangePassword
    • UserGrantRole
    • UserRevokeRole
    • RoleAdd
    • RoleGet
    • RoleList
    • [x]
    • RoleGrantPermission
    • RoleRevokePermission
  • Lease
    • Grant
    • Revoke
    • KeepAlive
    • KeepAliveOnce
    • TimeToLive
    • Leases
  • Watch
    • Watch
  • Lock
    • Lock
    • Unlock
  • Cluster
    • MemberAdd
    • MemberAddAsLearner
    • MemberRemove
    • MemberUpdate
    • MemberList
    • MemberPromote
  • Maintenance
    • Alarm
    • Status
    • Defragment
    • Hash
    • Snapshot
    • MoveLeader

Installation

go get github.com/xline-kv/go-xline

Quickstart

import (
	"fmt"

	"github.com/xline-kv/go-xline/client"
)

func ExampleClient() {
	curpMembers := []string{"172.20.0.3:2379", "172.20.0.4:2379", "172.20.0.5:2379"}

	cli, err := client.Connect(curpMembers)
	if err != nil {
		panic(err)
	}

	kvCli := cli.KV

	_, err = kvCli.Put([]byte("key"), []byte("value"))
	if err != nil {
		panic(err)
	}

	res, err := kvCli.Range([]byte("key"))
	if err != nil {
		panic(err)
	}

	kv := res.Kvs[0]
	fmt.Println(string(kv.Key), string(kv.Value))
}

Compatibility

We aim to maintain compatibility with each corresponding Xline version, and update this library with each new Xline release.

go-xline Xline
v0.1.0 v0.6.0
v0.1.1 v0.6.1