-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfarp.go
More file actions
72 lines (72 loc) · 2.26 KB
/
farp.go
File metadata and controls
72 lines (72 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Package farp implements the Forge API Gateway Registration Protocol (FARP).
//
// FARP is a protocol specification for enabling service instances to automatically
// register their API schemas, health information, and capabilities with API gateways
// and service meshes.
//
// # Overview
//
// FARP provides:
// - Schema-aware service discovery (OpenAPI, AsyncAPI, gRPC, GraphQL)
// - Dynamic gateway configuration based on registered schemas
// - Multi-protocol support with extensibility
// - Health and telemetry integration
// - Backend-agnostic storage (Consul, etcd, Kubernetes, Redis, Memory)
// - Push and pull models for schema distribution
// - Zero-downtime schema updates with versioning
//
// # Basic Usage
//
// Creating a schema manifest:
//
// manifest := farp.NewManifest("user-service", "v1.2.3", "instance-abc123")
// manifest.AddSchema(farp.SchemaDescriptor{
// Type: farp.SchemaTypeOpenAPI,
// SpecVersion: "3.1.0",
// Location: farp.SchemaLocation{
// Type: farp.LocationTypeHTTP,
// URL: "http://user-service:8080/openapi.json",
// },
// ContentType: "application/json",
// })
// manifest.AddCapability(farp.CapabilityREST.String())
// manifest.Endpoints.Health = "/health"
// manifest.UpdateChecksum()
//
// Registering with a registry:
//
// registry := memory.NewRegistry()
// err := registry.RegisterManifest(ctx, manifest)
//
// # Schema Providers
//
// Schema providers generate schemas from application code:
//
// type MyProvider struct {
// farp.BaseSchemaProvider
// }
//
// func (p *MyProvider) Generate(ctx context.Context, app farp.Application) (interface{}, error) {
// // Generate schema from app
// return schema, nil
// }
//
// farp.RegisterProvider(&MyProvider{})
//
// # Gateway Integration
//
// Gateways watch for schema changes:
//
// registry.WatchManifests(ctx, "user-service", func(event *farp.ManifestEvent) {
// if event.Type == farp.EventTypeAdded || event.Type == farp.EventTypeUpdated {
// // Fetch schemas and reconfigure gateway routes
// configureGatewayFromManifest(event.Manifest)
// }
// })
//
// # Protocol Version
//
// Current protocol version: 1.0.0
//
// For full documentation, see: https://github.com/xraph/forge/tree/main/farp/docs
package farp