Event-sourcing Schema Definition Language

Overview

ESDL

Event-sourcing Schema Definition Language


Schema definition language for defining aggregates, commands, events & custom types.

Heavily inspired by GraphQL syntax, you can describe aggregates which can be used for codegen in different languages.

Code generation

ESDL schemas can be used for code generation.

The Rust crate currently supports code generation for:

Additional languages may be added in the future. Contributions are welcome!

Example

aggregate BankAccount {
  open_account(initial_balance: Float) -> OpenedAccount
  deposit_funds(amount: Float) -> ReceivedFunds
  withdraw_funds(amount: Float) -> SentFunds
  send_funds(amount: Float, user: User) -> (SentFunds? | ReceivedFunds?)
}

event OpenedAccount {
  initial_balance: Float
}

event SentFunds {
  amount: Float
  user: User?
}

event ReceivedFunds {
  amount: Float
  user: User?
}

type User {
  id: String
  name: String?
}

Scalar Types

Scalar Rust Type TypeScript Type
String String string
Int i64 number
Float f64 number
Bool bool boolean
Timestamp DateTime<FixedOffset> Date

Optional & Required

Types can be marked as optional by adding the ? suffix.

Type Syntax Example
Required T String
Optional T? String?

Repeating Types

Types can be repeated by wrapping them in [].

Type Syntax Example
Single T String
Array [T] [String]

Remember, we can mark types as optional, even in arrays.

Type Syntax Example
Optional Array [T?]? [String?]?
Required Array [T?] [String?]
Required Array Items [T]? [String]?
Required Array Items [T] [String]

Integrates with Thalo to generate Rust code.

You might also like...
An Interpreter for Brainfuck programming language implemented in the Rust programming language with zero dependencies.

Brainfuck Hello, Visitor! Hey there, welcome to my project showcase website! It's great to have you here. I hope you're ready to check out some awesom

Nexa programming language. A language for game developers by a game developer
Nexa programming language. A language for game developers by a game developer

NexaLang Nexa programming language. A language for game developers by a game developer. Features High-Level: Nexa is an easy high level language Two M

A Text User Interface library for the Rust programming language
A Text User Interface library for the Rust programming language

Cursive Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but other backends are available. It allows you to build

Voila is a domain-specific language launched through CLI tool for operating with files and directories in massive amounts in a fast & reliable way.

Voila is a domain-specific language designed for doing complex operations to folders & files. It is based on a CLI tool, although you can write your V

Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.
Standard Graphics is a command-line tool for printing 2D graphics from any language to any screen.

2D graphics in any programming language with just print statements!

Text-based to-do management CLI & language server
Text-based to-do management CLI & language server

☑️ Todome (日本語版はこちら) Todome is a notation developed for making and editing to-do lists. It is inspired by Todo.txt, and in fact some of the todome not

An elegant language for script-kiddies and terminal squatters.

Tonic An elegant language for script-kiddies and terminal squatters. About I started Tonic to complete the Advent of Code 2021. My eventual goal is to

A diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to retain every change.

Docchi is a diff-based data management language to implement unlimited undo, auto-save for games, and cloud-apps which needs to save very often. User'

Rust-language assets for Zcash

Zcash Rust crates This repository contains a (work-in-progress) set of Rust crates for working with Zcash. Security Warnings These libraries are curre

Comments
  • Implement Serialize, Deserialize on

    Implement Serialize, Deserialize on "type" structs generated from ESDL files

    Currently referencing ESDL "types" from ESDL "events" will lead to a build error as the underlying "types" do not implement Serialize/Deserialize and will break the trait derivation for the "event" in question. Example ESDL from my test app lincluded:

    aggregate Order {
        order_placed(order_type: String!, line_items: [LineItem!]!, address: Address): OrderPlaced!
        order_status_changed(id: String!, order_status: String!): OrderStatusChanged!
    }
    
    event OrderPlaced {
        id: String!
        line_items: [LineItem!]!
        order_type: String!
        order_status: String!
        address: Address
    }
    
    event OrderStatusChanged {
        id: String!
        order_status: String!
    }
    
    type LineItem {
        item_id: String!
        quantity: Int!
        notes: String
    }
    
    type Address {
        address_1: String!
        address_2: String
        city: String!
        state: String!
        zip: String!
    }
    

    In this scenario the compiler will puke on the following:

         pub address: std::option::Option<Address>,
         |     ^^^ the trait `Deserialize<'_>` is not implemented for `Address`
         pub line_items: std::vec::Vec<LineItem>,
         |     ^^^ the trait `Deserialize<'_>` is not implemented for `LineItem`
         pub address: std::option::Option<Address>,
         |     ^^^ the trait `Serialize` is not implemented for `Address`
         pub line_items: std::vec::Vec<LineItem>,
         |     ^^^ the trait `Serialize` is not implemented for `LineItem`
         
    
    opened by Shearerbeard 2
  • feat!: use `->` separator for return type

    feat!: use `->` separator for return type

    Use -> separator instead of : for return types.

    From:

    open_account(initial_balance: Float!): OpenedAccount!
    

    To:

    open_account(initial_balance: Float!) -> OpenedAccount!
    
    opened by tqwewe 0
  • TypeScript codegen

    TypeScript codegen

    Adds support for TypeScript code generation.

    The project structure is also cleaned up.

    Code generation are available under feature flags:

    • codegen-rust
    • codegen-typescript
    opened by tqwewe 0
  • [Rust Codegen] Allow to use primitive types as custom types ?

    [Rust Codegen] Allow to use primitive types as custom types ?

    Hello, thanks for the thalo initiative, really good project!

    Currently the language is strongly opinionated, as a Int is a i64 however we are missing other types such as i16, i32, u16, u32, u64 (for timestamp)

    I would like to have the ability to explicit a type from Rust in a ESDL file. As there are multiple languages involved, it would be probably easier to cheat a bit and explicit the primitive types as custom types.

    Do you have any idea about this ?

    opened by Mcfloy 3
Owner
null
A toy event store and event messaging system.

RDeeBee Follow this blog series for more details on this project. This system is inspired by Martin Kleppman's arguments that Event Sourcing system an

null 4 Nov 6, 2022
Interface definition generator and standard for Move packages.

Move IDL Interface definition generator and standard for Move packages. Documentation is currently extremely sparse but will be improved in the near f

The Moving Company 10 Aug 25, 2022
Serde definition of Cargo.toml structure

Deserialize Cargo.toml This is a definition of fields in Cargo.toml files for serde. It allows reading of Cargo.toml data, and serializing it using TO

null 11 Dec 20, 2023
Turbine is a toy CLI app for converting Rails schema declarations into equivalent type declarations in other languages.

Turbine Turbine is a toy CLI app for converting Rails schema declarations into equivalent type declarations in other languages. It’s described as a to

Justin 2 Jan 21, 2022
Traverse DMMF of Prisma schema, in your terminal

Let's DMMF Traverse DMMF of Prisma schema, in your terminal. Powered by jless. Installation brew tap yujong-lee/tap brew install letsdmmf Usage # lets

Jayden 6 Dec 9, 2022
This crate provides a set of functions to generate SQL statements for various PostgreSQL schema objects

This crate provides a set of functions to generate SQL statements for various PostgreSQL schema objects, such as tables, views, materialized views, functions, triggers, and indexes. The generated SQL statements can be useful for schema introspection, documentation, or migration purposes.

Tyr Chen 11 Apr 4, 2023
An event replay tool for the Trento storage backend.

photofinish - a little, handy tool to replay events This tiny CLI tool aims to fulfill the need to replay some events and get fixtures. Photofinish re

null 5 Nov 10, 2022
Open-source Rust framework for building event-driven live-trading & backtesting systems

Barter Barter is an open-source Rust framework for building event-driven live-trading & backtesting systems. Algorithmic trade with the peace of mind

Barter 157 Feb 18, 2023
An implementation of a Windows Event Collector server running on GNU/Linux.

OpenWEC OpenWEC is a free and open source (GPLv3) implementation of a Windows Event Collector server running on GNU/Linux and written in Rust. OpenWEC

CEA IT Security 15 Jun 15, 2023
The Amp programming language: a language designed for building high performance systems.

A language designed for building high performance systems. Platform Support x86_64-pc-windows ✅ x86_64-unknown-linux ⚠️ untested x86_64-unknown-darwin

The Amp Programming Language 5 Mar 17, 2023