.. | |||
api | 3 days ago | ||
app | 11 days ago | ||
config | 1 day ago | ||
log | 13 days ago | ||
pkg | 1 day ago | ||
README.md | 15 days ago | ||
USECASE.md | 13 days ago | ||
api.go | 3 days ago | ||
api_handlers.go | 2 days ago | ||
converter.go | 15 days ago | ||
run_server.go | 18 days ago |
This is a great request! Based on the provided Go code, which defines a REST API for managing an Envoy xDS Configuration Snapshot, here is a comprehensive README.md
.
This package provides a REST API built in Go for managing the configuration snapshot (Cluster, Listener, Route) used by an Envoy xDS control plane. It allows for dynamic addition, removal, querying, and persistence of Envoy configuration resources.
github.com/envoyproxy/go-control-plane
) for resource definitions.All endpoints expect a JSON request body (for POST) or use query parameters (for GET).
These endpoints allow you to add or remove Envoy xDS resources from the current snapshot.
Endpoint | Method | Description | Request Body Example |
---|---|---|---|
/add-cluster |
POST |
Adds a new Envoy Cluster. | {"name": "my-cluster", "cluster": {...}} |
/remove-cluster |
POST |
Removes a Cluster by name. | {"name": "my-cluster"} |
/add-listener |
POST |
Adds a new Envoy Listener. | {"name": "my-listener", "listener": {...}} |
/remove-listener |
POST |
Removes a Listener by name. | {"name": "my-listener"} |
/add-route |
POST |
Adds a new Envoy Route configuration. | {"name": "my-route", "route": {...}} |
/remove-route |
POST |
Removes a Route by name. | {"name": "my-route"} |
Note: The
cluster
,listener
, androute
fields in the requests must contain the full, JSON-marshaled protobuf structure forclusterv3.Cluster
,listenerv3.Listener
, androuterv3.Router
respectively.
Use these endpoints to inspect the current state of the in-memory snapshot.
Endpoint | Method | Description | Query Parameters | Response Structure |
---|---|---|---|---|
/list-clusters |
GET |
Lists all enabled and disabled Clusters. | None | {"enabled": [...], "disabled": [...]} |
/get-cluster |
GET |
Retrieves the details of a specific Cluster. | ?name=my-cluster |
Full Cluster Protobuf JSON |
/list-listeners |
GET |
Lists all enabled and disabled Listeners. | None | {"enabled": [...], "disabled": [...]} |
/get-listener |
GET |
Retrieves the details of a specific Listener. | ?name=my-listener |
Full Listener Protobuf JSON |
/list-routes |
GET |
Lists all enabled and disabled Routes. | None | {"enabled": [...], "disabled": [...]} |
/get-route |
GET |
Retrieves the details of a specific Route. | ?name=my-route |
Full Route Protobuf JSON |
These handlers manage loading and saving the configuration snapshot from/to persistent storage (Database or local File).
Endpoint | Method | Description | Query Parameters |
---|---|---|---|
/load-from-db |
POST |
Loads the complete configuration from the persistent database into the snapshot cache. | None |
/flush-to-db |
POST |
Saves the current snapshot from the cache (source of truth) to the persistent database. | ?deleteMissing=true/1 (Optional) |
/flush-to-db
Logic:
- By default, it performs a logical flush (updates existing, adds new, but does not physically delete resources from the DB).
- If the query parameter
deleteMissing=true
ordeleteMissing=1
is provided, it performs an actual flush, physically deleting any resources from the database that are no longer present in the in-memory cache.
Endpoint | Method | Description | Request Body Example |
---|---|---|---|
/load-from-file |
POST |
Loads a snapshot from a local file at the specified path and applies it to the cache. | {"path": "/tmp/snapshot.json"} |
/save-to-file |
POST |
Saves the current cache snapshot to a local file at the specified path. | {"path": "/tmp/snapshot.json"} |