A pluggable backend API that enforces the Event Sourcing Pattern for persisting & broadcasting application state changes

Overview

stategate

A pluggable "Application State Gateway" that enforces the Event Sourcing Pattern for securely persisting & broadcasting application state changes

What is Event Sourcing?

Event sourcing persists the state of a business entity such an Order or a Customer as a sequence of state-changing events. Whenever the state of a business entity changes, a new event is appended to the list of events. Since saving an event is a single operation, it is inherently atomic. The application reconstructs an entity’s current state by replaying the events.

Applications persist events in an event store, which is a database of events. The store has an API for adding and retrieving an entity’s events. The event store also behaves like a message broker. It provides an API that enables services to subscribe to events. When a service saves an event in the event store, it is delivered to all interested subscribers.

Event-Sourcing

GoDoc

Features

  • 6 simple API Methods for interacting with application state:

    • SetObject sets the current state value of an object, adds it to the event log, then broadcast the event to all interested consumers
    • GetObject gets an object's current state values
    • DelObject hard deletes an object & all of it's events
    • SearchObjects queries objects of a specific type
    • StreamEvents creates an event stream/subscription to a given object type until fn returns false OR the context cancels.
    • SearchEvents queries events related to a specific object.
  • Multi-Tenant

  • Capture all changes to an application's state as a sequence of events.

  • Stateless & horizontally scaleable

  • Native gRPC support

  • Embedded REST support / (transcoding)

  • Embedded grpcweb support (transcoding)

  • Metrics Server(prometheus/pprof)

  • Authentication - JWT/OAuth with remote JWKS verification

  • Authorization - Rego based Authorization engine

  • Autogenerated Client gRPC SDK's

  • Structured JSON Logs

  • Sample Kubernetes Manifest

  • Sample Docker Compose

  • Pluggable "Channel" Providers

    • In-Memory(won't scale horizontally)
      • fully-tested
    • Nats
      • fully-tested
    • Nats Streaming(Stan)
    • Redis
      • fully-tested
    • Kafka
    • RabbitMQ
  • Pluggable "Storage" Providers

    • MongoDb
      • fully-tested
    • PostgreSQL
    • MySQL
    • Cassandra

Goals

  • Create a simple API interface for storing state and subscribing to state changes(events) using pluggable channel & storage providers
  • Capture all changes to an application's state as a sequence of events.
  • Safe to swap backend providers without changing client-side code
  • Type-safe client's generated in many languages
  • Safe to expose to the public internet due to fine-grained authentication/authorization model.
  • Different combinations of Channel & Storage Providers are interoperable.
  • Capture a persistant, immutable historical record of all state changes using a pluggable storage provider
  • Store identity(jwt.claims) & timestamp in event logs to capture who is changing what & when
  • Easy deployment model - fully configureable via environmental variables

Concepts

  • Storage Provider: A stategate storage provider is a pluggable, 3rd party database storage service. Storage providers provide persistance for all objects & events and should be scaled independently of stategate instances.

  • Channel Provider: A stategate channel provider is a pluggable, 3rd party message-queue/channel service. Channel providers provide a way for stategate to broadcast events to itself while scaling horizontally. Channel providers should be scaled independently of stategate instances.

Environmental Variables

# port to serve on (optional). defaults to 8080
STATEGATE_PORT=8080
# enable debug logs (optional)
STATEGATE_DEBUG=true
# disable all authentication & authorization(jwks, request policies, response policies) (optional)
STATEGATE_AUTH_DISABLED=false
# tls cert file (optional)
STATEGATE_TLS_CERT_FILE=/tmp/certs/stategate.cert
# tls key file (optional)
STATEGATE_TLS_KEY_FILE=/tmp/certs/stategate.key

# JSON Web Key Set remote URI used for fetching jwt signing keys for verification/validation (optional)
STATEGATE_JWKS_URI=https://www.googleapis.com/oauth2/v3/certs

# base64 encoded OPA rego policy executed on inbound requests from clients (optional)
STATEGATE_REQUEST_POLICY=cGFja2FnZSBzdGF0ZWdhdGUuYXV0aHoKCmRlZmF1bHQgYWxsb3cgPSB0cnVl
# base64 encoded OPA rego policy executed on responses sent to clients (optional)
STATEGATE_RESPONSE_POLICY=cGFja2FnZSBzdGF0ZWdhdGUuYXV0aHoKCmRlZmF1bHQgYWxsb3cgPSB0cnVl
# channel provider configuration(JSON) options: [inmem, redis, nats, stan, kafka] REQUIRED
STATEGATE_CHANNEL_PROVIDER={ "name": "redis", "addr": "localhost:6379" }
# STATEGATE_CHANNEL_PROVIDER={ "name": "nats", "addr": "localhost:4222" }
# STATEGATE_CHANNEL_PROVIDER={ "name": "stan", "addr": "localhost:4222" }
# STATEGATE_CHANNEL_PROVIDER={ "name": "inmem" }

# storage provider configuration(JSON) options: [mongo] REQUIRED
STATEGATE_STORAGE_PROVIDER={ "name": "mongo", "database": "testing", "addr": "mongodb://localhost:27017/testing" }

Notes

Issues
Owner
Coleman Word
Full stack(Go/Typescript) + Devops engineer
Coleman Word
Identify containers at runtime and observe them. No container runtime required. Read only access to the kernel.

Linux Telemetry The Double Slit Experiment Taken from an interesting physics anomaly where the behavior of a physical system mutates simply by being o

Kris Nóva 6 Jul 18, 2021
Perforator is a tool for recording performance metrics over subregions of a program using the Linux "perf" interface.

Perforator Perforator is a tool for recording performance metrics over subregions of a program (e.g., functions) using the Linux "perf" interface.

Zachary Yedidia 18 Jul 14, 2021
Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al.

Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al. This library is external dependency-free. It only depends on the Go standard library.

Sahil Muthoo 1k Jul 13, 2021
Reload Go code in a running process at function/method level granularity

got reload? Function/method-level stateful hot reloading for Go! Status Very much work in progress.

null 32 Jul 14, 2021
A tool to check problems about meta files of Unity

A tool to check problems about meta files of Unity on Git repositories, and also the tool can do limited autofix for meta files of auto-generated files.

DeNA 38 Jul 14, 2021
A full-featured license tool to check and fix license headers and resolve dependencies' licenses.

SkyWalking Eyes A full-featured license tool to check and fix license headers and resolve dependencies' licenses. Usage You can use License-Eye in Git

The Apache Software Foundation 33 Jul 23, 2021
a decision & trigger framework backed by Google's Common Expression Language used in graphikDB

a decision & trigger framework backed by Google's Common Expression Language used in graphikDB

null 56 Feb 23, 2021
A Dero service to sell Eth for Dero

ETH Seller - a Dero Service This is a Dero service for the Stargate R2 testnet, written for the dARCH 2021 Event 0.5 competition

null 3 May 4, 2021
this is an api that execute your deno code and send you the output

this a simple api that execute your deno code and send you the output, has not limit per request example request: in deno: const rawResponse = await f

pai 12 Jul 16, 2021
go-sundheit:A library built to provide support for defining service health for golang services

A library built to provide support for defining service health for golang services. It allows you to register async health checks for your dependencies and the service itself, and provides a health endpoint that exposes their status.

AppsFlyer 419 Jul 23, 2021
Golang bindings for GDAL

Golang bindings for GDAL Goals Godal aims at providing an idiomatic go wrapper around the GDAL library: Function calls return a result and an error.

Airbus DS GEO S.A. 38 Jul 13, 2021
A well tested and comprehensive Golang statistics library package with no dependencies.

Stats - Golang Statistics Package A well tested and comprehensive Golang statistics library / package / module with no dependencies. If you have any s

Montana Flynn 2k Jul 9, 2021
Discover internet-wide misconfigurations while drinking coffee

netz ?? ?? The purpose of this project is to discover an internet-wide misconfiguration of network components like web-servers/databases/cache-service

null 259 Jun 24, 2021
A local snippet manager in Go

Snip A local snippet manager :D Snip provides simple CLI for saving and copying links for emojis, gifs or whatever you want. Requirements Install go i

Felipe Mariotti 4 May 24, 2021