uncleDecart / nkv

Share your state between services using persisted key value storage with notification option
1 stars 0 forks source link

Adding functionality to satisfy v0.itworks #5

Closed uncleDecart closed 2 months ago

uncleDecart commented 2 months ago

This commit removes NatsClient and also introduces proper subscribe mechanism, which you can actually use to receive new values.

There's a bunch of things to do till version v0.itworks , we can slowly continue moving with multiple PRs or I'll just create commit for each point in TODO list

TODO:

uncleDecart commented 2 months ago

@deitch PR is ready for review, I'll do rest of todo in separate PR(s)

Edit: I tried to make it easier to review commit-by-commit, i.e. each commit serves one purpose

deitch commented 2 months ago

I put some comments inline. One other important thing that I didn't address is the "keyspace". What is our keyspace? I see a few options:

uncleDecart commented 2 months ago

Regarding "key space" I believe our best option would be to have it implicit like NATS, via separated dot. Because technically it won't change the way we store things and the only thing that would be added is to get all by a regex as a special case, we can then update documentation

deitch commented 2 months ago

Are you sure that implicit doesn't change storage? There can be significant performance differences between get("foo.*") when it's all in a single table and you need to check each key, vs separate tables.

uncleDecart commented 2 months ago

Are you sure that implicit doesn't change storage? There can be significant performance differences between get("foo.*") when it's all in a single table and you need to check each key, vs separate tables.

True, performance will be different, but depends on how many keys will we have? Say we are talking about 20 services which are namespaces of first order, then there are subscriptions/publications of 25 in each which are namespaces of 2nd order and each of them would contain say N values for each Edge App (say 25 as well). So it's ~12500 entries in total. How much it would increase our performance to iterate over 625 entries say instead of 12500 for each request? Well, I need to add benchmarks so that we could see it in microseconds :D

deitch commented 2 months ago

You're thinking eve. I'm thinking, you're building a generic high performance low footprint kv store.

uncleDecart commented 2 months ago

You're thinking eve. I'm thinking, you're building a generic high performance low footprint kv store.

Question is then, how many layers of nested namespaces should we allow in such generic store?

deitch commented 2 months ago

Truth is, it doesn't matter. Define the API day one, you always can optimize the back end later. You just need to think about what the API would constrain later.

uncleDecart commented 2 months ago

Then making it implicit makes sense, we can change implementation later, so client can do wild masks on dot patterns, wdyt?

deitch commented 2 months ago

Sure. Start with that, use regex for linear search. Split it in the future.

uncleDecart commented 2 months ago

Put description in #6 will address it in separate PR, it'll need some love

uncleDecart commented 2 months ago

Actually got too into it so I finished all the todo list, @deitch I see one unresolved discussion about documentation, once it's done I think we're safe to merge this and proceed with other issues