A backend server and client for Norg related applications.

Overview

Norgopolis

Norgopolis is a lightweight communication, launcher and utility services client for the Neorg rust-native modules ecosystem on Desktop. It is designed to connect, launch and manage instances of modules such as the Norgberg database system which should only exist once per desktop, but provide services to n frontends such as multiple neovim processes, without the need for intermediate process ownership changes or process re-launches.

Norgopolis also provides for the ability to download and connect different services together without the need for recompilation or complete re-launch, making for easy modifying and extension by the common user.

Why?

There are four problems that Norgopolis solves:

  • how do we provide singleton services like a database-over-the-notes-on-file while having more than one frontend at the same time?

  • How do we ensure that the exit of the first-launching frontend (which must initiate all the background services) does not cause loss of service, interruption of service, failure to handover to another thread, or similar issues?

    • how do we ensure that the processes exit when the last frontend has indeed also exited?
  • How do we allow people to extend their installation with new native modules without the need for recompilation or volatile shared object dynamic loading?

  • How do we get these modules to talk with each other and any frontend callees in a lightweight, performant manner?

Norgopolis addresses these.

How it works

Norgopolis comes on two parts, the client and the server backend. They communicate with each other using gRPC.

When a client is launched, it tries to find an existing server instant via gRPC. If it does not find an existing instance, it will initiate a server boot as an independent process. If it finds an existing server, it will connect to that server and log on as a client session.

The Norgopolis server reference-counts registered clients. If clients die or time out with no communication for a certain duration, they are removed from the reference count. If the reference count hits zero, Norgopolis will gracefully exit itself and all its child processes.

The core of Norgopolis is a communications router between the frontend gRPC connection(s) and the set of currently loaded modules. "Modules" are executable binaries that conform to the Neorg native module standard, providing a configurations TOML and a stdin/stdout-based RPC communications interface. Modules provide services to their callers. Norgberg is an example of such a module, providing database services.

Related to the router is Norgopolis' loader capability. Norgopolis routes calls using a module name specified in the RPC protocol buffer data. If no such module is currently registered on the router, Norgopolis will attempt to locate the binary in a modules directory and spawn a child thread with that binary in it. This allows for inherent lazy loading, "self-loading" and adding-modules-underway. Modules may declare transient module dependencies in their configurations TOML, in which case the Norgobolis loader will verify availability and fail the load if dependencies are not availiable. Likewise, inabililty to locate an executable binary will fail gracefully.

Modules only have to be compiled binaries or otherwise executable programs. They run as independent child threads of Norgopolis. Note: that means of Norgopolis exists, so will these child threads. This is by design and should be bypassed sparingly. Norgopolis will broadcast shutdown RPC messages when it exits.

This also describes the utilities Norgopolis offers: they are related to loading, managing and shutting down modules.

Client interface

The client exposes Rust functions and an FFI interface aimed at Lua, and comes both as a separate crate and as part of the combined crate. This is used to bridge method calls over into gRPC and execute the stateful startup-registration logic for the server, as well as unpack and deliver method invocation return values.

Server interface

The server talks with any clients or other external callers which are not modules it maintains over gRPC, using the Norgopolis protobuffer spec. Note, this does mean you can try to call the server (if it is online) and through it any modules you may want, from any other application with the correct protocol buffer and mpack specification, such as web applet plugins or one-off scripts.

Modules talk to the server and through it with callers and other modules using stdin/stdout-piped protobuffers that follow the same specification. The server provides the asynchronous routing.

Neat hacks and implications

Since Norgopolis launches executable files as child threads and communicates using protocol buffers over stdin/stdout, any executable that can talk according to our spec can be loaded as a module. This not only inoculates against Rust ABI changes between versions, but also allows modules compiled in other languages (or interpreted on the spot) to be loaded up into your system. Be however aware of the performance implications (modules run as separate threads, so slow programs will begin clogging your CPU), and modules are generally understood to be persistent, not transient, until unloaded with a command to the server or the server exits, and thus also all module threads. (That said, you can exit as a module yourself. Again, just beware of the implications.)

Self-loading

Since Norgopolis will attempt to locate and launch modules for which it has received a method call but does not have an active instance to route to, you can use this to inject an executable into the modules group from external gRPC calls, by having an executable containing Neorg module logic first call the server, provide its loading spec, exist its initial thread and then launch as a module thread under the server. This can be a very neat method to run modules one-off as part of a script ecosystem, or for cases such as testing.

Default lazy loading

Norgopolis default is to only try and load a module if a call is received and it does not have an active thread of that module name to route to. This implicit lazy loading can be used to reduce startup times. Norgopolis has a loading capability to automate the startup of certain services in part due to its transient dependency checking, but this builds on the lazy loading behavior.

You might also like...
TinyTodo is a Cedar Agent example, with a server in Rust and client in python
TinyTodo is a Cedar Agent example, with a server in Rust and client in python

TinyTodo - OPAL and Cedar Agent Demo TinyTodo is a simple application for managing task lists. It uses OPAL and Cedar Agent to control who has access

Sets of libraries and tools to write applications and libraries mixing OCaml and Rust

Sets of libraries and tools to write applications and libraries mixing OCaml and Rust. These libraries will help keeping your types and data structures synchronized, and enable seamless exchange between OCaml and Rust

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

Official repository for v3's backend

RoChat This repository holds the official source code for RoChat's new backend. Previously, the old backend was written in PHP. The newer one, coming

Backend service to build customer facing dashboards 10x faster. Written in Rust.
Backend service to build customer facing dashboards 10x faster. Written in Rust.

Frolic is an open source backend service (written in Rust) to build customer facing dashboards 10x faster. You can directly connect your database to t

This rust compiler backend emmits valid CLR IR, enambling you to use Rust in .NET projects

What is rustc_codegen_clr? NOTE: this project is a very early proof-of-concept This is a compiler backend for rustc which targets the .NET platform an

An mdBook backend to output Typst markup, pdf, png, or svg

mdbook-typst mdbook-typst is a backend for mdBook. The backend converts the book to Typst markup and can output any format Typst can (currently pdf, p

💸 An open-source wasteof.money frontend/backend implementation

wasteof.time An open-source wasteof.money frontend/backend implementation Running Backend cargo run -q -p backend Frontend To run the frontend, you ne

Bruteforce connecting to a specific Sea of Thieves server. Useful if you want to be in the same server as your friends.

SoT Server Finder Find which Sea of Thieves server you're connected to. Useful if you want to be in the same server as your friends. Setup Download so

Owner
Neorg
Neorg
Curated list of awesome projects and resources related to Rust and computer security

Awesome Rust Security Curated list of awesome projects and resources related to Rust and computer security Table of Contents Tools Web and Cloud Secur

Alan 131 Jan 1, 2023
Calculation of Wigner symbols and related constants

Calculation of Wigner symbols and related constants This crate computes Wigner 3j coefficients and Clebsch-Gordan coefficients in pure Rust. The calcu

Guillaume Fraux 3 Jan 19, 2022
A library providing helpers for various StarkNet fees related tasks.

?? How Much ? ?? Table of Contents About Getting Started Prerequisites Installation Usage Estimate fees on network Authors & contributors Security Lic

Abdel @ StarkWare 4 Dec 15, 2022
Low overhead Rust implementation of time-related concepts

It's Rust time! Low overhead implementation of time-related concepts. Who is time for? For applications where simplicity and low-overhead are more imp

MOIA GmbH - Open Source 10 Feb 20, 2023
REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀

Information: REC2 is an old personal project (early 2023) that I didn't continue development on. It's part of a list of projects that helped me to lea

Quentin Texier (g0h4n) 104 Oct 7, 2023
This is the data collector that gets your system's state and sends it to the backend

⚡ Installation Linux curl -s https://raw.githubusercontent.com/xornet-cloud/Reporter/main/scripts/install.sh | sudo bash Windows Invoke-Command -Scrip

Xornet 18 Sep 3, 2022
a (soon to be) calculator frontend and a (soon to be optimizing) toy IR backend

Zach-Calc Zach-Calc is a pet project for me to try and better understand pattern matching, optimization, IRs, and the likes. ./libs/* contains librari

Zachary Petti 0 Jan 6, 2022
🛠️ An experimental functional systems programming language, written in Rust and powered by LLVM as a backend.

An experimental functional systems programming language, written in Rust, and powered by LLVM as a backend. ?? Goal: The intent is to create a program

codex 3 Nov 15, 2023
A Rust CLI tool that helps you enforce Git policies through Git hooks both server and client side

GitPolicyEnforcer This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies. It currently supports

Vagelis Prokopiou 4 Aug 14, 2022
Russh - Async (tokio) SSH2 client and server rimplementation

Russh Async (tokio) SSH2 client and server rimplementation. This is a fork of Thrussh by Pierre-Étienne Meunier which adds: More safety guarantees AES

Warptech Industries 113 Dec 28, 2022