metcd

package
v0.0.0-...-58dbcc3 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

README

metcd

metcd implements the etcd V3 API on top of Weave Mesh.

Note that this package no longer compiles due to changes in etcd upstream. The code remains for historical purposes.

Caveats

  • We only partially implement the etcd V3 API. See etcd_store.go for details.
  • Snapshotting and compaction are not yet implemented.

Usage

ln, err := net.Listen("tcp", ":8080")
if err != nil {
	panic(err)
}

minPeerCount := 3
logger := log.New(os.Stderr, "", log.Lstdflags)
server := metcd.NewDefaultServer(minPeerCount, logger)

server.Serve(ln)

To have finer-grained control over the mesh, use metcd.NewServer. See metcdsrv for a complete example.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCServer

func GRPCServer(s Server, options ...grpc.ServerOption) *grpc.Server

GRPCServer converts a metcd.Server to a *grpc.Server.

func PrefixRangeEnd

func PrefixRangeEnd(prefix []byte) []byte

PrefixRangeEnd allows Get, Delete, and Watch requests to operate on all keys with a matching prefix. Pass the prefix to this function, and use the result as the RangeEnd value.

Types

type Server

type Server interface {
	//etcdserverpb.AuthServer
	//etcdserverpb.ClusterServer
	etcdserverpb.KVServer
}

Server collects the etcd V3 server interfaces that we implement.

func NewDefaultServer

func NewDefaultServer(
	minPeerCount int,
	terminatec <-chan struct{},
	terminatedc chan<- error,
	logger mesh.Logger,
) Server

NewDefaultServer is like NewServer, but we take care of creating a mesh.Router and meshconn.Peer for you, with sane defaults. If you need more fine-grained control, create the components yourself and use NewServer.

func NewServer

func NewServer(
	router *mesh.Router,
	peer *meshconn.Peer,
	minPeerCount int,
	terminatec <-chan struct{},
	terminatedc chan<- error,
	logger mesh.Logger,
) Server

NewServer returns a Server that (partially) implements the etcd V3 API. It uses the passed mesh components to act as the Raft transport. For the moment, it blocks until the mesh has minPeerCount peers. (This responsibility should rather be given to the caller.) The server can be terminated by certain conditions in the cluster. If that happens, terminatedc signaled, and the server is invalid.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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