335 Commits (a39d9bf4cfae9ef2f17e1ee55c79f7298799e7de)

Author SHA1 Message Date
Sayan Nandan a39d9bf4cf Implement parser for new protocol 3 years ago
Sayan Nandan 14bfe1fcd1 Add support for parsing arrays and nested arrays 3 years ago
Sayan Nandan 53cad270fc Add parsing for u64 and also check overflows 3 years ago
Sayan Nandan ad0fbffe32 Add data types and add parsing for strings 3 years ago
Sayan Nandan 60d7a1c173 Optimize will_cursor_give_char check 3 years ago
Sayan Nandan 3a1abda2cb Return NotEnough if nothing at current cursor
If Parser::will_cursor_give_char is set to not error if a char matches
or the next line is empty, return Ok(bool). If this_if_nothing_ahead is
set to false, then return a NotEnough error if no more chars are
available.

The newly added test explains why
3 years ago
Sayan Nandan 6d29e519c9 Fix read_sizeline returning wrong error
Also added more tests
3 years ago
Sayan Nandan daaf6968ba Verify if byte is LF before moving cursor 3 years ago
Sayan Nandan d91e696e24 Add more tests 3 years ago
Sayan Nandan 0bdbd81f92 Add a header magic
We add a header magic '0x0D' or the CR byte. This acts as a boundary
between multiple queries on the same connection
3 years ago
Sayan Nandan 88b4eb88a1 Make some idents public 3 years ago
Sayan Nandan 6dbe0fcfaa Add parsing for complete query 3 years ago
Sayan Nandan e07614d857 Rename function to reflect names in rest of mod 3 years ago
Sayan Nandan d22fec8036 Implement complete actiongroup parsing 3 years ago
Sayan Nandan 65f0e445a4 Pre-allocate capacity for the element 3 years ago
Sayan Nandan 2efe2ab213 Implement parsing of datagroup elements 3 years ago
Sayan Nandan 14e0ab2462 Rename functions appropriately 3 years ago
Sayan Nandan 773c82ac83 Add actiongroup size parsing 3 years ago
Sayan Nandan 2fed0e876b Implement metaframe parsing 3 years ago
Sayan Nandan 559af81ee9 Start impl of new parser and add sizeline parsing 3 years ago
Sayan Nandan 4265820fbd Don't raise error if there is more data 3 years ago
Sayan Nandan c9b2abfc96 Fix test 3 years ago
Sayan Nandan abb1b9bf33 Only discard part of buffer that was parsed 3 years ago
Sayan Nandan 74893c275e
Abstract HashMap into HTable (#146)
It is likely that we'll change the HashMap implementation in the future,
hence its best to hide away the HashMap to make sure we can easily
replace it.
3 years ago
Sayan Nandan d18631680c Bump up version and add changelog entry 3 years ago
Sayan Nandan 50273f324a Upgrade dependencies 3 years ago
Sayan Nandan f3e7a73b00 Fix trying to read dir instead of snapshot file
Also, migration support for the old snapshot directory was added
3 years ago
Sayan Nandan 90ee7baa8a Fix snapshot directory parsing logic
The previous logic was heavily flawed; it only had to check if the path
was a dir and isn't the remote snapshot directory.

Similarly, the file name parsing should only kick in if the item is a
file
3 years ago
Sayan Nandan 772e7b0b27 Fix restoring from snapshot and data file 3 years ago
Sayan Nandan 0b3dd9c129 Add backwards compat for old snapshot dirs 3 years ago
Sayan Nandan f013a90179 Change snapshot directory to data/snapshots 3 years ago
Sayan Nandan f60b3098da Change the data file path to data/data.bin
As a consequence, other methods were also upgraded
3 years ago
Sayan Nandan 3851f6d9ce
Remove redundant functions from mod `config` (#143) 3 years ago
Sayan Nandan ce466ebc22 Reacquire lock when runtime exits
This commit adds changes so that the main process almost immediately
acquires a lock on the data file when runtime is dropped. This is just
an added precaution to try and ensure that no other process does
something silly with the data file.

The descriptor is cloned for this using `FileLock::try_clone`
3 years ago
Sayan Nandan 74ce75d919 There is no need for block_on_process_exit
8e46e62 added a block_on_process_exit function that kept on sending
`notify_one()`s in a loop until the services terminated. This was
pointless as the `Drop` impl would do it for us anyways.
(What was I thinking?)

So, in main(), we're spawning an async task that lets the DB run as long
as we don't pass a ctrl_c (or some bad panic occurs). Once the ctrl_c
is received, we start terminating all workers. `block_on` returns DB
which should be the only one holding an atomic reference to the shared
field. We assert this right after dropping `runtime`.

Finally, the ECONNRESET suppression match was fixed to remove an
unreachable branch by adding conditional compilation
3 years ago
Sayan Nandan 8e46e62d3f Wait for all workers to drop and release flock(s)
This commit ensures that the workers exit before attempting a flush_db
operation. Only after block_on_process_exit finishes we return `db`.
Now we run a simple flush_db operation knowing that the lock has been
released.
To block on process termination, we introduce a new function
block_on_process_exit that does the same thing as CoreDB's Drop
implementation.
3 years ago
Sayan Nandan 7349f5261d Manually build rt and then block on dbnet::run 3 years ago
Sayan Nandan d9af302417 Don't use additional scope 3 years ago
Sayan Nandan fb503e2981 Fix trying to unlock `file` instead of `file2`
Silly me, `file` has already been unlocked
3 years ago
Sayan Nandan 1180de3b71 Ret FileLock from BGSave to unlock before flush_db 3 years ago
Sayan Nandan 5df31287da Use dedicated blocking osthread for unlocking file
This commit ensures that the file unlock operation is completed as soon
as bgsave returns and not in the future
3 years ago
Sayan Nandan 39ab1e7683 Log error that causes `flush_db` to fail 3 years ago
Sayan Nandan 07dd884f3c Upgrade deps and remove unused regex in cli
Closes #128, closes #129 and closes #132
3 years ago
Sayan Nandan 4354bfc0f9 Fix ECONNRESET errors on Windows
As discussed in #110, this commit suppresses ECONNRESET on Windows.
3 years ago
Sayan Nandan ea1381269b Don't use filename `con`
Windows is the most ingenious OS in the world where filenames can
conflict with shell commands. That's right, con is an I/O device on
Windows and cannot be used for a filename! This is why we were having
checkout errors on Windows!

Vive la POSIX!
3 years ago
Sayan Nandan e918dabf26 Use generic Connection replacing SSL/TCP variants
We have introduced a trait `BufferedSocketStream` that is a 'dummy'
trait and is implemented for both `SslStream<TcpStream>` and
`TcpStream`. So, the generic `Connection` object accepts any type that
implements the `BufferedSocketStream` trait (and hence should also
implement `AsyncWrite`)
3 years ago
Sayan Nandan 4ba5418120 Document `dbnet::con` 3 years ago
Sayan Nandan ef36351428 Refactor dbnet and protocol into logical modules 3 years ago
Sayan Nandan eb71335a62 Upgrade all functions to use generic connections
This commit does a LOT! It migrates the `queryengine::execute_simple`,
`CoreDB::execute_query` and the kvengine functions to use generic
connections.

The object dbnet::Con was removed because it isn't needed anymore.
The listeners were also upgraded to use the generic connection handler
3 years ago
Sayan Nandan c399ae1f1c Implement a generic con handler and rename traits
The trait `Con` and `ConOps` were renamed to `ProtocolConnectionExt`
and `ProtocolConnection`.

This naming scheme clearly explains that the Ext version 'augments' the
non-Ext impl. This is the very case here: ProtocolConnection provides
the basic funtions needed for interfacing with net I/O while the Ext
trait enables high-level interaction with the protocol and ultimately
queries.

A generic `ConnectionHandler` object was added that will replace the
SSL and non-SSL handler objects, again reducing redundancy.

Dummy execute functions were added to CoreDB and queryengine.
3 years ago