Code Monkey home page Code Monkey logo

microkv's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

microkv's Issues

unused type parameter for `exists`

microkv/src/kv.rs

Lines 307 to 314 in 610cdee

pub fn exists<K>(&self, _key: &str) -> Result<bool> {
let key = String::from(_key);
let data = self.storage.read().map_err(|_| KVError {
error: ErrorType::PoisonError,
msg: None,
})?;
Ok(data.contains_key(&key))
}

Seems that the type parameter K is not actually used in exists. The compiler cannot infer the type for K, so I must add an explicit type annotation in order to call exists.

Proposal: cross-compatible secure enclaves

We should consider phasing out secstr for our own "secured memory" implementation, with full support for other primitives for isolating memory pages to support different OSes:

  • Linux - typical support for mlock and zeroing, but also thinking MFD_SECRET_*, as posed here to further isolate sensitive memory from kernel space and even cache. Have not seen a merge upstream to a new revision yet, but interesting to think about.

  • macOS - mlock again, but also potentially pushing support for Secure Enclave storage, which will requiring signing rather than our current symmetric encryption.

  • Windows - CryptProtectMemory and SecureZeroMemory for explicit zeroing.

Backing to other native "keyring" implementations (Credential Manager, macOS Keychain) are also interesting and provides security and isolation for free(-ish).

Usefulness of locks

Thank you for creating this awesome project. The only issue I have is that the current state of the read and write lock are lacking helper functions to be useful. I see the following main issues:

  1. microkv uses bincode serialization, when only having the IndexMap (e.g., read or write lock) users would have to do the serialization + encryption themselves
  2. making matters worse, external encryption part cannot rely on the stored secret as it is private. So users would need to store it in a second place
  3. formatting the namespace strings is private, so users cannot access them and need to build them in the closure themselves (which is not very nice)

I propose we extend the index map in such a way that we have helper functions (that are also used internally by the namespaces). With them, users can use them inside a lock like this

db.lock_write(|mut kv| {
    kv.kv_put(db, "namespace", "key", 1);
}

I created a PR that serves as a proposal to discuss a a possible direction we could go to solve this problem (#15). If this is the way we want to go, I can extend it to the remaining useful functions and we can merge the PR.

I would love to hear your opinion on this issue.

Proposal: Raft consensus PoC

Demonstrate how we can implement some type of consensus, ideally with Raft with microkv. This should work with the CLI application that is currently being implemented, and should demonstrate how the minimal API can be incorporated well within a distributed systems context.

`put` should take `&V` instead of `V`

pub fn put<V>(&self, _key: &str, _value: V) -> Result<()>

The only use of _value is to pass a reference to bincode::serialize. Thus, _value should be of type &V instead of V. The way it is now: if your caller has only a reference then you force your caller to make an unnecessary clone into _value in order to call put.

Creating/Opening A Database With Path

Right now I'm struggling with opening a database that doesn't end with .kv. I propose to create a new function like

pub fn open_with_path<S: AsRef<str>>(path_to_kv: PathBuf) -> Result<Self>

For example, path to KV can be /home/user/path/dontcare/keyvaluestore.my. This will result in a more generic way of opening the kv store and easier way to pass the path argument from a file selector (for example).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.