Skip to content

An XTDB v2 playground containing the 'Sakila' (MySQL) film rental sample dataset

License

Notifications You must be signed in to change notification settings

xtdb/sakila-playground

Repository files navigation

XTDB Sakila Playground

XTDB playground for the Sakila sample dataset.

Getting started

  • To start a REPL, run clj -M:xtdb:nrepl, and then connect to it from your editor of choice.

  • Evaluating xtdb.demo.db will start and seed an XTDB node, which will be available at (:xt-node xtdb.demo.db/xt-node)`

  • Query away to your heart’s content!

For more information, see the main XTDB docs.

Tests

There are some simple tests:

clojure -M:test -m kaocha.runner test

Web serving

Run make to download dependencies. With a Clojure REPL started, evaluate user.clj to start the HTTP server on port 3010.

Open a web browser at http://localhost:3010/

A Ring handler is provided. Incoming requests are handled by locating the resource corresponding with the URI of the request. By default, resource location is provided by a locator in xtdb.demo.web.locator that searches for resources in Clojure namespaces. A key Clojure namespace is xtdb.demo.resources which has metadata indicating the web context of the resources contained with the namespace.

Most web frameworks route web requests to a single 1-arity function, taking the request data and returning the response. This scheme originates from the early web’s Common Gateway Interface (CGI) mechansim to 'escape' out of the normal serving of static files. However, this scheme deviates from the object-oriented nature of the early web, where resources were defined more closely as objects with state responding to methods. Therefore, Clojure records are used to reflect the fact that web resources are a set of method functions, closed over some state (the resource’s current state and configuration) These Clojure records satisfy a Clojure protocol defined in xtdb.demo.web.protocols/UniformInterface. This protocol represents REST’s Uniform Interface, including the various methods that a resource may support.

The benefits of a more accurate and faithful model of the web means that it is easier to implement HTTP as described in its specifications. For instance, by modelling which methods are allowed on a given resource, a user-agent can introspect these methods at run-time (inspecting the Allow header returned from an OPTIONS request). A user-agent might make use of this metadata, for example, to show/hide parts of its UI accordingly.

About

An XTDB v2 playground containing the 'Sakila' (MySQL) film rental sample dataset

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published