Sunday, July 14, 2019

I saw Kamran Ayub speak on RavenDB at the Twin Cities .NET User Group on Thursday night.

RavenDB, a document database (NoSQL) like MongoDB, is still a thing. It is now on version 4. It is still Ayende's baby. While Mongo just has a CLI (command line interface) for you to use, Raven has a rich studio experience which Kamran Ayub showed off. Raven is written in C#, focused on fast reads, and allows for graph queries which transverse nested gunk. As of version 4, it is now built in .NET Core. cloud.ravendb.net will allow you to create a free account hosted at either AWS (Amazon Web Services) or Azure. X.509 SSL (secure sockets layer) Certificates are used for security. A collection is a way to organize documents. Guids are still the defaults for keys, however, you may now have keys that are plain text names and there are routes, so-to-speak, to these keys, drilling into containers, something like foo/bar/baz/qux for example (wherein qux is the document key, referred to as the "slug" in the path, and foo, bar, and baz the hierarchy of organization called prefixes). Well, honestly, I think the whole route is the key and not just the slug chunk at the end. The collections have indexes as to what they contain in the name of querying against them, however new insertions are not immediately indexed but rather indexed eventually. In this way Raven is BASE instead of ACID. In querying directly against a document key, perhaps with a slug, the result will be ACID. Even if you are just using Guids for the keys and they are auto-generated, you may get a key before you actually commit an in-memory object to the database. CompareExchange in C# allows you to avoid concurrency issues. Kamran was showing this off some in live coding. The Raft algorithm is used with it which I don't pretend to understand. The Wikipedia write up on it suggests there is an elected leader and only one leader at a time. Other actors in the algorithm would be followers. I'm guessing this logic determines who wins in a collision. I saw some B grade martial arts movie on HBO once where the immovable object versus unstoppable force conundrum took shape in a parable in which a rhinoceros charged an elephant. That's concurrency people, and you work out the winner with CompareExchange and Raft. RavenDB's API is built on top of web sockets so you can have what Kamran referred to as Observables! Socket.IO was namedropped as a solution for web sockets in the Node space. SignalR was used in a coding example to update a counter at a web site in real time. The queries look like this:

from Orgs as org
where id() = "orgs/microsoft"

No comments:

Post a Comment