Metadata

Class: Metadata

new Metadata( options)

Class for storing metadata. Keys are normalized to lowercase ASCII.

Parameters:

NameTypeArgumentDescription
optionsObjectoptionalBoolean options for the beginning of the call. These options only have any effect when passed at the beginning of a client request.
Properties
NameTypeArgumentDefaultDescription
idempotentRequestbooleanoptionalfalseSignal that the request is idempotent
waitForReadybooleanoptionaltrueSignal that the call should not return UNAVAILABLE before it has started.
cacheableRequestbooleanoptionalfalseSignal that the call is cacheable. GRPC is free to use GET verb.
corkedbooleanoptionalfalseSignal that the initial metadata should be corked.
Example
var metadata = new metadata_module.Metadata();
metadata.set('key1''value1');
metadata.add('key1''value2');
metadata.get('key1') // returns ['value1''value2']

Methods


add(key, value)

Adds the given value for the given key. Normalizes the key.

Parameters:
NameTypeDescription
keyStringThe key to add to.
valueString/BufferThe value to add. Must be a buffer if and only if the normalized key ends with '-bin'

clone()

Clone the metadata object.

Returns:

The new cloned object


get(key)

Gets a list of all values associated with the key. Normalizes the key.

Parameters:
NameTypeDescription
keyStringThe key to get
Returns:

The values associated with that key

Type

Array.<(String|Buffer)>


getMap()

Get a map of each key to a single associated value. This reflects the most common way that people will want to see metadata.

Returns:

A key/value mapping of the metadata

Type

Object.<String, (String|Buffer)>


remove(key)

Remove the given key and any associated values. Normalizes the key.

Parameters:
NameTypeDescription
keyStringThe key to remove

set(key, value)

Sets the given value for the given key, replacing any other values associated with that key. Normalizes the key.

Parameters:
NameTypeDescription
keyStringThe key to set
valueString/BufferThe value to set. Must be a buffer if and only if the normalized key ends with '-bin'

setOptions(options)

Set options on the metadata object

Parameters:
NameTypeDescription
optionsObjectBoolean options for the beginning of the call. These options only have any effect when passed at the beginning of a client request.
Properties
NameTypeArgumentDefaultDescription
idempotentRequestbooleanoptionalfalseSignal that the request is idempotent
waitForReadybooleanoptionaltrueSignal that the call should not return UNAVAILABLE before it has started.
cacheableRequestbooleanoptionalfalseSignal that the call is cacheable. GRPC is free to use GET verb.
corkedbooleanoptionalfalseSignal that the initial metadata should be corked.