Skip to content

feat: added code improvements for cache and concurrency#3

Merged
jgrigorian merged 1 commit intomasterfrom
code_improvements-2025-06-13
Jun 13, 2025
Merged

feat: added code improvements for cache and concurrency#3
jgrigorian merged 1 commit intomasterfrom
code_improvements-2025-06-13

Conversation

@jgrigorian
Copy link
Owner

Purpose

What is the context of this pull request? Why is it being done?

Overall code improvements (changes detailed below).

Notable Changes

Are there any changes that need to be called out as particularly tricky or significant?

1. Certificate Caching:

  • Added a thread-safe cache for parsed certificates using a sync.RWMutex
  • Certificates are now cached by their PEM data, preventing redundant parsing
  • Added a ClearCertCache function to manage cache memory usage

2. Concurrent Processing:

  • Implemented a worker pool pattern for processing certificates
  • Certificates are now processed concurrently using goroutines
  • The number of workers is configurable (currently set to 4)
  • Results are collected through a channel for thread-safe processing

3. Better Error Handling:

  • Added proper error handling throughout the codebase
  • Errors are now propagated up the call stack
  • Added detailed error messages for certificate parsing failures
  • Errors are displayed to the user without crashing the application

4. Memory Optimization:

  • Removed unnecessary channel usage in the list command
  • Implemented proper cleanup of resources
  • Added structured error reporting to help identify issues

5. Code Quality Improvements:

  • Added type safety with a certInfo struct
  • Improved code organization and readability
  • Removed redundant code and comments
  • Added proper documentation

Risks

Detail any potential risks and what will be done to minimize/prevent them.
N/A

Launch Plan

Are there any special considerations to who should deploy or when or how?
N/A

Gif (optional)

Gif (optional)

@jgrigorian jgrigorian merged commit 26d88af into master Jun 13, 2025
1 check passed
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.

1 participant