Preview version, will not guarantee the stability of the API! Do NOT use in production environment!
A library-first, lightweight, high-performance, cloud-native supported API gateway๐ช
SpaceGate("Spacegates are Stargates suspended in space, or in planetary orbit") From "Stargate".
๐ Core functions
- Tiny: based on rust, the executable file only takes 6MB.
- Cloud Native: Implemented the Kubernetes Gateway API specification.
- Easy to extent: Build your own plugin with rust in just two function.
- Easy to extent: Build your own plugin with rust in just two function.
- High performance
- Low resource usage
Usage
Use spacegate in k8s
Install for kubernetes
kubectl apply -f https://github.com/ideal-world/spacegate/releases/download/0.2.0-alpha.1/spacegate-0.2.0-alpha.1.yaml
Open spacegate admin web,and enjoy!
Use spacegate as an executable binary
Build and Install
Build and install on your own linux machine.
Install spacegate
sh resource/install/install.sh
Install spacegate-admin manage tool (Optional)
This official manage tool will provide you a web interface to edit gateway's config.
sh resource/install/install-admin.sh
Configure your gateway
Visit localhost:9991 if you installed spacegate-admin manage tool.
firefox localhost:9991
Or visit config folder
ls /etc/spacegate
After you edited config, use systemctl to reload config.
sudo systemctl reload spacegate
Install plugin
Check the plugin folder:
ls /lib/spacegate/plugins
Just and put the .so
file under the plugin folder and configure it.
Use spacegate as a rust lib
You can use spacegate-kernel
or spacegate-shell
. The The former one is relatively low-level, while the latter integrates plugins and configuration systems.
Use spacegate-shell
= { ="https://github.com/ideal-world/spacegate", ="dev" }
Start up by a config change listener
async
or just using build-in listeners
// file config
startup_file.await;
// k8s resource
startup_k8s.await;
// fetch from redis
startup_redis.await;
Use spacegate-kernel
= { ="https://github.com/ideal-world/spacegate", ="dev" }
Create a listener and a gateway service
let cancel = default;
// create a gateway service
let gateway = builder
.http_routers
.build;
let addr = from_str?;
// create a listener
let listener = new;
// start listen
listener.listen.await?;
Create your own plugins in rust
All you need to do is to implements a Plugin
trait
use ;
Use the plugin as a static lib
In your application program.
// register the plugin into global plugin repository
global.
Use the plugin as a dynamic linked lib
Use the macro dynamic_lib
use dynamic_lib;
dynamic_lib!
and set the crate-type to dylib
[]
= ["dylib"]
After you got the lib file, load it in application program.
For example:
.register_dylib
global
Why create this project
There are a lot of API gateway products out there, but they are mostly in the form of standalone services. The customization ability is relatively poor, and the cost of using and deploying is relatively high.
This project is based on the Rust
language and uses hyper
as the base network library. The goal is to: provide a library-first, lightweight, high-performance, cloud-native supported API gateway .
๐ฆ Components
Project Structure
๐ Releases
Release binary naming method: {crate}-{arch}{OS}{abi}-{version} download here
OS | Arch | abi | Remark |
---|---|---|---|
linux | x86_64,aarch64 | gnu,musl | If you need static linking please use musl |