Specification

Complete FARP protocol specification reference

This page provides a condensed reference of the FARP protocol specification. For the full specification, see SPECIFICATION.md.

Protocol Overview

FARP defines a standard format for services to advertise their API schemas, health information, and capabilities to API gateways and service meshes. The protocol consists of:

  1. Schema Manifest — JSON document describing a service instance's API surface
  2. Schema Providers — Components that generate schemas from application code
  3. Schema Registry — Storage abstraction for manifests and schemas
  4. Schema Merger — Utilities for composing multiple schemas into unified documentation

Registration Flow

1. Service starts
2. Schema providers generate schemas (OpenAPI, gRPC, etc.)
3. Service creates a SchemaManifest
4. Service registers the manifest with a discovery backend
5. Gateway watches for manifest changes
6. Gateway fetches schemas and auto-configures routes
7. On schema update: service updates manifest, gateway reconfigures
8. On shutdown: service deregisters manifest

Core Data Structures

SchemaManifest Fields

FieldTypeRequiredDescription
versionstringYesProtocol version (semver)
service_namestringYesLogical service name
service_versionstringYesService version (semver)
instance_idstringYesUnique instance identifier
instanceInstanceMetadataNoInstance metadata
schemasSchemaDescriptor[]YesAPI schemas
capabilitiesstring[]NoSupported protocols
endpointsSchemaEndpointsYesIntrospection URLs
routingRoutingConfigNoGateway routing config
authAuthConfigNoAuthentication config
webhookWebhookConfigNoBidirectional communication
hintsServiceHintsNoOperational hints
updated_atint64YesUnix timestamp
checksumstringYesSHA256 of all schemas

Schema Types

TypeConstantSupported Spec Versions
OpenAPIopenapi3.0.x, 3.1.x
AsyncAPIasyncapi2.x, 3.0.x
gRPCgrpcproto2, proto3
GraphQLgraphql2021, June 2018
oRPCorpc1.0.0
Thriftthrift0.19.x
Avroavro1.11.x
Customcustom

Location Types

TypeBehavior
inlineSchema embedded directly in manifest
httpSchema fetched via HTTP GET
registrySchema stored in registry KV store

Mount Strategies

StrategyURL Pattern
root/path
instance/{instance_id}/path
service/{service_name}/path
versioned/{service_name}/{version}/path
custom/{base_path}/path
subdomain{subdomain}.gateway.com/path

Interfaces

SchemaProvider

Type() SchemaType
Generate(ctx, app) (any, error)
Validate(schema) error
Hash(schema) (string, error)
Serialize(schema) ([]byte, error)
Endpoint() string
SpecVersion() string
ContentType() string

SchemaRegistry

RegisterManifest(ctx, manifest) error
GetManifest(ctx, instanceID) (*SchemaManifest, error)
UpdateManifest(ctx, manifest) error
DeleteManifest(ctx, instanceID) error
ListManifests(ctx, serviceName) ([]*SchemaManifest, error)
PublishSchema(ctx, path, schema) error
FetchSchema(ctx, path) (any, error)
DeleteSchema(ctx, path) error
WatchManifests(ctx, serviceName, handler) error
WatchSchemas(ctx, path, handler) error
Close() error
Health(ctx) error

StorageBackend

Put(ctx, key, value) error
Get(ctx, key) ([]byte, error)
Delete(ctx, key) error
List(ctx, prefix) ([]string, error)
Watch(ctx, prefix) (<-chan StorageEvent, error)
Close() error

Service Hints

Non-binding operational hints for gateways:

type ServiceHints struct {
    PreferredLoadBalancer LoadBalancerType `json:"preferred_lb,omitempty"`
    MaxConcurrency        int              `json:"max_concurrency,omitempty"`
    RateLimit             *RateLimitHint   `json:"rate_limit,omitempty"`
    CircuitBreaker        *CircuitBreakerHint `json:"circuit_breaker,omitempty"`
    Timeout               *TimeoutHint     `json:"timeout,omitempty"`
    Retry                 *RetryHint       `json:"retry,omitempty"`
    Caching               *CachingHint     `json:"caching,omitempty"`
}

Service hints are advisory. Gateways may override them based on their own policies.

Error Types

ErrorDescription
ErrManifestNotFoundManifest not in registry
ErrSchemaNotFoundSchema not in registry
ErrInvalidManifestManifest fails validation
ErrInvalidSchemaSchema fails validation
ErrInvalidLocationUnknown location type
ErrSchemaToLargeSchema exceeds size limit
ErrRegistryUnavailableRegistry backend unreachable
ErrProviderNotFoundUnknown schema provider

How is this guide?

On this page