API: client
Source:
etcd/client.ts
Converts a string to a native Etcd ByteSequence object. @param str The string to convert. @returns The native ByteSequence object (Java type).
Usage
// Load the etcd client module.
import { etcd } from "sdk/etcd";
// Initialize the etcd client.
let etcdClient = etcd.getClient();
// Put key-value pair where the value is a string.
etcdClient.putStringValue("foo", "bar");
// Get key-value pair where value will be returned as a string.
etcdClient.getKvsStringValue("foo"); // => { "foo": "bar" }
// Put key-value pair where the value is a byte array.
etcdClient.putByteArrayValue("foo", [98, 97, 114]);
// Get key-value pair where value will be returned as a byte array.
etcdClient.getKvsByteArrayValue("foo"); // => { "foo": [98, 97, 114] }
// Delete key-value pair.
etcdClient.delete("foo");Classes
Header
Represents the header metadata of an Etcd response.
Methods
getRevision
getRevision ():stringThe revision of the key-value store when the request was processed.
getClusterId
getClusterId ():stringThe ID of the cluster which the request was sent to.
getMemberId
getMemberId ():stringThe ID of the member which the request was handled by.
getRaftTerm
getRaftTerm ():stringThe Raft term.
GetResponse
Represents the response object for a Get operation from Etcd.
Methods
getHeader
getHeader ():HeaderRetrieves the response header containing cluster metadata.
getKvsString
getKvsString ():string}Retrieves the Key-Value pairs with values converted to strings.
getKvsByteArray
getKvsByteArray ():Int8Array}Retrieves the Key-Value pairs with values converted to Int8Array (byte arrays).
getCount
getCount ():numberRetrieves the number of Key-Value pairs returned.
Client
Client facade for interacting with the Etcd key-value store.
Methods
get
get (key:string):GetResponseExecutes a blocking GET request on the specified key.
@param key The key to retrieve.
@returns The processed GetResponse object.
putStringValue
putStringValue (key:string, value:string):voidPuts (writes) a string value to the specified key.
@param key The key to write to.
@param value The string value.
putByteArrayValue
putByteArrayValue (key:string, value:Int8Array):voidPuts (writes) a byte array value to the specified key.
@param key The key to write to.
@param value The Int8Array (byte array) value.
getHeader
getHeader (key:string):HeaderRetrieves the response header metadata for a key.
@param key The key to query.
@returns The {@link Header} object.
getKvsStringValue
getKvsStringValue (key:string):string}Retrieves the Key-Value pairs as a JavaScript object with string values.
@param key The key (or key prefix) to query.
@returns An object mapping keys to string values.
getKvsByteArrayValue
getKvsByteArrayValue (key:string):Int8Array}Retrieves the Key-Value pairs as a JavaScript object with Int8Array values.
@param key The key (or key prefix) to query.
@returns An object mapping keys to Int8Array values.
getCount
getCount (key:string):numberRetrieves the count of Key-Value pairs matching the key (or key prefix).
@param key The key (or key prefix) to query.
@returns The count of matching entries.
delete
delete (key:string):voidDeletes the specified key.
@param key The key to delete.