Documentation ¶
Index ¶
- Variables
- func ConfigFromYAML(b []byte) (*embed.Config, error)
- func ConfigToYAML(config *embed.Config) ([]byte, error)
- func CopyConfig(config *embed.Config) *embed.Config
- func GetKeyPrefix(key string) (bkey []byte, rangEnd []byte)
- func GetPermission(key string, permName string) *pb.Permission
- func WebsocketProxy(h http.Handler) http.HandlerFunc
- type Server
- func (s *Server) AuthDisable(ctx context.Context, req *pb.AuthDisableRequest) (*pb.AuthDisableResponse, error)
- func (s *Server) AuthEnable(ctx context.Context, req *pb.AuthEnableRequest) (*pb.AuthEnableResponse, error)
- func (s *Server) Authenticate(ctx context.Context, req *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error)
- func (s *Server) Clear(ctx context.Context, null *pb.Null) (*pb.Null, error)
- func (s *Server) Close()
- func (s *Server) DecrementFloat(ctx context.Context, fv *pb.FloatValue) (*pb.FloatValue, error)
- func (s *Server) DecrementInt(ctx context.Context, iv *pb.IntValue) (*pb.IntValue, error)
- func (s *Server) DelHashField(ctx context.Context, hf *pb.HashField) (*pb.Null, error)
- func (s *Server) Delete(ctx context.Context, key *pb.Key) (*pb.Null, error)
- func (s *Server) Get(ctx context.Context, key *pb.Key) (*pb.ByteValue, error)
- func (s *Server) GetFloat(ctx context.Context, key *pb.Key) (*pb.FloatValue, error)
- func (s *Server) GetHash(ctx context.Context, key *pb.Key) (*pb.Hash, error)
- func (s *Server) GetHashField(ctx context.Context, hf *pb.HashField) (*pb.ByteValue, error)
- func (s *Server) GetHashFields(ctx context.Context, hs *pb.HashFieldSet) (*pb.Hash, error)
- func (s *Server) GetInt(ctx context.Context, key *pb.Key) (*pb.IntValue, error)
- func (s *Server) GetList(ctx context.Context, key *pb.Key) (*pb.List, error)
- func (s *Server) GetListItem(ctx context.Context, li *pb.ListItem) (*pb.ByteValue, error)
- func (s *Server) GetMany(ctx context.Context, keys *pb.KeysList) (*pb.Hash, error)
- func (s *Server) GetWithPrefix(ctx context.Context, key *pb.Key) (*pb.Hash, error)
- func (s *Server) Has(ctx context.Context, key *pb.Key) (*pb.Bool, error)
- func (s *Server) HashFields(ctx context.Context, key *pb.Key) (*pb.KeysList, error)
- func (s *Server) HashHas(ctx context.Context, hf *pb.HashField) (*pb.Bool, error)
- func (s *Server) HashLength(ctx context.Context, key *pb.Key) (*pb.IntValue, error)
- func (s *Server) HashValues(ctx context.Context, key *pb.Key) (*pb.List, error)
- func (s *Server) IncrementFloat(ctx context.Context, fv *pb.FloatValue) (*pb.FloatValue, error)
- func (s *Server) IncrementInt(ctx context.Context, iv *pb.IntValue) (*pb.IntValue, error)
- func (s *Server) Keys(ctx context.Context, null *pb.Null) (*pb.KeysList, error)
- func (s *Server) KeysWithPrefix(ctx context.Context, key *pb.Key) (*pb.KeysList, error)
- func (s *Server) Length(ctx context.Context, key *pb.Key) (*pb.IntValue, error)
- func (s *Server) ListAppend(ctx context.Context, li *pb.ListItem) (*pb.Null, error)
- func (s *Server) ListDelete(ctx context.Context, li *pb.ListItem) (*pb.Null, error)
- func (s *Server) ListDeleteItem(ctx context.Context, li *pb.ListItem) (*pb.IntValue, error)
- func (s *Server) ListHas(ctx context.Context, li *pb.ListItem) (*pb.IntValue, error)
- func (s *Server) ListInsert(ctx context.Context, li *pb.ListItem) (*pb.Null, error)
- func (s *Server) ListLength(ctx context.Context, key *pb.Key) (*pb.IntValue, error)
- func (s *Server) ListLimit(ctx context.Context, li *pb.ListItem) (*pb.Null, error)
- func (s *Server) ListPopLeft(ctx context.Context, key *pb.Key) (*pb.ByteValue, error)
- func (s *Server) ListPopRight(ctx context.Context, key *pb.Key) (*pb.ByteValue, error)
- func (s *Server) Lock(ctx context.Context, key *pb.Key) (*pb.Null, error)
- func (s *Server) LockWithTimeout(ctx context.Context, ex *pb.Expiration) (*pb.Null, error)
- func (s *Server) RoleAdd(ctx context.Context, req *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
- func (s *Server) RoleDelete(ctx context.Context, req *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error)
- func (s *Server) RoleGet(ctx context.Context, req *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
- func (s *Server) RoleGrantPermission(ctx context.Context, req *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error)
- func (s *Server) RoleList(ctx context.Context, req *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error)
- func (s *Server) RoleRevokePermission(ctx context.Context, req *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error)
- func (s *Server) Set(ctx context.Context, val *pb.ByteValue) (*pb.Null, error)
- func (s *Server) SetExpire(ctx context.Context, ex *pb.Expiration) (*pb.Null, error)
- func (s *Server) SetFloat(ctx context.Context, fv *pb.FloatValue) (*pb.Null, error)
- func (s *Server) SetHash(ctx context.Context, h *pb.Hash) (*pb.Null, error)
- func (s *Server) SetHashField(ctx context.Context, hf *pb.HashField) (*pb.Null, error)
- func (s *Server) SetHashFields(ctx context.Context, ah *pb.Hash) (*pb.Null, error)
- func (s *Server) SetInt(ctx context.Context, iv *pb.IntValue) (*pb.Null, error)
- func (s *Server) SetList(ctx context.Context, lst *pb.List) (*pb.Null, error)
- func (s *Server) SetListItem(ctx context.Context, li *pb.ListItem) (*pb.Null, error)
- func (s *Server) SetMany(ctx context.Context, h *pb.Hash) (*pb.ErrorHash, error)
- func (s *Server) SetNX(ctx context.Context, val *pb.ByteValue) (*pb.Bool, error)
- func (s *Server) Start(http1, http2 string) error
- func (s *Server) Unlock(ctx context.Context, key *pb.Key) (*pb.Null, error)
- func (s *Server) UnlockThenSet(ctx context.Context, val *pb.ByteValue) (*pb.Null, error)
- func (s *Server) UnlockThenSetHash(ctx context.Context, val *pb.Hash) (*pb.Null, error)
- func (s *Server) UnlockThenSetList(ctx context.Context, val *pb.List) (*pb.Null, error)
- func (s *Server) UserAdd(ctx context.Context, req *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error)
- func (s *Server) UserChangePassword(ctx context.Context, req *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error)
- func (s *Server) UserDelete(ctx context.Context, req *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error)
- func (s *Server) UserGet(ctx context.Context, req *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
- func (s *Server) UserGrantRole(ctx context.Context, req *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error)
- func (s *Server) UserList(ctx context.Context, req *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error)
- func (s *Server) UserRevokeRole(ctx context.Context, req *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error)
- func (s *Server) Watch(stream pb.Mydis_WatchServer) error
- type WatchController
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var VERSION = "1.2.4"
VERSION of Mydis
var ZeroByte = []byte{0}
ZeroByte represents a single zero byte in a byte slice.
Functions ¶
func ConfigFromYAML ¶
ConfigFromYAML creates a Config object from YAML.
func ConfigToYAML ¶
ConfigToYAML creates a YAML config from a Config object.
func CopyConfig ¶
CopyConfig creates a new copy of a Config object.
func GetKeyPrefix ¶ added in v1.0.0
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 (*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) 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 ¶
DecrementInt decrements an integer stored at the given key by the number and returns the new value.
func (*Server) DelHashField ¶
DelHashField removes a field from a hash.
func (*Server) GetHashField ¶
GetHashField gets the value of a hash field.
func (*Server) GetHashFields ¶
GetHashFields gets a list of values from a hash.
func (*Server) GetListItem ¶
GetListItem returns a single item from a list key.
func (*Server) GetWithPrefix ¶
GetWithPrefix gets all byte arrays with the given prefix.
func (*Server) HashFields ¶
HashFields gets all fields in a hash.
func (*Server) HashLength ¶
HashLength gets the number of fields in a hash.
func (*Server) HashValues ¶
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 ¶
IncrementInt increments an integer stored at the given key by the number and returns the new value.
func (*Server) KeysWithPrefix ¶
KeysWithPrefix returns a list of keys with the given prefix.
func (*Server) ListAppend ¶
ListAppend appends an item to the end of a list, creates new list of doesn't exist.
func (*Server) ListDelete ¶
ListDelete removes an item from a list by index.
func (*Server) ListDeleteItem ¶
ListDeleteItem removes the first occurrence of value from a list, returns index of removed item or -1 for not found.
func (*Server) ListHas ¶
ListHas determines if the given value exists in the list, returns index or -1 if not found.
func (*Server) ListInsert ¶
ListInsert inserts a new item into the list at the given index, creates new list if doesn't exist.
func (*Server) ListLength ¶
ListLength returns the number of items in the list.
func (*Server) ListLimit ¶
ListLimit sets the maximum length of a list, removing items from the top once limit is reached.
func (*Server) ListPopLeft ¶
ListPopLeft removes and returns the first item in a list.
func (*Server) ListPopRight ¶
ListPopRight removes and returns the last item in a list.
func (*Server) Lock ¶
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 ¶
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
func (s *Server) RoleAdd(ctx context.Context, req *pb.AuthRoleAddRequest) (*pb.AuthRoleAddResponse, error)
RoleAdd adds a new role.
func (*Server) RoleDelete ¶ added in v1.0.0
func (s *Server) RoleDelete(ctx context.Context, req *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDeleteResponse, error)
RoleDelete deletes a specified role.
func (*Server) RoleGet ¶ added in v1.0.0
func (s *Server) RoleGet(ctx context.Context, req *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse, error)
RoleGet gets detailed role information.
func (*Server) RoleGrantPermission ¶ added in v1.0.0
func (s *Server) RoleGrantPermission(ctx context.Context, req *pb.AuthRoleGrantPermissionRequest) (*pb.AuthRoleGrantPermissionResponse, error)
RoleGrantPermission grants a permission of a specified key or range to a specified role.
func (*Server) RoleList ¶ added in v1.0.0
func (s *Server) RoleList(ctx context.Context, req *pb.AuthRoleListRequest) (*pb.AuthRoleListResponse, error)
RoleList gets a list of all rolls.
func (*Server) RoleRevokePermission ¶ added in v1.0.0
func (s *Server) RoleRevokePermission(ctx context.Context, req *pb.AuthRoleRevokePermissionRequest) (*pb.AuthRoleRevokePermissionResponse, error)
RoleRevokePermission revokes a permission of a specified key or range from a specified role.
func (*Server) SetHashField ¶
SetHashField sets a single field in a hash, creates new hash if does not exist.
func (*Server) SetHashFields ¶
SetHashFields sets multiple fields in a hash, creates new hash if does not exist.
func (*Server) SetListItem ¶
SetListItem sets a single item in a list, throws ErrListIndexOutOfRange if index is out of range.
func (*Server) SetMany ¶
SetMany sets multiple byte arrays. Returns a map[key]errorText of any errors encountered.
func (*Server) UnlockThenSet ¶
UnlockThenSet unlocks a key, then immediately sets a new value for it.
func (*Server) UnlockThenSetHash ¶
UnlockThenSetHash unlocks a key, then immediately sets a hash value for it.
func (*Server) UnlockThenSetList ¶
UnlockThenSetList unlocks a key, then immediately sets a list value for it.
func (*Server) UserAdd ¶ added in v1.0.0
func (s *Server) UserAdd(ctx context.Context, req *pb.AuthUserAddRequest) (*pb.AuthUserAddResponse, error)
UserAdd adds a new user.
func (*Server) UserChangePassword ¶ added in v1.0.0
func (s *Server) UserChangePassword(ctx context.Context, req *pb.AuthUserChangePasswordRequest) (*pb.AuthUserChangePasswordResponse, error)
UserChangePassword changes the password of a specified user.
func (*Server) UserDelete ¶ added in v1.0.0
func (s *Server) UserDelete(ctx context.Context, req *pb.AuthUserDeleteRequest) (*pb.AuthUserDeleteResponse, error)
UserDelete deletes a specified user.
func (*Server) UserGet ¶ added in v1.0.0
func (s *Server) UserGet(ctx context.Context, req *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse, error)
UserGet gets detailed information for a user.
func (*Server) UserGrantRole ¶ added in v1.0.0
func (s *Server) UserGrantRole(ctx context.Context, req *pb.AuthUserGrantRoleRequest) (*pb.AuthUserGrantRoleResponse, error)
UserGrantRole grants a role to a specified user.
func (*Server) UserList ¶ added in v1.0.0
func (s *Server) UserList(ctx context.Context, req *pb.AuthUserListRequest) (*pb.AuthUserListResponse, error)
UserList gets a list of all users.
func (*Server) UserRevokeRole ¶ added in v1.0.0
func (s *Server) UserRevokeRole(ctx context.Context, req *pb.AuthUserRevokeRoleRequest) (*pb.AuthUserRevokeRoleResponse, error)
UserRevokeRole revokes a role from a specified user.
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) NewWatcher ¶
func (w *WatchController) NewWatcher() *Watcher
NewWatcher returns a new Watcher object.