Giter VIP home page Giter VIP logo

luadb's People

Contributors

chrisrink10 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

luadb's Issues

Improve state performance and usability

LuaDB is currently just loading every library into the global namespace when it spawns a new Lua state. This would be very performance intensive for implementations which involve a large number of incoming HTTP requests since it's likely each request would need it's own new state. Consider instead just pushing a single import function into the global namespace that application scripts can use to load the statically linked C libraries on-demand.

Consider other areas for potential configuration

Several of the following items may make sense to be added to config.lua in case they change across web servers or operating systems:

  • FastCGI environment prefix (default: "HTTP_")
  • Expected number of FastCGI headers and variables
  • Default FastCGI backlog
  • Default device for FastCGI
  • Log prefix (default: "luadb")
  • Log location (default: "/var/log/luadb.log")
  • etc.

Move to a global MDB_env object to avoid locking/multithreading issues

Per the caveats listed on the main page of the LMDB docs:

Do not have open an LMDB database twice in the same process at the same time. 
Not even from a plain open() call - close()ing it breaks flock() advisory locking.

Right now, LuaDB runs everything in the main thread. When multithreading support is added, there is a high likelihood that two Lua scripts could be running with separate references to the same MDB_env which could cause locking issues as noted above.

We should create a global MDB_env object that is shared between Lua instances.

Improve robustness of query string parser

Certain types of query string characters might cause issues with the current parser. The RFC that defines query strings technically permits a ; delimiter in addition to &, but the parser does not account for that.

libuuid is using OS X / Darwin specific types

LuaDB's uuid.c is referencing uuid_string_t, which is only included in the Apple/Darwin headers for uuid/uuid.h. Consequently, the compiler on Linux throws errors when it encounters this absurd type.

Fortunately, it looks like uuid_string_t is just a typedef for char[37], and the standard libuuid uses a 'uuid_unparse(uuid_t, char *)' function prototype anyway, so we can just fix this by using a char *.

Improve line editing on Windows

For systems which provide readline, LuaDB will compile with support for that library. However, since LuaDB does not provide it as a native dependency, Windows has no line editing support.

lmdb.Transaction:order() does not skip duplicate nodes

The MUMPS $ORDER function which is emulated by the lmdb.Transaction:order function does not return duplicated key nodes, rather it always returns the next unique key node in ordered iteration over the database.

This should be fixed.

JSON arrays are not properly tagged with metafield

The LuaDB json library's decode function is supposed to mark Lua tables with the metatable field _json_array on decode, but for some reason this fails. This means that JSON arrays are not properly re-encoded as arrays (i.e. the identity function of json.encode(json.decode(t)) == t for some table t does not hold).

Improve logging from LuaDB/FastCGI

Right now it's pretty painful to figure out what brought down the LuaDB FastCGI process. Some things are pushed into the web-server error log from stderr, but it would be better if LuaDB had it's own logs.

The `json` module fails to encode tables

When encoding a Lua table to JSON, the json library module throws a Lua error and never completes. It appears that it pushes an extra string onto the stack at json.c:139 in the function lua_value_to_json and it never calls lua_pop to pop the extra value off the stack. This throws off lua_next and the table iteration fails.

Standardize LuaDB code style

There are a few places where we use bool rather than int. API names are inconsistent. A style guide should be created and followed.

Function `luadb_strndup` doesn't handle non-null terminated inputs

Because luadb_strndup uses strncpy rather than memcpy, it will fail to NUL terminate strings that are taken from larger character buffers (as is being done in query string parsing). Consequently, attempting to JSON encode the data generates UTF-8 errors (if it does not SEGFAULT) since string will almost certainly run into some crazy bytes.

Fix by swapping to use memcpy and manually NUL terminate.

Check for error conditions when loading environment config

Right now, when the environment configuration values are loaded from config.lua, the code merely assumes that the value is going to exist. Instead, we should provide sensible defaults and defer to the Lua values if they are provided.

Likewise, proper error handling should be imposed so if the values in the Lua code are invalid for some reason, we won't use them (and won't crash :) ).

LuaDB does not always load integral values back from LMDB as integers

Integers are often reloaded as double/float values which are correctly integral (e.g. 1 is loaded as 1.0). This is annoying and counterintuitive. LuaDB already has a function in the json library which verifies if a number is integral in C, so we should generalize this and use it for similar purposes to verify that integers are correctly serialized and deserialized as such.

Add support for LuaFileSystem

The only support for filesystem manipulation from LuaDB is from whatever rudimentary pieces Lua provides out of the box. We should implement LFS.

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.