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

fix(MockResponse): added thread-safe to the MockResponse #155

Conversation

nomadesoft
Copy link
Contributor

@nomadesoft nomadesoft commented Aug 30, 2024

Summary

The PR adds thread-safety to the MockResponse struct by introducing a sync.RWMutex and ensuring that all read and write operations on the MockResponse fields are properly synchronized.

Motiviation

Prevent race conditions.
image

Changes

  1. mocks.go:
    • Added a sync.RWMutex field mu to the MockResponse struct.
    • Wrapped read operations with RLock and RUnlock.
    • Wrapped write operations with Lock and Unlock.

@steinfletcher steinfletcher merged commit 913343f into steinfletcher:master Aug 30, 2024
2 checks 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.

2 participants