v3client

package
v3.5.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2020 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package v3client provides clientv3 interfaces from an etcdserver.

Use v3client by creating an EtcdServer instance, then wrapping it with v3client.New:

import (
	"context"

	"github.com/ptabor/etcd/server/v3/embed"
	"github.com/ptabor/etcd/server/v3/etcdserver/api/v3client"
)

...

// create an embedded EtcdServer from the default configuration
cfg := embed.NewConfig()
cfg.Dir = "default.etcd"
e, err := embed.StartEtcd(cfg)
if err != nil {
	// handle error!
}

// wrap the EtcdServer with v3client
cli := v3client.New(e.Server)

// use like an ordinary clientv3
resp, err := cli.Put(context.TODO(), "some-key", "it works!")
if err != nil {
	// handle error!
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(s *etcdserver.EtcdServer) *clientv3.Client

New creates a clientv3 client that wraps an in-process EtcdServer. Instead of making gRPC calls through sockets, the client makes direct function calls to the etcd server through its api/v3rpc function interfaces.

Types

This section is empty.

Jump to

Keyboard shortcuts

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