Skip to content

backend-master666/swir

 
 

Repository files navigation

Build Status License GitHub release Awesome Badges

SWIR or Sidecar Written in Rust

For alternative meaning of SWIR

Rationale

SWIR is a platform allowing you to build applications for the cloud and on-prem environments quickly by providing an abstraction layer between your business logic and the infrastructure.

How it works

SWIR exposes a set of high level APIs that your business logic component uses to tap into underlying resources such as PubSub, State, Service Invocation. SWIR API specification in OpenApi 3.0 format can be found here

Usecases

Examples of SWIR in action for Docker, Kubernetes and AWS ECS are descibed here

Top Level Architecture

Diagram

Rust

Rust is a safe language, and side by side benchmarks show that the applications which are written in Rust achieve performance comparable with applications written in C or C++. In choosing an implementation language for a sidecar, these two factors are probably the most important. Rust language secure design guarantees that an attacker can't compromise the sidecar due to problems with memory safety. At the same time, since sidecar is responsible for most of the application's system-level functionality, it is crucial to minimise sidecar's impact on the performance. As Rust has no runtime nor garbage collector, it can run very fast and with small latency.

About Swir

This project is just a starting point to a conversation about sidecars, particularly for solutions consisting of many event-driven components. Even then it has some interesting features mainly because of the quality of crates created and maintained by Rust community: SWIR:

  • has moved to asynchronous programming
  • uses Hyper to expose REST interfaces over HTTP or HTTPS
  • uses Tonic to handle gRPC calls
  • uses rdkafka to talk to Kafka brokers
  • uses Nats to talk to NATS brokers
  • uses rusoto AWS SDK for Rust
  • uses redis-rs Redis SDK for Rust
  • is using modified config-rs so various aspects can be configured via a yaml file and environment variables can be easily injected based on an environment
  • adapted and improved mDNS(https://github.com/swir-rs/rust-mdns) to advertise/resolve services
  • SWIR uses conditional compilation which allows creating sidecars with just Kafka or Kafka and NATS
  • HTTP and gRPC Java and Python clients and other components allowing testing it end to end

Requirements

  • Docker, Docker Compose to build the project, run the infrastructure and the examples.
  • Minikube to run examples for Kubernetes
  • AWS account to run AWS based examples
  • Rust 1.44.1 or above

Similar Frameworks

SWIR has been influenced by Microsoft's Distributed Application Runtime - Dapr. It is hard to compete with Microsoft's unlimited resources, but someday perhaps SWIR might achieve a parity :)

Packages

No packages published

Languages

  • Rust 96.8%
  • Shell 2.7%
  • Dockerfile 0.5%