Add mapping layer for keys

Open
#44 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
go

Research direction

Start by reading the Store interface and the store configuration objects in libkv, then inspect the Consul implementation and its currently supported key paths. Compare the proposed namespace constants, mapping function, and NS methods against existing APIs; done means the design is agreed, existing callers remain compatible, and the additional namespaces and mappings are covered.

Written by the indexing model from the issue text.

Description

I think it would be useful to have a simple mapping function for each store to allow access to arbitrary keys. This is especially useful for stores like consul where currently only a subset of keys is accessible (e.g. /kv). There are additional keys available below /catalog/services for example.
I propose some changes to the API of libkv:

  • Add namespace constants to libkv. These are for example const (KV = 0, AGENT = 1, CATALOG = 2, SESSIONS=3, HEALTHCHECKS=4, ACLS=5, EVENTS=6, STATUS=7 ) These are Consul namespaces which, except for KV, are not accessible by libkv. There could be more.
  • Add an optional func map(namespace int, key string) (int, string) to each store's configuration object. This function allow mapping of namespaces and strings to different values as required by the store implementation.
  • Add a new ...NS() function to Store for each function accepting a key string or directory string. This function should have an additional first parameter namespace int which accepts the constants defined above. It applies the map-function to its parameters namespace and key and then calls the approriate store methods according to the mapped namespace and key.

If sane defaults are provided this should not require any change for any existing code outside of libkv.
It should provide allow to support more stores and their features.
Beside support for more namespaces in Consul the mapping function should allow schema changes and migrations from one store to another.

Dominant language
Go
Stars
847
Forks
204
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker/libkv

All issues in docker/libkv

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.