Skip to content

refactor: core services#1220

Merged
sophia-bq merged 4 commits intomainfrom
refactor/services-container
Apr 2, 2026
Merged

refactor: core services#1220
sophia-bq merged 4 commits intomainfrom
refactor/services-container

Conversation

@sophia-bq
Copy link
Copy Markdown
Contributor

Description

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@sophia-bq sophia-bq force-pushed the refactor/services-container branch 2 times, most recently from df6922a to e5f475b Compare March 26, 2026 16:16
@sophia-bq sophia-bq force-pushed the refactor/services-container branch from e5f475b to 96742b9 Compare March 30, 2026 17:27
Comment on lines +33 to +35
_event_publisher: Optional[BatchingEventPublisher] = None
_storage_service: Optional[StorageService] = None
_monitor_service: Optional[MonitorService] = None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious, do u think we need to lazily initialize these? Or would it be better to just initialize these since all connections will pretty much use them.

I like what you did here cause I feel like it's a lot more pythonic than having dependency injection everywhere, the only code smell I see is global keyword. It's not inherently bad, but would make the code cleaner (and possibly be able to remove the lock), if we just initialize these. I'm fine either way though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to be able to re-initialize them - I've gone with a services container style approach that should have no global keyword and initializes them at the start. It's a little less pythonic but fits our use case

Comment on lines +130 to +132
for key, cache_item in container.cache.items():
if cache_item.item is monitor:
container.cache._cdict.remove(key)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a way for us to remove this without doing O(n)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This particular one is because of how efm does aliases as keys for the monitors - it makes it so that we can't access by key unless we do a reverse dict

@sophia-bq sophia-bq merged commit 03888f1 into main Apr 2, 2026
11 of 15 checks passed
@sophia-bq sophia-bq deleted the refactor/services-container branch April 2, 2026 20:38
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.

3 participants