Skip to content

fix(app): adding fixed hash bucket and tidying loose ends#37

Merged
Jacobbrewer1 merged 5 commits intomainfrom
feat/fixed-hash-bucket
Apr 17, 2025
Merged

fix(app): adding fixed hash bucket and tidying loose ends#37
Jacobbrewer1 merged 5 commits intomainfrom
feat/fixed-hash-bucket

Conversation

@Jacobbrewer1
Copy link
Owner

Describe your changes

This pull request includes several changes focused on improving error handling, introducing new utility classes, enhancing logging functionality, and refining Kubernetes-related utilities. Below is a categorized summary of the most important changes:

Error Handling Improvements

  • Enhanced error handling in the Start method of the App struct by replacing log-based error reporting with explicit error propagation for server and async task initialization issues. (app.go, app.goR203-R245)
  • Added a new test case to validate error handling for invalid async task functions in TestApp_Start. (app_test.go, app_test.goL304-R326)

New Utility Classes

  • Introduced FixedHashBucket in the cache package, implementing a consistent hashing mechanism for bucket indexing. Includes methods for checking key membership, advancing the bucket index, and retrieving bucket properties. (cache/fixed_hash_bucket.go, cache/fixed_hash_bucket.goR1-R51)
  • Added comprehensive tests for FixedHashBucket to validate its functionality, including key distribution and index wrapping. (cache/fixed_hash_bucket_test.go, cache/fixed_hash_bucket_test.goR1-R25)

Logging Enhancements

  • Implemented dedupeHandler, a new slog.Handler that deduplicates log attributes. Includes methods for deduplication, grouping, and immutability. (logging/dedupe_handler.go, logging/dedupe_handler.goR8-R26)
  • Added unit tests for dedupeHandler to ensure correct deduplication, grouping, and record handling. (logging/dedupe_handler_bench_test.go, logging/dedupe_handler_bench_test.goL13-R134)
  • Improved replaceAttrs in logging/logger.go to handle attribute replacement more robustly, including new tests and benchmarks. (logging/logger.go, [1]; logging/logger_test.go, [2]

Kubernetes Utility Updates

  • Refined the PodName utility to retrieve the pod name using os.Hostname() as the primary method and falling back to the HOSTNAME environment variable. Added a fallback to an empty string if both methods fail. (utils/kubernetes.go, utils/kubernetes.goL15-R27)

Minor Improvements

  • Added a Shutdown method to ServiceEndpointHashBucket for cleaning up resources. (cache/service_endpoint_hash_bucket.go, cache/service_endpoint_hash_bucket.goR147)
  • Added interface compliance checks for HashBucket and slog.Handler implementations to ensure type safety. (cache/service_endpoint_hash_bucket.go, [1]; logging/dedupe_handler.go, [2]

@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot April 17, 2025 12:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot April 17, 2025 12:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

@Jacobbrewer1 Jacobbrewer1 requested a review from Copilot April 17, 2025 12:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

@Jacobbrewer1 Jacobbrewer1 marked this pull request as ready for review April 17, 2025 12:54
@Jacobbrewer1 Jacobbrewer1 merged commit d4dafa4 into main Apr 17, 2025
5 checks passed
@Jacobbrewer1 Jacobbrewer1 deleted the feat/fixed-hash-bucket branch April 17, 2025 12:55
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants