consultopo

package
v2.2.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package consultopo implements topo.Server with consul as the backend.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadResponse is returned from this package if the
	// response from the consul server does not contain the data
	// that the API promises. The consul client unmarshals JSON
	// from the server into a Response struct that uses pointers,
	// so we need to check for nil pointers, or else a misbehaving
	// consul could cause us to panic.
	ErrBadResponse = errors.New("consul request returned success, but response is missing required data")
)

Errors specific to this package.

Functions

func VersionFromInt

func VersionFromInt(version int64) topo.Version

VersionFromInt is used by old-style functions to create a proper Version: if version is -1, returns nil. Otherwise returns the ConsulVersion object.

Types

type ConsulVersion

type ConsulVersion uint64

ConsulVersion is consul's idea of a version. It implements topo.Version. We use the native consul version type, uint64.

func (ConsulVersion) String

func (v ConsulVersion) String() string

String is part of the topo.Version interface.

type Factory

type Factory struct{}

Factory is the consul topo.Factory implementation.

func (Factory) Create

func (f Factory) Create(cell, serverAddr, root string) (topo.Conn, error)

Create is part of the topo.Factory interface.

func (Factory) HasGlobalReadOnlyCell

func (f Factory) HasGlobalReadOnlyCell(serverAddr, root string) bool

HasGlobalReadOnlyCell is part of the topo.Factory interface.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the implementation of topo.Server for consul.

func NewServer

func NewServer(serverAddr, root string) (*Server, error)

NewServer returns a new consultopo.Server.

func (*Server) Close

func (s *Server) Close()

Close implements topo.Server.Close. It will nil out the global and cells fields, so any attempt to re-use this server will panic.

func (*Server) Create

func (s *Server) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error)

Create is part of the topo.Conn interface.

func (*Server) Delete

func (s *Server) Delete(ctx context.Context, filePath string, version topo.Version) error

Delete is part of the topo.Conn interface.

func (*Server) Get

func (s *Server) Get(ctx context.Context, filePath string) ([]byte, topo.Version, error)

Get is part of the topo.Conn interface.

func (*Server) ListDir

func (s *Server) ListDir(ctx context.Context, dirPath string, full bool) ([]topo.DirEntry, error)

ListDir is part of the topo.Conn interface.

func (*Server) Lock

func (s *Server) Lock(ctx context.Context, dirPath, contents string) (topo.LockDescriptor, error)

Lock is part of the topo.Conn interface.

func (*Server) NewMasterParticipation

func (s *Server) NewMasterParticipation(name, id string) (topo.MasterParticipation, error)

NewMasterParticipation is part of the topo.Server interface

func (*Server) Update

func (s *Server) Update(ctx context.Context, filePath string, contents []byte, version topo.Version) (topo.Version, error)

Update is part of the topo.Conn interface.

func (*Server) Watch

func (s *Server) Watch(ctx context.Context, filePath string) (*topo.WatchData, <-chan *topo.WatchData, topo.CancelFunc)

Watch is part of the topo.Conn interface.

Jump to

Keyboard shortcuts

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