Giter Site home page Giter Site logo

mjepronk / apie Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 67 KB

Apie: a simple event sourcing and content addressable storage API (Warp and CGI)

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.37% Haskell 95.28% Nix 3.70% Shell 0.65%
event-sourcing content-addressable-storage cgi haskell

apie's Introduction

Apie

NOTE: This project is not for general consumption yet.

This program provides a very minimal backend API for an event sourcing system.

The main features are:

  • an append-only event stream that can be used to record all data mutations
  • content-based storage (for binary data)
  • authenticate users using HTTP basic authentication

Event stream

The event stream is an append-only log of all changes made to structured data of your application. The client can use this event stream to create a projection on the structured data, basically the state of your application data at a given moment.

The advantages of storing your application data as an event stream are:

  • view all changes to the application data (for auditing, rollback of incorrect changes, "time travel" debugging, ...)
  • synchronize distributed data (support offline applications, ...)

CGI

The backend can be compiled to a statically compiled Linux binary that should run as a CGI program on most hosting providers (on Linux). This requires the Nix package manager to be installed (in order to build a binary that uses musl instead of glibc).

Please make sure that the webserver passes the Authorization header (HTTP_AUTHORIZATION environment variable) to the CGI script. For Apache you can use the provided cgi-bin/.htaccess.

Webserver

The backend can also run standalone using the Warp HTTP server. Please note however that it's not an efficient implementation: we use file locks as primitives for synchronization.

The plan is to create an efficient multi-threading server backend using STM.

Examples

Event Store

curl -X PUT -H "Content-Type: application/json" --data @event.json http://localhost:8000/events

curl http://localhost:8000/events

curl http://localhost:8000/events?from=0d0ef6946e84a7bb64c600709c05edda81d2ebec8b85ced529ae56a9de5eb9cb

curl http://localhost:8000/events?to=0d0ef6946e84a7bb64c600709c05edda81d2ebec8b85ced529ae56a9de5eb9cb

curl http://localhost:8000/events/0d0ef6946e84a7bb64c600709c05edda81d2ebec8b85ced529ae56a9de5eb9cb

Content Store

curl -X PUT -H "Content-Type: application/pdf" -T ~/Documents/test.pdf http://localhost:8000/storage/

curl -X GET http://localhost:8000/storage/0d0ef6946e84a7bb64c600709c05edda81d2ebec8b85ced529ae56a9de5eb9cb --output test.pdf

curl -X DELETE http://localhost:8000/storage/0d0ef6946e84a7bb64c600709c05edda81d2ebec8b85ced529ae56a9de5eb9cb

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.