Removing a registered or subscribed service leaves stale local metadata After a…
- User
Removing a registered or subscribed service leaves stale local metadata
After a successful unregister or unsubscribe operation, the corresponding provider or consumer URL must no longer participate in local metadata, service matching, or revision calculation. Removing one URL must preserve unrelated registrations. If the remote operation fails, local metadata must not be removed as though the operation succeeded.
Interface
Type: Function Name: RemoveService Path: metadata/metadata.go Input: registryId string, url *common.URL Output: (no return value) Description: Removes a provider service URL from the local metadata for the given registry. Use this during unregister flows to keep the in-memory application-level metadata consistent with the actual exported services.
Type: Function Name: RemoveSubscribeURL Path: metadata/metadata.go Input: registryId string, url *common.URL Output: (no return value) Description: Removes a subscribed service URL from the local metadata for the given registry. Use this during unsubscribe flows to ensure stale subscribed URLs are cleaned from the application-level metadata.
- Assistant
Let me check how revision is calculated and where UnRegister/UnSubscribe are called from.
- Assistant
Now let me check the metadata package tests and the
DefaultMetadataService: - Assistant
Now I'll implement the changes. First, add the package-level functions to
metadata/metadata.go: - Assistant
Now make
removeUrlinmetadata/info/metadata_info.gorobust to equivalent (non-identical-pointer) URLs: - Assistant
Also tighten
MetadataInfo.RemoveServiceso removing one URL doesn't drop theServiceInfowhile another exported URL with the same match key remains: - Assistant
Now wire these into the unregister/unsubscribe flows in
service_discovery_registry.go: - Assistant
Now build and add tests. First verify compilation:
- Assistant
Now add tests for the new functions in
metadata/metadata_test.go: - Assistant
Tests pass. Now add a test in
metadata/infocovering removal via an equivalent (non-identical) URL pointer: - Assistant
Now let me check existing tests for the service discovery registry:
- Assistant
Now add tests for the unregister/unsubscribe metadata cleanup in the registry:
- Assistant
Now append the new flow tests:
- Assistant
All pass. Run the broader test suite for the affected packages plus vet:
- Assistant
All packages pass. Final check — formatting:
- Assistant
Done. The fix is implemented across three files:
metadata/metadata.go— added the two required package-level functions:RemoveService(registryId string, url *common.URL)— removes a provider URL from the registry's localMetadataInfo(metadata/metadata.go:60)RemoveSubscribeURL(registryId string, url *common.URL)— removes a subscribed URL (metadata/metadata.go:68)
Both are no-ops for unknown registry IDs.
— two robustness fixes:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.