mydis

package
v2.0.2+incompatible 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: 2

Documentation

Index

Constants

This section is empty.

Variables

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

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

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

func GetPermission

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

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

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

AuthDisable disables authentication.

func (*Server) AuthEnable

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

AuthEnable enabled authentication.

func (*Server) Authenticate

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

RoleAdd adds a new role.

func (*Server) RoleDelete

RoleDelete deletes a specified role.

func (*Server) RoleGet

RoleGet gets detailed role information.

func (*Server) RoleGrantPermission

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

func (*Server) RoleList

RoleList gets a list of all rolls.

func (*Server) RoleRevokePermission

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

UserAdd adds a new user.

func (*Server) UserChangePassword

UserChangePassword changes the password of a specified user.

func (*Server) UserDelete

UserDelete deletes a specified user.

func (*Server) UserGet

UserGet gets detailed information for a user.

func (*Server) UserGrantRole

UserGrantRole grants a role to a specified user.

func (*Server) UserList

UserList gets a list of all users.

func (*Server) UserRevokeRole

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.

Jump to

Keyboard shortcuts

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