FARP - Forge API Gateway Registration Protocol
FARP is a Rust implementation of the Forge API Gateway Registration Protocol - a standardized mechanism for service instances to register their API schemas, health information, and capabilities with API gateways and service discovery systems.
๐ Features
- Schema-Aware Discovery: Extend service discovery with API contract information
- Multi-Protocol Support: REST (OpenAPI), AsyncAPI, gRPC, GraphQL, oRPC, Avro, and Thrift
- Gateway Automation: Enable API gateways to auto-configure routes from schemas
- Backend Agnostic: Work with any service discovery backend (in-memory registry included)
- Type-Safe: Fully typed with comprehensive error handling
- Async First: Built on tokio for high-performance async I/O
- Zero-Downtime Updates: Support for schema versioning and compatibility checks
- Production Ready: Checksums, validation, compression, and observability built-in
๐ฆ Installation
Add FARP to your Cargo.toml:
[]
= "1.0.0"
# With all features
= { = "1.0.0", = ["full"] }
# With specific providers
= { = "1.0.0", = ["providers-openapi", "providers-asyncapi", "gateway"] }
๐ Quick Start
use *;
use Arc;
async
๐ฏ Feature Flags
FARP uses feature flags to minimize dependencies:
default: Core types + memory registrymemory-registry: In-memory registry implementationproviders-openapi: OpenAPI schema providerproviders-asyncapi: AsyncAPI schema providerproviders-grpc: gRPC/Protocol Buffer providerproviders-graphql: GraphQL schema providerproviders-orpc: oRPC providerproviders-avro: Apache Avro providerproviders-thrift: Apache Thrift providerproviders-all: All schema providersgateway: Gateway client for route conversionfull: Everything enabled
๐ Core Concepts
Schema Manifest
A Schema Manifest describes all API contracts exposed by a service instance:
Schema Descriptor
A Schema Descriptor describes a single API schema:
Location Strategies
Schemas can be retrieved via three strategies:
- HTTP: Gateway fetches from service HTTP endpoint
- Registry: Gateway fetches from backend KV store
- Inline: Schema embedded directly in manifest
๐ง Usage Examples
Create and Register a Manifest
use *;
let mut manifest = new_manifest;
manifest.add_capability;
manifest.endpoints.health = "/health".to_string;
manifest.update_checksum?;
// Register with registry
registry.register_manifest.await?;
Watch for Schema Changes
use *;
registry.watch_manifests.await?;
Gateway Integration
use Client;
let client = new;
client.watch_services.await?;
Schema Providers
use OpenAPIProvider;
use ;
;
let provider = default;
let schema = provider.generate.await?;
๐งช Testing
Run the test suite:
# Run all tests
# Run tests with all features
# Run specific test
# Run with output
Run the example:
๐ Documentation
Generate and view documentation:
๐๏ธ Architecture
FARP follows a layered architecture:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Applications & Gateways โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FARP Protocol Core โ
โ - Types & Manifests โ
โ - Provider & Registry Traits โ
โ - Validation & Checksums โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโดโโโโโโโ
โ โ
โโโโโโโโโผโโโโโโโ โโโผโโโโโโโโโโโโโโโโโ
โ Providers โ โ Registries โ
โ - OpenAPI โ โ - Memory โ
โ - AsyncAPI โ โ - (Future: etcd,โ
โ - gRPC โ โ Consul, K8s) โ
โ - GraphQL โ โ โ
โ - ... โ โ โ
โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
๐ค Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
๐ License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
๐ Related Projects
- FARP Go Implementation - Official Go implementation
- Forge Framework - Full-featured Go web framework
๐ฌ Contact
For questions or feedback, please open an issue.
Built with โค๏ธ using Rust