Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): enhance error handling and thread safety in log management #1013

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Commits on Mar 22, 2024

  1. feat(api): enhance error handling and thread safety in log management

    This commit introduces improved error handling in the logHandler function within the API, ensuring that any errors encountered while writing to or resetting the memory log are properly logged and communicated back to the client with an appropriate HTTP status code. Additionally, the circularBuffer struct in the logging mechanism now incorporates a mutex to ensure thread-safe operations, particularly for the Reset method which has been updated to clear all chunks and reset read/write pointers under lock protection.
    
    The changes include:
    - Logging errors and returning HTTP 500 (Internal Server Error) if writing the memory log to the response writer fails.
    - Similarly, logging errors and returning HTTP 500 if resetting the memory log fails.
    - Updating the HTTP method not allowed error response to set the "Allow" header correctly and use the more appropriate HTTP 405 (Method Not Allowed) status code.
    - Adding a mutex to the circularBuffer struct to protect concurrent access, particularly in the Reset method which now clears all buffer chunks safely.
    
    These enhancements aim to improve the robustness and concurrency safety of the log management functionality, ensuring that the system can handle errors gracefully and maintain consistent state even in multi-threaded environments.
    skrashevich committed Mar 22, 2024
    Configuration menu
    Copy the full SHA
    7760174 View commit details
    Browse the repository at this point in the history

Commits on Apr 22, 2024

  1. Configuration menu
    Copy the full SHA
    abc3dde View commit details
    Browse the repository at this point in the history

Commits on May 12, 2024

  1. Configuration menu
    Copy the full SHA
    3e45513 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f1a670d View commit details
    Browse the repository at this point in the history
  3. perf(log): optimize circularBuffer.Bytes() method for efficiency

    Optimized the Bytes method in circularBuffer to precalculate the total length of the resulting byte slice, reducing allocations. Added tests and benchmarks for the Bytes method to ensure correctness and measure performance improvements.
    skrashevich committed May 12, 2024
    Configuration menu
    Copy the full SHA
    95703e6 View commit details
    Browse the repository at this point in the history