Skip to content

Add Thread Safety and Write Function#1

Merged
Kansuler merged 1 commit intomainfrom
feature/writeconfig
Oct 1, 2025
Merged

Add Thread Safety and Write Function#1
Kansuler merged 1 commit intomainfrom
feature/writeconfig

Conversation

@Kansuler
Copy link
Copy Markdown
Owner

@Kansuler Kansuler commented Oct 1, 2025

Summary

This PR makes the configura package thread-safe and adds a new WriteConfiguration function for setting config values programmatically (mainly for testing).

Changes

  • Thread Safety: Added RWMutex locks to all config operations to handle concurrent access safely
  • New Function: WriteConfiguration() - lets you set config values directly, useful for mocking in tests
  • Private Fields: Changed RegString, RegInt, etc. to private fields (regString, regInt) to prevent direct access
  • Pointer Receivers: Config methods now use *ConfigImpl instead of ConfigImpl
  • Enhanced Tests: Added thread safety tests with race detection and updated existing tests to use the new function

Breaking Changes

  • Config fields are now private - use the interface methods instead of direct field access
  • If you were accessing config.RegString[key] directly, use WriteConfiguration() or the getter methods instead

Testing

  • All tests updated to use WriteConfiguration()
  • New thread safety tests with 100 concurrent goroutines
  • CI now runs with race detection enabled

The package is now safe for concurrent use and provides better encapsulation while maintaining the same public API.

Copilot AI review requested due to automatic review settings October 1, 2025 18:32
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 1, 2025

Golang Build & Test status 🚀

Go Test Outcome 🧪success

Coverage Report 📊success

Pusher: @Kansuler, Action: pull_request, Working Directory: ``, Workflow: Go Test Coverage Report On Pull Request

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Oct 1, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.75% (target: -1.00%) 85.92%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (dadac6e) 356 319 89.61%
Head commit (59d9bf6) 446 (+90) 403 (+84) 90.36% (+0.75%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1) 213 183 85.92%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Copy link
Copy Markdown

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.

Pull Request Overview

This PR makes the configura package thread-safe and adds a new WriteConfiguration function for programmatically setting config values. The changes introduce proper concurrency control while maintaining the existing public API through encapsulation improvements.

Key changes include:

  • Added thread safety with RWMutex locks for all configuration operations
  • Introduced WriteConfiguration() function for setting config values programmatically (mainly for testing)
  • Changed public fields to private fields with pointer receivers for better encapsulation

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
configura.go Core implementation with thread safety locks, WriteConfiguration function, and private field changes
configura_test.go Updated all tests to use WriteConfiguration instead of direct field access
configura_thread_safety_test.go New comprehensive thread safety test suite with concurrent access testing
.github/workflows/test-coverage-pr.yaml Added race detection flag to test command
.github/workflows/test-coverage-main.yaml Added race detection flag to test command

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Kansuler Kansuler force-pushed the feature/writeconfig branch from b42cf97 to 8bc6995 Compare October 1, 2025 18:43
@Kansuler Kansuler requested a review from Copilot October 1, 2025 18:44
@Kansuler Kansuler force-pushed the feature/writeconfig branch from 8bc6995 to 71171ae Compare October 1, 2025 18:44
Copy link
Copy Markdown

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.

Pull Request Overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Kansuler Kansuler force-pushed the feature/writeconfig branch from 71171ae to 0ebd554 Compare October 1, 2025 18:56
@Kansuler Kansuler force-pushed the feature/writeconfig branch from 0ebd554 to 59d9bf6 Compare October 1, 2025 18:57
@Kansuler Kansuler changed the title Add Thread Safety and WriteConfiguration Function Add Thread Safety and Write Function Oct 1, 2025
@Kansuler Kansuler merged commit 84dd334 into main Oct 1, 2025
3 of 4 checks passed
@Kansuler Kansuler deleted the feature/writeconfig branch October 1, 2025 18:58
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.

2 participants