Commit 4ee67ef
Add BackendRegistry interface for thread-safe backend access
Introduce BackendRegistry as a shared kernel component in pkg/vmcp to
provide thread-safe access to discovered backends across bounded contexts
(aggregator, router, health monitoring).
This implementation addresses the requirement to store full backend
information in routing tables, enabling the router to forward requests
without additional backend lookups.
Key changes:
- Create pkg/vmcp/registry.go with BackendRegistry interface
* Get(ctx, backendID) - retrieve backend by ID
* List(ctx) - get all backends
* Count() - efficient backend count
- Implement immutableRegistry for Phase 1
* Thread-safe for concurrent reads
* Built once from discovered backends, never modified
* Suitable for static backend lists in Phase 1
- Add BackendToTarget() helper function
* Converts Backend to BackendTarget with full information
* Populates WorkloadID, WorkloadName, BaseURL, TransportType,
HealthStatus, AuthStrategy, and AuthMetadata
- Update aggregator to use BackendRegistry
* Modify Aggregator.MergeCapabilities() to accept registry parameter
* Refactor AggregateCapabilities() to create registry from backends
* Populate routing table with complete BackendTarget information
- Enhance test coverage
* Update TestDefaultAggregator_MergeCapabilities with registry
* Add assertions verifying full BackendTarget population in routing table
* Generate mocks for BackendRegistry interface
Design rationale:
Following DDD principles, BackendRegistry is placed in pkg/vmcp root as
a shared kernel component (like types.go and errors.go) to:
- Avoid circular dependencies between aggregator and router
- Provide single source of truth for backend information
- Enable reuse across multiple bounded contexts
- Support future evolution to mutable registry with health monitoring
The routing table now contains complete backend information needed for
request forwarding, eliminating the need for additional lookups during
routing (required for Issue #147).
Phase 1 uses immutableRegistry (read-only). Future phases can swap to
mutexRegistry for dynamic backend updates without API changes.
Related to Issue #148 (vMCP Capability Discovery & Querying)
Prepares for Issue #147 (Request Routing)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 30bdce8 commit 4ee67ef
File tree
6 files changed
+308
-23
lines changed- pkg/vmcp
- aggregator
- mocks
- mocks
6 files changed
+308
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
175 | 176 | | |
176 | | - | |
| 177 | + | |
177 | 178 | | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| |||
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
203 | 211 | | |
204 | 212 | | |
205 | 213 | | |
206 | 214 | | |
207 | 215 | | |
208 | | - | |
209 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
210 | 225 | | |
211 | 226 | | |
212 | 227 | | |
213 | 228 | | |
214 | 229 | | |
215 | | - | |
216 | | - | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
217 | 239 | | |
218 | 240 | | |
219 | 241 | | |
| |||
241 | 263 | | |
242 | 264 | | |
243 | 265 | | |
244 | | - | |
245 | | - | |
246 | | - | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
247 | 270 | | |
248 | 271 | | |
249 | 272 | | |
250 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
251 | 278 | | |
252 | 279 | | |
253 | 280 | | |
254 | 281 | | |
255 | 282 | | |
256 | | - | |
| 283 | + | |
257 | 284 | | |
258 | 285 | | |
259 | 286 | | |
260 | 287 | | |
261 | 288 | | |
262 | | - | |
263 | | - | |
| 289 | + | |
| 290 | + | |
264 | 291 | | |
265 | 292 | | |
266 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
313 | 313 | | |
314 | 314 | | |
315 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
316 | 335 | | |
317 | | - | |
| 336 | + | |
318 | 337 | | |
319 | 338 | | |
320 | 339 | | |
| |||
330 | 349 | | |
331 | 350 | | |
332 | 351 | | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
333 | 368 | | |
334 | 369 | | |
335 | 370 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments