Fearless asynchronous Plumber.

Related tags

Cryptography Faucet
Overview

Faucet

Faucet is an asynchronous runtime for running Plumber APIs. Faucet enables guaranteed concurrency and parallelism for Plumber APIs without the need for a promise based API. Faucet can run either locally or in a Kubernetes cluster.

Note: Faucet is currently in early development and is not ready for production use.

Why Faucet?

When building an API with Plumber a common pattern is to use promises, however in many cases promises cause significant overhead by creating new R processes on every request; promises also do not support database connections.

In local mode, Faucet uses a lock system (similar to how relational databases handle concurrency) to distribute HTTP requests across multiple Plumber workers guaranteeing that a single process only handles one request at a time.

In K8s mode, Faucet uses the same lock system to distribute load across a Kubernetes service.

What makes it different from other async runtimes?

Faucet is similar to other load balancers like Valve when working on local mode. However, Faucet is designed to be a versatile runtime that can run either in a normal Linux VM or in a Kubernetes cluster. Faucet is able to use it's worker lock on replicas inside a Kubernetes service, avoiding unwanted request collisions.

Installation

To install Faucet, you first need to install The Rust Programming Language on your system. In the future, platform specific binaries will be distributed.

Clone the repository and run cargo install --path . to install the faucet binary.

Usage in local mode

To use Faucet, you will need to have a Plumber API with an entrypoint file named entrypoint.R that contains code like the following:

library(plumber)
# 'plumber.R' is the location of the file shown above
pr("plumber.R") %>%
  pr_run(port = as.integer(Sys.getenv("FAUCET_PORT")))

The environment variable FAUCET_PORT is used to specify the port that the specific Plumber worker should listen on. Faucet will automatically set this environment variable for each worker.

To run the API, run the following command while in the same directory as the entrypoint.R file:

faucet

If you want to run an API on a different directory, you can use the --dir flag:

faucet local --dir /path/to/api

For more information on the available flags, run faucet local --help.

Usage in Kubernetes mode

TODO: Improve documentation

This is a work in progress. Please check back later.

For now you can try a little experiment to understand the basic idea:

  1. Run a plumber API locally on port 8000
  2. Run faucet k8s --service-url http://localhost:8000 to start a faucet server
  3. Request any resource to the faucet server and see that it is proxied to the plumber API.

What the faucet server will do is resolve the hostname of the --service-url flag and acquire a lock on the specific pod hosting the application. In a Kubernetes environment this hostname would dynamically resolve to different IP addresses according to the number of replicas.

You might also like...
Simple interoperability between C++ coroutines and asynchronous Rust

cxx-async Overview cxx-async is a Rust crate that extends the cxx library to provide seamless interoperability between asynchronous Rust code using as

An asynchronous Rust client library for the Hashicorp Vault API

vaultrs An asynchronous Rust client library for the Hashicorp Vault API The following features are currently supported: Auth AppRole JWT/OIDC Token Us

asynchronous and synchronous interfaces and persistence implementations for your OOD architecture

OOD Persistence Asynchronous and synchronous interfaces and persistence implementations for your OOD architecture Installation Add ood_persistence = {

An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous and blocking clients respectively.

eithers_rust An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous a

General-purpose asynchronous socket stream.

async-socket This crate implements a general-purpose asynchronous socket. The Socket implements AsyncRead, AsyncWrite, Stream and Clone traits and thu

Ratchet is a fast, robust, lightweight and fully asynchronous implementation of RFC6455 (The WebSocket protocol).

Ratchet 🚧 Ratchet is a fast, robust, lightweight and fully asynchronous implementation of RFC6455 (The WebSocket protocol). Complete with an optional

An asynchronous Hardware Abstraction Layer (HAL) for embedded systems

embedded-hal-async An asynchronous Hardware Abstraction Layer (HAL) for embedded systems. This crate contains asynchronous versions of the embedded-ha

Protocol for Asynchronous, Reliable, Secure and Efficient Consensus

PARSEC - Protocol for Asynchronous, Reliable, Secure and Efficient Consensus Crate Documentation Linux/macOS Windows Issues MaidSafe website SAFE Dev

An asynchronous IO utilities crate powered by tokio.

An asynchronous IO utilities crate powered by tokio.

dark-std an Implementation of asynchronous containers build on tokio

dark-std dark-std is an Implementation of asynchronous containers build on tokio. It uses a read-write separation design borrowed from Golang SyncHash

An asynchronous API client for a light installation at the University of Kiel

An asynchronous API client for a light installation at the University of Kiel

An open source, programmed in rust, privacy focused tool for reading programming resources (like stackoverflow) fast, efficient and asynchronous from the terminal.

Falion An open source, programmed in rust, privacy focused tool for reading programming resources (like StackOverFlow) fast, efficient and asynchronou

Asynchronous handle for rusqlite library.

tokio-rusqlite Asynchronous handle for rusqlite library. Usage use rusqlite::{params, Result}; use tokio_rusqlite::Connection; #[derive(Debug)] struc

Asynchronous Linux SocketCAN - Broadcast Manager support (BCM) with tokio

tokio-socketcan-bcm The Broadcast Manager protocol provides a command based configuration interface to filter and send (e.g. cyclic) CAN messages in k

Rate limit guard - Lazy rate limit semaphore implementation to control your asynchronous code frequency execution

Lazy rate limit semaphore (a.k.a fixed window algorithm without queueing) implementation to control your asynchronous code frequency execution

An asynchronous dumb exporter proxy for prometheus. This aggregates all the metrics and exposes as a single scrape endpoint.

A dumb light weight asynchronous exporter proxy This is a dumb lightweight asynchronous exporter proxy that will help to expose multiple application m

Various extention traits for providing asynchronous higher-order functions

async-hofs Various extention traits for providing asynchronous higher-order functions. // This won't make any name conflicts since all imports inside

A asynchronous implementation of the invidious innertube aka youtubei API wrapper

A asynchronous implementation of the invidious innertube aka youtubei API wrapper. Using tokio,reqwest, serde and serde_json

A complete, rate-limiting, asynchronous Rust wrapper of the Hypixel Public API with extensive SkyBlock support

rs-pixel   A complete, rate-limiting, asynchronous Rust implementation of the Hypixel Public API with extensive SkyBlock support. [dependencies] rs-pi

Owner
Andrés Felipe Quintero Moreano
Software Developer from Colombia. Rust, R, Web-Dev.
Andrés Felipe Quintero Moreano
Empowering everyone to build asynchronous software

Runtime Empowering everyone to build asynchronous software. API Docs | Contributing | Chat Built with ⛵ by The Rust Async Ecosystem WG ⚠️ Deprecation

Rust Async (archived) 867 Dec 9, 2022
Asynchronous Linux SocketCAN sockets with tokio

tokio-socketcan SocketCAN support for tokio based on the socketcan crate. Example echo server use futures_util::stream::StreamExt; use tokio_socketcan

Terry 29 Nov 8, 2022
A fully asynchronous, futures-based Kafka client library for Rust based on librdkafka

rust-rdkafka A fully asynchronous, futures-enabled Apache Kafka client library for Rust based on librdkafka. The library rust-rdkafka provides a safe

Federico Giraud 1.1k Jan 8, 2023
A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...

Tokio A runtime for writing reliable, asynchronous, and slim applications with the Rust programming language. It is: Fast: Tokio's zero-cost abstracti

Tokio 18.7k Dec 30, 2022
Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.

delay-timer Time-manager of delayed tasks. Like crontab, but synchronous asynchronous tasks are possible, and dynamic add/cancel/remove is supported.

BinCheng 255 Dec 30, 2022
Hitbox is an asynchronous caching framework supporting multiple backends and suitable for distributed and for single-machine applications.

Hitbox is an asynchronous caching framework supporting multiple backends and suitable for distributed and for single-machine applications.

null 62 Dec 27, 2022
BLEZ - Asynchronous Bluetooth Low Energy on Linux for Rust

BLEZ - Asynchronous Bluetooth Low Energy on Linux for Rust This library provides an asynchronous, fully featured interface to the Bluetooth Low Energy

Sebastian Urban 40 Oct 21, 2021
An asynchronous Prometheus exporter for iptables

iptables_exporter An asynchronous Prometheus exporter for iptables iptables_exporter runs iptables-save --counter and scrapes the output to build Prom

Kevin K. 21 Dec 29, 2022
influxdb provides an asynchronous Rust interface to an InfluxDB database.

influxdb influxdb provides an asynchronous Rust interface to an InfluxDB database. This crate supports insertion of strings already in the InfluxDB Li

null 9 Feb 16, 2021
Geng wanzheng ([a] more complete) asynchronous operating system

更完整系统(GWZOS) 更完整系统的目的是编写一个异步功能完整的异步操作系统。我们希望尽可能完整地实现异步内核的核心概念,提供相应的驱动、软件生态系统,为未来内核的设计探索可能的实现方案。对比不同解决方案的性能开销,得到较详细的内核验证结论。 感谢大家对项目的支持!接龙链接 设计文档请参考: 无相

Luo Jia 10 Aug 26, 2021