Skip to content

Conversation

@lowhung
Copy link
Owner

@lowhung lowhung commented Dec 24, 2025

Fixes #20

Summary

Adds module unregistration functionality to buswatch-sdk, enabling clean lifecycle management for temporary or dynamic modules.

Changes

  • Added Instrumentor::unregister(name) method to remove modules from internal state
  • Added GlobalState::unregister_module(name) for module cleanup
  • Returns true if module was found and removed, false otherwise
  • Updated README.md with comprehensive unregistration documentation
  • Updated CHANGELOG.md

Tests

Added comprehensive test coverage:

  • ✅ Unregister existing module
  • ✅ Unregister non-existent module
  • ✅ Verify metrics are removed after unregister
  • ✅ Verify re-registering works after unregister (fresh state)
  • ✅ Old handles still work but don't appear in snapshots
  • ✅ Unregistering one module doesn't affect others
  • ✅ Multiple unregister calls are safe

All 54 tests pass successfully.

Use Cases

  • Temporary worker modules that complete their tasks
  • Dynamic module registration/unregistration in multi-tenant systems
  • Cleanup of inactive modules to reduce memory footprint
  • Testing scenarios requiring module isolation

- Add Instrumentor::unregister(name) method to remove modules
- Add GlobalState::unregister_module(name) for cleanup
- Returns true if module was found and removed, false otherwise
- Comprehensive tests covering:
  - Unregister existing module
  - Unregister non-existent module
  - Verify metrics are removed after unregister
  - Verify re-registering works after unregister
  - Old handles still work but don't appear in snapshots
  - Unregistering one module doesn't affect others
  - Multiple unregister calls are safe
- Update README.md with unregistration documentation
- Update CHANGELOG.md

This enables clean lifecycle management for temporary or dynamic modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sdk): Add module unregistration

2 participants