feat: improve documentation, tests, and examples#13
Merged
Conversation
This commit significantly enhances the go-pglock package with comprehensive documentation, improved test coverage, and practical examples for common distributed locking patterns. Documentation improvements: - Rewrite README.md with 10 detailed examples covering real-world use cases including leader election, task processing, resource pools, and migrations - Add QUICKREF.md with concise API reference, patterns, and troubleshooting - Add examples/README.md with detailed guide for running example programs - Enhance all Go doc strings in lock.go following best practices with comprehensive descriptions of behavior, parameters, and edge cases - Add package-level documentation explaining PostgreSQL advisory locks Test improvements: - Add 12 comprehensive test cases covering: * Basic lock acquisition and release * Lock stacking behavior (multiple acquisitions) * Context cancellation and timeout handling * Concurrent lock attempts with race detection * Blocking vs non-blocking behavior * Lock cleanup via Close() * Error cases and edge conditions - Improve test helpers with t.Helper(), require assertions, and better error messages - Add proper test skipping when DATABASE_URL is not set - All tests pass with race detector enabled Example programs: - Add 5 complete, runnable example programs demonstrating: * basic/ - Simple lock acquire/release pattern * workers/ - Concurrent workers coordinating access * leader-election/ - Cluster leadership election * timeout/ - Context timeout and cancellation * task-processing/ - Distributed task coordination - All examples compile successfully and include proper error handling Development tooling: - Add docker-compose.yml for easy PostgreSQL test database setup - Enhance Makefile with test-race, test-coverage, docker-up, docker-down, and test-local targets for improved developer experience The documentation now provides clear guidance from basic usage to advanced patterns, with 10 real-world examples, troubleshooting guides, and best practices. Test coverage includes comprehensive scenarios with proper concurrency testing and edge case handling.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit significantly enhances the go-pglock package with comprehensive documentation, improved test coverage, and practical examples for common distributed locking patterns.
Documentation improvements:
Test improvements:
Example programs:
Development tooling:
The documentation now provides clear guidance from basic usage to advanced patterns, with 10 real-world examples, troubleshooting guides, and best practices. Test coverage includes comprehensive scenarios with proper concurrency testing and edge case handling.