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

Refactor Agency Configuration File Handling and Add Tests #10

Merged
merged 7 commits into from
Dec 20, 2023

Conversation

bonk1t
Copy link
Owner

@bonk1t bonk1t commented Dec 19, 2023

  • Introduced AgencyConfigStorageInterface, an abstract base class defining a standard interface for agency configuration storage.
  • Implemented AgencyConfigFileStorage, a concrete class that extends AgencyConfigStorageInterface. It provides thread-safe file operations for agency-specific configurations using a context manager pattern.
  • Ensured thread safety in AgencyConfigFileStorage by integrating AgencyConfigLockManager for managing locks based on agency IDs.
  • Added comprehensive unit tests for AgencyConfigFileStorage to validate functionality such as lock acquisition/release, loading and saving configuration data, and handling default configuration fallbacks when specific agency files are not present.

@bonk1t bonk1t requested a review from guiparpinelli December 19, 2023 19:09
@bonk1t bonk1t changed the title Refactor agency config Refactor Agency Configuration File Handling and Add Tests Dec 19, 2023
Returns:
self: An instance of AgencyConfigFileStorage.
"""
self.lock = AgencyConfigLockManager.get_lock(self.agency_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

My original plan for the context manager implementation was to eliminate the need for a separate lock manager class. Instead, the context manager itself would handle the lock. This means that upon entering the context (i.e., during the enter method), it would acquire the lock and then return the opened file. Conversely, upon exiting the context (exit method), it would release the lock and close the file.

@@ -4,6 +4,7 @@ version = "1.0.0"
description = "Nalgonda is a FastAPI app to manage swarm agencies"
authors = [
"Nikita Bobrovskiy <[email protected]>",
"Guilherme Parpinelli <[email protected]>",
Copy link
Contributor

Choose a reason for hiding this comment

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

😀

@bonk1t bonk1t merged commit a8e1a96 into main Dec 20, 2023
1 check passed
@bonk1t bonk1t deleted the feat/refactor-agency-config branch December 20, 2023 16:07
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