mydis

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2017 License: Apache-2.0 Imports: 32 Imported by: 0

README

logo

Mydis

Go Report Card Build Status GoDoc

Introduction

Distributed, reliable database and cache library, server, and client. Inspired by Redis, Mydis is written entirely in Go and can be used as a library, embedded into an existing application, or as a standalone client/server.

Basics

Mydis can store multiple types of data: strings, bytes, integers, floats, lists, and hashes (objects that hold key/value pairs). Each item is referenced with a key, a string of any length. The Mydis library, server, and client are thread/goroutine-safe. Client and server communication is handled with gRPC. All data types can have an expiration value set. Backwards compatibility with HTTP/1.1 is handled by gRPC-Gateway and must be run on a separate port. Both client and peer connections using gRPC are encrypted by default.

Details

Under the hood, the production-ready Etcd system is used. The creators describe it as such:

Etcd is a distributed, reliable key-value store for the most critical data of a distributed system.

In an effort to keep the focus on reliability and consistency, the authors of Etcd decided to allow only a single data type for both keys and values: byte arrays. Mydis builds upon the solid Etcd framework to provide more data types and features such as atomic list operations and distributed locks.

Load Balancing

The client supports Round Robin load balancing by calling mydis.NewClientConfigAddresses(addresses []string) or by changing the Addresses value in an existing ClientConfig instance. The client will connect to all servers specified and round robin each request across the pool of connections. Since 1.2.0, Mydis supports graceful reconnects in the event of a server or network outage.

Versioning

Versioning is done using SemVer. All bug fixes and new features should happen in separate branches and a pull request made when ready to merge. The master branch is the development branch and stable releases are tagged with the version number.

Configuration

Without any configuration, Mydis starts up as a single node cluster on port 8383 with a storage limit of 2GB. This can be changed by creating a YAML configuration file named mydis.conf in either /etc/mydis or in the same directory as the executable. To change the storage limit from the 2GB default, set quota-backend-bytes to the number of bytes the new limit should be. Clustering configuration is explained in another section. It is recommended to leave listen-client-urls and advertise-client-urls as an empty list unless you want clients to be able to bypass Mydis and connect directly to Etcd.

See Etcd's documentation for more configuration options.

The gRPC listening port can be changed from the default of 8383 by specifying the environment variable MYDIS_ADDRESS. The default value is 0.0.0.0:8383. Likewise, the gRPC-Gateway port can be changed by specifying the environment variable PORT. The default value is 8000.

Clustering

Clustering is handled entirely by Etcd. Its documentation explains the configuration required to create a cluster. To summarize, clusters should always have an odd number of nodes.

Example cluster configuration:

Nodes

  • node1=10.0.0.1
  • node2=10.0.0.2
  • node3=10.0.0.3

Config for Node1

initial-advertise-peer-urls:
- https://10.0.0.1:2380

listen-peer-urls:
- https://10.0.0.1:2380

ClientAutoTLS: true
PeerAutoTLS: true

name: node1
initial-cluster: node1=https://10.0.0.1:2380,node2=https://10.0.0.2:2380,node3=https://10.0.0.3:2380
initial-cluster-token: name-of-cluster

Config for Node2

initial-advertise-peer-urls:
- https://10.0.0.2:2380

listen-peer-urls:
- https://10.0.0.2:2380

ClientAutoTLS: true
PeerAutoTLS: true

name: node2
initial-cluster: node1=https://10.0.0.1:2380,node2=https://10.0.0.2:2380,node3=https://10.0.0.3:2380
initial-cluster-token: name-of-cluster

Some notes about this configuration:

  • Nodes will communicate over an encrypted HTTPS socket using auto generated keys.
  • Mydis will use the value of ClientAutoTLS or the client-specific TLS options to enable client encryption.
  • It is highly recommended to always use ClientAutoTLS: true and PeerAutoTLS: true unless you specify your own TLS configuration. The client tries to use AutoTLS by default.
  • The IP address 127.0.0.1 or 0.0.0.0 should never be used in any configuration option. The node's actual IP address should be used.
  • The name is used in initial-cluster to determine which address in the list belongs to the current node, so it must match.
  • The only fields that should change between nodes are: initial-advertise-peer-urls, listen-peer-urls, and name.
  • While setting initial-cluster-token is optional, it's always a good idea to give each cluster a name.

See Etcd's clustering guide for more information.

Server API

When used as a library, the server API uses protocol buffer messages with context, as required by gRPC.

Client API

Some getter functions return a helper object, called Value that allows you to specify what data type you would like the response in. The data type functions available include:

  • Bytes()
  • String()
  • Bool()
  • Proto(proto.Message)
  • Int()
  • Float()
  • Time()
  • Duration()
  • List()
  • Map()

All of these functions return the desired data type and an error if there was a problem getting or converting the value.

Keys

Keys are strings of any length.

Functions

  • Keys() []string: Get list of keys available in the database.
  • KeysWithPrefix() []string: Gets a list of keys with the given prefix.
  • Has(key) bool: Determine if a key exists.
  • SetExpire(key, exp): Reset the expiration of a key to the number of seconds from now.
  • Delete(key): Delete a key.
  • Clear(): Clear the database.

Strings/Bytes

Strings can be text or byte arrays. Conversion between string and bytes is done without any additional memory allocations.

Functions

  • Get(key) Value: Get a value, returns ErrKeyNotFound if key doesn't exist.
  • GetMany(keyList) map[string]Value: Get multiple values.
  • GetWithPrefix(prefix) map[string]Value: Gets the keys with the given prefix.
  • Set(key, value): Set a value.
  • SetNX(key, value) bool: Set a value only if the key doesn't exist, returns true if changed.
  • SetMany(values) map[string]string: Set many values, returning a map[key]errorText for any errors.
  • Length(key) int64: Get the number of bytes stored at the given key.

Numbers

Numbers can be 64-bit integers or floating-point values.

Functions

  • IncrementInt(key, by) int64: Increment an integer and return new value, starts at zero if key doesn't exist.
  • IncrementFloat(key, by) float64: Increment a float and return new value, starts at zero if key doesn't exist.
  • DecrementInt(key, by) int64: Decrement an integer and return new value, starts at zero if key doesn't exist.
  • DecrementFloat(key, by) float64: Decrement a float and return new value, starts at zero if key doesn't exist.

Lists

Lists are lists of values.

Functions

  • GetListItem(key, index) Value: Get a single item from a list by index, returns ErrKeyNotFound if key doesn't exist, or ErrorListIndexOutOfRange if index is out of range.
  • SetListItem(key, index, value): Set a single item in a list by index.
  • ListHas(key, value) int64: Determines if a list has a value, returns index or -1 if not found.
  • ListLimit(key, limit): Sets the maximum length of a list, removing items from the top once limit is reached. Evaluated on insert and append only.
  • ListInsert(key, index, value): Insert an item in a list at the given index, creates new list and inserts item at index zero if key doesn't exist.
  • ListAppend(key, value): Append an item to the end of a list, creates new list if key doesn't exist.
  • ListPopLeft(key) Value: Remove and return the first item in a list, returns ErrListEmpty if list is empty.
  • ListPopLeftBlock(key, seconds) Value: Remove and return the first item in a list, or wait the given seconds for a new value, setting to zero waits forever.
  • ListPopRight(key) Value: Remove and return the last item in a list, returns ErrListEmpty if list is empty.
  • ListPopRightBlock(key, seconds) Value: Remove and return the last item in a list, or wait the given seconds for a new value, setting to zero waits forever.
  • ListDelete(key, index): Remove an item from a list by index, returns an error if key or index doesn't exist.
  • ListDeleteItem(key, value) int64: Search for and remove the first occurrence of value from the list, returns index of item or -1 for not found.
  • ListLength(key) int64: Get the number of items in a list.

Hashes

Hashes are objects with multiple string fields.

Functions

  • GetHashField(key, field) Value: Get a single field from a hash, returns ErrHashFieldNotFound if field doesn't exist.
  • GetHashFields(key, fields) map[string]Value: Get multiple fields from a hash, non-existent keys will not be added to the resulting map.
  • HashHas(key) bool: Determines if a hash has a field, returns true or false.
  • HashFields(key) []string: Get a list of hash fields.
  • HashValues(key) []Value: Get a list of hash values.
  • HashLength(key) int64: Get the number of fields in a hash.
  • SetHashField(key, field, value): Set a single field in a hash, creates new hash if key doesn't exist.
  • SetHashFields(key, values): Set multiple fields in a hash, creates new hash if key doesn't exist.
  • DelHashField(key, field): Delete a single field from a hash.

Locks

Keys can be locked from modification.

Functions

  • Lock(key): Lock a key, waiting a default of 5 seconds if a lock already exists on the key before returning ErrKeyLocked.
  • LockWithTimeout(key, seconds): Lock a key, waiting for the given number of seconds if already locked before returning ErrKeyLocked.
  • Unlock(key): Unlock a key.
  • UnlockThenSet(key, value): Unlock a key, then immediately set its value.
  • SetLockTimeout(seconds): Sets the default timeout in seconds if key is already locked.

Events

Using the event handling feature, you can be notified when a key changes.

Functions

  • Watch(key, prefix): Get a notification event when a key changes. When calling one of the set functions, subscribed clients will be notified, including the sender if subscribed. If prefix is true, watches all keys with the given prefix.
  • UnWatch(key, prefix): Stop getting notifications when a key changes.
  • NewEventChannel(): Returns a new Event channel.
  • CloseEventChannel(id): Closes an Event channel.

Authentication

Authentication is handled entirely by Etcd. All auth commands are proxied to Etcd for processing. Once authentication is enabled, the functions below (with the exepction of Authenticate and LogOut) will require a user with the root role. Etcd requires a root user and role to be created before authentication can be enabled. Any user can be assigned the root role afterwards, but the root user must remain for recovery purposes.

Functions

  • AuthEnable(): Enable authentication (must have root user and role created).
  • AuthDisable(): Disable authentication.
  • Authenticate(username, password): Authenticate as the given user.
  • LogOut(): Client-only method, clears the authentication token set by the call to Authenticate.
  • UserAdd(username, password): Creates a new user.
  • UserGet(username): Get list of roles for the given user.
  • UserList(): Get list of all usernames.
  • UserDelete(username): Delete a user.
  • UserChangePassword(username, password): Change a user's password.
  • UserGrantRole(username, role): Grant the user a role.
  • UserRevokeRole(username, role): Revoke a role from the user.
  • RoleAdd(role): Create a new role.
  • RoleGet(role): Get list of permissions for the given role.
  • RoleList(): Get list of all roles.
  • RoleDelete(role): Delete a role.
  • RoleGrantPermission(role, perm): Grant the role a permission.
  • RoleRevokePermission(role, perm): Revoke a permission from a role.

See Etcd's API documentation or the Authentication Guide for version 2. Even though the guide is for an older version of Etcd, the concepts and configuration haven't changed in version 3.

Usage

Server

server := mydis.NewServer(mydis.NewServerConfig())
if err := server.Start(":8000", ":8383"); err != nil {
	log.Fatalln(err)
}

Client

import myClient "github.com/deejross/mydis/client"

client := myClient.NewClient(myClient.NewClientConfig("localhost:8383"))
s, err := client.Get("key").String()
if err != nil {
	return err
}

Limitations

Etcd limits message sizes to 1.5MB, so values cannot be larger than this. The maximum storage size is configurable up to 8GB.

Help Wanted

If you encounter a bug or have an idea for a feature, please open a GitHub issue.

Development

If you are interested in setting up an environment to modify Mydis and submit a pull request, you can follow the instructions in the SETUP document.

License

Mydis is licensed under the Apache 2.0 license. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var VERSION = "1.2.4"

VERSION of Mydis

View Source
var ZeroByte = []byte{0}

ZeroByte represents a single zero byte in a byte slice.

Functions

func ConfigFromYAML

func ConfigFromYAML(b []byte) (*embed.Config, error)

ConfigFromYAML creates a Config object from YAML.

func ConfigToYAML

func ConfigToYAML(config *embed.Config) ([]byte, error)

ConfigToYAML creates a YAML config from a Config object.

func CopyConfig

func CopyConfig(config *embed.Config) *embed.Config

CopyConfig creates a new copy of a Config object.

func GetKeyPrefix added in v1.0.0

func GetKeyPrefix(key string) (bkey []byte, rangEnd []byte)

GetKeyPrefix returns the actual rangeStart and rangeEnd for keys that end with '*'.

func GetPermission added in v1.0.0

func GetPermission(key string, permName string) *pb.Permission

GetPermission returns a new Permission object for the given information or nil if permName unrecognized.

func WebsocketProxy added in v1.2.0

func WebsocketProxy(h http.Handler) http.HandlerFunc

WebsocketProxy attempts to expose the underlying handler as a bidirectional websocket stream with newline-delimited JSON as the content encoding.

The HTTP Authorization header is populated from the Sec-Websocket-Protocol field.

example:

Sec-Websocket-Protocol: Bearer, foobar

is converted to:

Authorization: Bearer foobar

Types

type Server

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

Server object.

func NewServer

func NewServer(config *embed.Config) *Server

NewServer returns a new Server object.

func (*Server) AuthDisable added in v1.0.0

func (s *Server) AuthDisable(ctx context.Context, req *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error)

AuthDisable disables authentication.

func (*Server) AuthEnable added in v1.0.0

func (s *Server) AuthEnable(ctx context.Context, req *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error)

AuthEnable enabled authentication.

func (*Server) Authenticate added in v1.0.0

func (s *Server) Authenticate(ctx context.Context, req *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error)

Authenticate processes an authenticate request.

func (*Server) Clear

func (s *Server) Clear(ctx context.Context, null *pb.Null) (*pb.Null, error)

Clear all keys in the cache.

func (*Server) Close

func (s *Server) Close()

Close the server.

func (*Server) DecrementFloat

func (s *Server) DecrementFloat(ctx context.Context, fv *pb.FloatValue) (*pb.FloatValue, error)

DecrementFloat decrements a float stored at the given key by the number and returns the new value.

func (*Server) DecrementInt

func (s *Server) DecrementInt(ctx context.Context, iv *pb.IntValue) (*pb.IntValue, error)

DecrementInt decrements an integer stored at the given key by the number and returns the new value.

func (*Server) DelHashField

func (s *Server) DelHashField(ctx context.Context, hf *pb.HashField) (*pb.Null, error)

DelHashField removes a field from a hash.

func (*Server) Delete

func (s *Server) Delete(ctx context.Context, key *pb.Key) (*pb.Null, error)

Delete a key from the cache.

func (*Server) Get

func (s *Server) Get(ctx context.Context, key *pb.Key) (*pb.ByteValue, error)

Get a byte array from the cache.

func (*Server) GetFloat

func (s *Server) GetFloat(ctx context.Context, key *pb.Key) (*pb.FloatValue, error)

GetFloat gets a float value for the given key.

func (*Server) GetHash

func (s *Server) GetHash(ctx context.Context, key *pb.Key) (*pb.Hash, error)

GetHash gets a hash from the cache.

func (*Server) GetHashField

func (s *Server) GetHashField(ctx context.Context, hf *pb.HashField) (*pb.ByteValue, error)

GetHashField gets the value of a hash field.

func (*Server) GetHashFields

func (s *Server) GetHashFields(ctx context.Context, hs *pb.HashFieldSet) (*pb.Hash, error)

GetHashFields gets a list of values from a hash.

func (*Server) GetInt

func (s *Server) GetInt(ctx context.Context, key *pb.Key) (*pb.IntValue, error)

GetInt gets an integer value for the given key.

func (*Server) GetList

func (s *Server) GetList(ctx context.Context, key *pb.Key) (*pb.List, error)

GetList from the cache.

func (*Server) GetListItem

func (s *Server) GetListItem(ctx context.Context, li *pb.ListItem) (*pb.ByteValue, error)

GetListItem returns a single item from a list key.

func (*Server) GetMany

func (s *Server) GetMany(ctx context.Context, keys *pb.KeysList) (*pb.Hash, error)

GetMany gets a list of values from the cache.

func (*Server) GetWithPrefix

func (s *Server) GetWithPrefix(ctx context.Context, key *pb.Key) (*pb.Hash, error)

GetWithPrefix gets all byte arrays with the given prefix.

func (*Server) Has

func (s *Server) Has(ctx context.Context, key *pb.Key) (*pb.Bool, error)

Has determines if the given key exists.

func (*Server) HashFields

func (s *Server) HashFields(ctx context.Context, key *pb.Key) (*pb.KeysList, error)

HashFields gets all fields in a hash.

func (*Server) HashHas

func (s *Server) HashHas(ctx context.Context, hf *pb.HashField) (*pb.Bool, error)

HashHas determines if a hash has the given field.

func (*Server) HashLength

func (s *Server) HashLength(ctx context.Context, key *pb.Key) (*pb.IntValue, error)

HashLength gets the number of fields in a hash.

func (*Server) HashValues

func (s *Server) HashValues(ctx context.Context, key *pb.Key) (*pb.List, error)

HashValues gets all values in a hash.

func (*Server) IncrementFloat

func (s *Server) IncrementFloat(ctx context.Context, fv *pb.FloatValue) (*pb.FloatValue, error)

IncrementFloat increments a float stored at the given key by the number and returns the new value.

func (*Server) IncrementInt

func (s *Server) IncrementInt(ctx context.Context, iv *pb.IntValue) (*pb.IntValue, error)

IncrementInt increments an integer stored at the given key by the number and returns the new value.

func (*Server) Keys

func (s *Server) Keys(ctx context.Context, null *pb.Null) (*pb.KeysList, error)

Keys returns a list of valid keys.

func (*Server) KeysWithPrefix

func (s *Server) KeysWithPrefix(ctx context.Context, key *pb.Key) (*pb.KeysList, error)

KeysWithPrefix returns a list of keys with the given prefix.

func (*Server) Length

func (s *Server) Length(ctx context.Context, key *pb.Key) (*pb.IntValue, error)

Length returns the length of the value for the given key.

func (*Server) ListAppend

func (s *Server) ListAppend(ctx context.Context, li *pb.ListItem) (*pb.Null, error)

ListAppend appends an item to the end of a list, creates new list of doesn't exist.

func (*Server) ListDelete

func (s *Server) ListDelete(ctx context.Context, li *pb.ListItem) (*pb.Null, error)

ListDelete removes an item from a list by index.

func (*Server) ListDeleteItem

func (s *Server) ListDeleteItem(ctx context.Context, li *pb.ListItem) (*pb.IntValue, error)

ListDeleteItem removes the first occurrence of value from a list, returns index of removed item or -1 for not found.

func (*Server) ListHas

func (s *Server) ListHas(ctx context.Context, li *pb.ListItem) (*pb.IntValue, error)

ListHas determines if the given value exists in the list, returns index or -1 if not found.

func (*Server) ListInsert

func (s *Server) ListInsert(ctx context.Context, li *pb.ListItem) (*pb.Null, error)

ListInsert inserts a new item into the list at the given index, creates new list if doesn't exist.

func (*Server) ListLength

func (s *Server) ListLength(ctx context.Context, key *pb.Key) (*pb.IntValue, error)

ListLength returns the number of items in the list.

func (*Server) ListLimit

func (s *Server) ListLimit(ctx context.Context, li *pb.ListItem) (*pb.Null, error)

ListLimit sets the maximum length of a list, removing items from the top once limit is reached.

func (*Server) ListPopLeft

func (s *Server) ListPopLeft(ctx context.Context, key *pb.Key) (*pb.ByteValue, error)

ListPopLeft removes and returns the first item in a list.

func (*Server) ListPopRight

func (s *Server) ListPopRight(ctx context.Context, key *pb.Key) (*pb.ByteValue, error)

ListPopRight removes and returns the last item in a list.

func (*Server) Lock

func (s *Server) Lock(ctx context.Context, key *pb.Key) (*pb.Null, error)

Lock a key from being modified. If a lock has already been placed on the key, code will block until lock is released, or until 5 seconds has passed. If 5 second timeout is reached, ErrKeyLocked is returned.

func (*Server) LockWithTimeout

func (s *Server) LockWithTimeout(ctx context.Context, ex *pb.Expiration) (*pb.Null, error)

LockWithTimeout works the same as Lock, but allows the lock timeout to be specified instead of using the default of 5 seconds in the case that a lock has already been placed on the key. Setting expiration to zero will timeout immediately. If expiration is less than zero, timeout will be set to forever.

func (*Server) RoleAdd added in v1.0.0

RoleAdd adds a new role.

func (*Server) RoleDelete added in v1.0.0

RoleDelete deletes a specified role.

func (*Server) RoleGet added in v1.0.0

RoleGet gets detailed role information.

func (*Server) RoleGrantPermission added in v1.0.0

RoleGrantPermission grants a permission of a specified key or range to a specified role.

func (*Server) RoleList added in v1.0.0

RoleList gets a list of all rolls.

func (*Server) RoleRevokePermission added in v1.0.0

RoleRevokePermission revokes a permission of a specified key or range from a specified role.

func (*Server) Set

func (s *Server) Set(ctx context.Context, val *pb.ByteValue) (*pb.Null, error)

Set a byte array in the cache.

func (*Server) SetExpire

func (s *Server) SetExpire(ctx context.Context, ex *pb.Expiration) (*pb.Null, error)

SetExpire sets the expiration in seconds on a key.

func (*Server) SetFloat

func (s *Server) SetFloat(ctx context.Context, fv *pb.FloatValue) (*pb.Null, error)

SetFloat sets a float.

func (*Server) SetHash

func (s *Server) SetHash(ctx context.Context, h *pb.Hash) (*pb.Null, error)

SetHash sets a hash in the cache.

func (*Server) SetHashField

func (s *Server) SetHashField(ctx context.Context, hf *pb.HashField) (*pb.Null, error)

SetHashField sets a single field in a hash, creates new hash if does not exist.

func (*Server) SetHashFields

func (s *Server) SetHashFields(ctx context.Context, ah *pb.Hash) (*pb.Null, error)

SetHashFields sets multiple fields in a hash, creates new hash if does not exist.

func (*Server) SetInt

func (s *Server) SetInt(ctx context.Context, iv *pb.IntValue) (*pb.Null, error)

SetInt sets an integer.

func (*Server) SetList

func (s *Server) SetList(ctx context.Context, lst *pb.List) (*pb.Null, error)

SetList sets a list to the cache.

func (*Server) SetListItem

func (s *Server) SetListItem(ctx context.Context, li *pb.ListItem) (*pb.Null, error)

SetListItem sets a single item in a list, throws ErrListIndexOutOfRange if index is out of range.

func (*Server) SetMany

func (s *Server) SetMany(ctx context.Context, h *pb.Hash) (*pb.ErrorHash, error)

SetMany sets multiple byte arrays. Returns a map[key]errorText of any errors encountered.

func (*Server) SetNX

func (s *Server) SetNX(ctx context.Context, val *pb.ByteValue) (*pb.Bool, error)

SetNX sets a value only if the key doesn't exist, returns true if changed.

func (*Server) Start

func (s *Server) Start(http1, http2 string) error

Start the server.

func (*Server) Unlock

func (s *Server) Unlock(ctx context.Context, key *pb.Key) (*pb.Null, error)

Unlock a key for modifications.

func (*Server) UnlockThenSet

func (s *Server) UnlockThenSet(ctx context.Context, val *pb.ByteValue) (*pb.Null, error)

UnlockThenSet unlocks a key, then immediately sets a new value for it.

func (*Server) UnlockThenSetHash

func (s *Server) UnlockThenSetHash(ctx context.Context, val *pb.Hash) (*pb.Null, error)

UnlockThenSetHash unlocks a key, then immediately sets a hash value for it.

func (*Server) UnlockThenSetList

func (s *Server) UnlockThenSetList(ctx context.Context, val *pb.List) (*pb.Null, error)

UnlockThenSetList unlocks a key, then immediately sets a list value for it.

func (*Server) UserAdd added in v1.0.0

UserAdd adds a new user.

func (*Server) UserChangePassword added in v1.0.0

UserChangePassword changes the password of a specified user.

func (*Server) UserDelete added in v1.0.0

UserDelete deletes a specified user.

func (*Server) UserGet added in v1.0.0

UserGet gets detailed information for a user.

func (*Server) UserGrantRole added in v1.0.0

UserGrantRole grants a role to a specified user.

func (*Server) UserList added in v1.0.0

UserList gets a list of all users.

func (*Server) UserRevokeRole added in v1.0.0

UserRevokeRole revokes a role from a specified user.

func (*Server) Watch

func (s *Server) Watch(stream pb.Mydis_WatchServer) error

Watch a key for changes.

type WatchController

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

WatchController object.

func NewWatchController

func NewWatchController(server *etcdserver.EtcdServer) *WatchController

NewWatchController returns a new WatchController object.

func (*WatchController) Close

func (w *WatchController) Close()

Close the WatchController.

func (*WatchController) NewWatcher

func (w *WatchController) NewWatcher() *Watcher

NewWatcher returns a new Watcher object.

type Watcher

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

Watcher object.

func (*Watcher) Close

func (w *Watcher) Close()

Close the Watcher.

func (*Watcher) RequestID

func (w *Watcher) RequestID(r *pb.WatchRequest) string

RequestID gets the string ID from the WatchRequest.

Directories

Path Synopsis
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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