Module eetcd_kv

Function Index

compact/1Compact compacts etcd KV history before the given revision.
compact/2Compact compacts etcd KV history before the given revision with options.
delete/1Delete deletes a key, or optionally using eetcd_kv:with_range(End), [Key, End).
delete/2Delete deletes a key with options.
get/1Get retrieves keys.
get/2Get retrieves keys with options.
new/0
new/1Create context for request.
put/1Put puts a key-value pair into etcd.
put/3Put puts a key-value pair into etcd with options put/1
txn/4Txn creates a transaction.
with_count_only/1Make the get request return only the count of keys.
with_first_create/1Get the key with the oldest creation revision in the request range.
with_first_key/1Get the lexically first key in the request range.
with_first_rev/1Get the key with the oldest modification revision in the request range.
with_from_key/1Specifies the range of get, delete requests to be equal or greater than the key in the argument.
with_ignore_lease/1Update the key using its current lease.
with_ignore_value/1Update the key using its current value.
with_key/2Sets data for the request's key.
with_keys_only/1Make the get request return only the keys and the corresponding values will be omitted.
with_last_create/1Get the lexically last key in the request range.
with_last_key/1Get the lexically last key in the request range.
with_last_rev/1Get the key with the latest modification revision in the request range.
with_lease/2Attache a lease ID to a key in put request.
with_limit/2Limit the number of results to return from get request.
with_max_create_rev/2Filter out keys for get with creation revisions greater than the given revision.
with_max_mod_rev/2Filter out keys for get with modification revisions greater than the given revision.
with_min_create_rev/2Filter out keys for get with creation revisions less than the given revision.
with_min_mod_rev/2Filter out keys for get with modification revisions less than the given revision.
with_physical/1WithPhysical makes Compact wait until all compacted entries are removed from the etcd server's storage.
with_prefix/1Enables get, delete requests to operate on the keys with matching prefix.
with_prev_kv/1Get the previous key-value pair before the event happens.
with_range_end/2Sets data for the request's range_end.
with_rev/2Specifies the store revision for get request.
with_serializable/1Make get request serializable.
with_sort/3Specifies the ordering in get request.
with_timeout/2Timeout is an integer greater than zero which specifies how many milliseconds to wait for a reply, or the atom infinity to wait indefinitely.
with_top/3Get the first key over the get's prefix given a sort order.
with_value/2Sets data for the request's value.

Function Details

compact/1

compact(Context::context()) -> {ok, router_pb:'Etcd.CompactionResponse'()} | {error, eetcd_error()}

Compact compacts etcd KV history before the given revision.

1.base
eetcd_kv:compact(ConnName,Revision).
2.with physical
eetcd_kv:compact(eetcd_kv:with_physical(eetcd_kv:with_revision(eetcd_kv:new(ConnName), Revision))).
3.Elixir
   :eetcd_kv.new(ConnName)
   |> :eetcd_kv.with_revision(revision)
   |> :eetcd_kv.with_physical()
   |> :eetcd_kv.compact()
eetcd_kv:with_revision/2 eetcd_kv:with_physical/1

compact/2

compact(Context::name() | context(), Revision::integer()) -> {ok, router_pb:'Etcd.CompactionResponse'()} | {error, eetcd_error()}

Compact compacts etcd KV history before the given revision with options

delete/1

delete(Context::context()) -> {ok, router_pb:'Etcd.DeleteRangeResponse'()} | {error, eetcd_error()}

Delete deletes a key, or optionally using eetcd_kv:with_range(End), [Key, End).

1.base
eetcd_kv:delete(ConnName,Key).
2.with range end
eetcd_kv:delete(eetcd_kv:with_range_end(eetcd_kv:with_key(eetcd_kv:new(ConnName),Key), End)).
3.elixir
   :eetcd_kv.new(ConnName)
   |> :eetcd_kv.with_key(key)
   |> :eetcd_kv.with_range_end(rangeEnd)
   |> :eetcd_kv.with_prev_kv()
   |> :eetcd_kv.delete()
eetcd_kv:with_key/2 eetcd_kv:with_range_end/2 eetcd_kv:with_prev_kv/1

delete/2

delete(Context::name() | context(), Key::key()) -> {ok, router_pb:'Etcd.DeleteRangeResponse'()} | {error, eetcd_error()}

Delete deletes a key with options

get/1

get(Context::context()) -> {ok, router_pb:'Etcd.RangeResponse'()} | {error, eetcd_error()}

Get retrieves keys. By default, Get will return the value for Key, if any. When passed eetcd_kv:with_range_end/2, Get will return the keys in the range [Key, End). When passed eetcd_kv:with_from_key/1, Get returns keys greater than or equal to key. When passed eetcd_kv:with_revision/2 with Rev > 0, Get retrieves keys at the given revision; if the required revision is compacted, the request will fail with ErrCompacted. When passed eetcd_kv:with_limit/1, the number of returned keys is bounded by Limit. When passed eetcd_kv:with_sort/3, the keys will be sorted.

1.base
eetcd_kv:get(ConnName,Key).
2.with range end
eetcd_kv:get(eetcd_kv:with_range_end(eetcd_kv:with_key(eetcd_kv:new(ConnName),Key),End)).
3.Elixir
   :eetcd_kv.new(connName)
   |> :eetcd_kv.with_key(key)
   |> :eetcd_kv.with_range_end(rangeEnd)
   |> :eetcd_kv.with_limit(limit)
   |> :eetcd_kv.with_revision(rev)
   |> :eetcd_kv.with_sort(:'KEY', :'ASCEND')  %% 'NONE' | 'ASCEND' | 'DESCEND' enum Etcd.RangeRequest.SortOrder
   |> :eetcd_kv.with_serializable()
   |> :eetcd_kv.with_keys_only()
   |> :eetcd_kv.with_count_only()
   |> :eetcd_kv.with_min_mod_revision(minModRev)
   |> :eetcd_kv.with_max_mod_revision(maxModRev)
   |> :eetcd_kv.with_min_create_revision(minCreateRev)
   |> :eetcd_kv.with_max_create_revision(maxCreateRev)
   |> :eetcd_kv:get()
eetcd_kv:with_key/2 eetcd_kv:with_range_end/2 eetcd_kv:with_limit/2 eetcd_kv:with_revision/2 eetcd_kv:with_sort/3 eetcd_kv:with_serializable/1 eetcd_kv:with_keys_only/1 eetcd_kv:with_count_only/1 eetcd_kv:with_min_mod_revision/2 eetcd_kv:with_max_mod_revision/2 eetcd_kv:with_min_create_revision/2 eetcd_kv:with_max_create_revision/2

get/2

get(Context::context() | name(), Key::key()) -> {ok, router_pb:'Etcd.RangeResponse'()} | {error, eetcd_error()}

Get retrieves keys with options.

new/0

new() -> context()

new/1

new(Context::atom() | reference()) -> context()

Create context for request.

put/1

put(Context::context()) -> {ok, router_pb:'Etcd.PutResponse'()} | {error, eetcd_error()}

Put puts a key-value pair into etcd.

1. base
eetcd_kv:put(ConnName, Key, Value).
2. with lease id
eetcd_kv:put(Key, Value, eetcd_kv:with_lease(eetcd_kv:new(ConnName), LeaseID)).
3. elixir
   :eetcd_kv.new(connName)
   |> :eetcd_kv.with_key(key)
   |> :eetcd_kv.with_value(value)
   |> :eetcd_kv.with_lease(leaseId)
   |> :eetcd_kv.with_ignore_value()
   |> :eetcd_kv.with_timeout(6000)
   |> :eetcd_kv.put()
eetcd_kv:with_key/2, eetcd_kv:with_value/2, eetcd_kv:with_lease/2, eetcd_kv:with_ignore_value/2, eetcd_kv:with_ignore_lease/2, eetcd_kv:with_timeout/2

put/3

put(Context::name() | context(), Key::key(), Value::value()) -> {ok, router_pb:'Etcd.PutResponse'()} | {error, eetcd_error()}

Put puts a key-value pair into etcd with options put/1

txn/4

txn(Context::name() | context(), If::[router_pb:'Etcd.Compare'()], Then::[router_pb:'Etcd.RequestOp'()], Else::[router_pb:'Etcd.RequestOp'()]) -> {ok, router_pb:'Etcd.TxnResponse'()} | {error, eetcd_error()}

Txn creates a transaction.

If takes a list of comparison. If all comparisons passed in succeed,
the operations passed into Then() will be executed.
Or the operations passed into Else() will be executed.
Then takes a list of operations. The Ops list will be executed, if the comparisons passed in If() succeed.
Else takes a list of operations. The Ops list will be executed, if the comparisons passed in If() fail.
   Cmp = eetcd_compare:new(Key),
   If = eetcd_compare:value(Cmp, ">", Value),
   Then = eetcd_op:put(eetcd_kv:with_value(eetcd_kv:with_key(eetcd_kv:new(), Key), NewValue)),
   Else = eetcd_op:delete(eetcd_kv:with_key(eetcd_kv:new(), Key)),
   eetcd_kv:txn(EtcdConnName, If, Then, Else).
eetcd_compare:new/1 eetcd_compare:with_range/2 eetcd_compare:value/3 eetcd_compare:version/3 eetcd_compare:mod_revision/3 eetcd_compare:create_revision/3 eetcd_compare:lease/3 eetcd_op:put/1 eetcd_op:get/1 eetcd_op:delete/1 eetcd_op:txn/1

with_count_only/1

with_count_only(Context::context()) -> context()

Make the get request return only the count of keys.

with_first_create/1

with_first_create(Context::context()) -> context()

Get the key with the oldest creation revision in the request range.

with_first_key/1

with_first_key(Context::context()) -> context()

Get the lexically first key in the request range.

with_first_rev/1

with_first_rev(Context::context()) -> context()

Get the key with the oldest modification revision in the request range.

with_from_key/1

with_from_key(Context::context()) -> context()

Specifies the range of get, delete requests to be equal or greater than the key in the argument.

with_ignore_lease/1

with_ignore_lease(Context::context()) -> context()

Update the key using its current lease. This option can not be combined with with_lease/2. Returns an error if the key does not exist.

with_ignore_value/1

with_ignore_value(Context::context()) -> context()

Update the key using its current value. This option can not be combined with non-empty values. Returns an error if the key does not exist.

with_key/2

with_key(Context::context(), Key::key()) -> context()

Sets data for the request's key.

with_keys_only/1

with_keys_only(Context::context()) -> context()

Make the get request return only the keys and the corresponding values will be omitted.

with_last_create/1

with_last_create(Context::context()) -> context()

Get the lexically last key in the request range.

with_last_key/1

with_last_key(Context::context()) -> context()

Get the lexically last key in the request range.

with_last_rev/1

with_last_rev(Context::context()) -> context()

Get the key with the latest modification revision in the request range.

with_lease/2

with_lease(Context::context(), Id::integer()) -> context()

Attache a lease ID to a key in put request.

with_limit/2

with_limit(Context::context(), End::iodata()) -> context()

Limit the number of results to return from get request. If with_limit is given a 0 limit, it is treated as no limit.

with_max_create_rev/2

with_max_create_rev(Context::context(), Rev::pos_integer()) -> context()

Filter out keys for get with creation revisions greater than the given revision.

with_max_mod_rev/2

with_max_mod_rev(Context::context(), Rev::pos_integer()) -> context()

Filter out keys for get with modification revisions greater than the given revision.

with_min_create_rev/2

with_min_create_rev(Context::context(), Rev::pos_integer()) -> context()

Filter out keys for get with creation revisions less than the given revision.

with_min_mod_rev/2

with_min_mod_rev(Context::context(), Rev::pos_integer()) -> context()

Filter out keys for get with modification revisions less than the given revision.

with_physical/1

with_physical(Context::context()) -> context()

WithPhysical makes Compact wait until all compacted entries are removed from the etcd server's storage.

with_prefix/1

with_prefix(Context::context()) -> context()

Enables get, delete requests to operate on the keys with matching prefix. For example, get(with_prefix(with_key(Ctx, "foo")) can return 'foo1', 'foo2', and so on.

with_prev_kv/1

with_prev_kv(Context::context()) -> context()

Get the previous key-value pair before the event happens. If the previous KV is already compacted, nothing will be returned.

with_range_end/2

with_range_end(Context::context(), End::iodata()) -> context()

Sets data for the request's range_end.

with_rev/2

with_rev(Context::context(), Rev::pos_integer()) -> context()

Specifies the store revision for get request.

with_serializable/1

with_serializable(Context::context()) -> context()

Make get request serializable. By default, it's linearizable. Serializable requests are better for lower latency requirement.

with_sort/3

with_sort(Context::context(), Target::'KEY' | 'VERSION' | 'VALUE' | 'CREATE' | 'MOD', Order::'NONE' | 'ASCEND' | 'DESCEND') -> context()

Specifies the ordering in get request. It requires with_range and/or with_prefix to be specified too. target specifies the target to sort by: 'KEY', 'VERSION', 'VALUE', 'CREATE', 'MOD'. order can be either 'NONE', 'ASCEND', 'DESCEND'.

with_timeout/2

with_timeout(Context::context(), Timeout::pos_integer() | infinity) -> context()

Timeout is an integer greater than zero which specifies how many milliseconds to wait for a reply, or the atom infinity to wait indefinitely. Default value is 5000. If no reply is received within the specified time, the function call fails with {error, timeout}.

with_top/3

with_top(Context::context(), SortTarget::'KEY' | 'VERSION' | 'VALUE' | 'CREATE' | 'MOD', SortOrder::'NONE' | 'ASCEND' | 'DESCEND') -> context()

Get the first key over the get's prefix given a sort order

with_value/2

with_value(Context::context(), Key::key()) -> context()

Sets data for the request's value.


Generated by EDoc