Create protocol layers for EventHistory and EventHistoryDatabase#1136
Merged
timkimadobe merged 6 commits intoadobe:feature/historical-consequencefrom Apr 29, 2025
Merged
Conversation
… EventHub to use dependency injection for EventHistory Update MockEventHistoryDatabase to use new EventHistoryDatabaseService protocol Update EventHistory and EventHistoryDatabase to conform to their respective protocols Update MockEventHistory to conform to EventHistoryService protocol and fix implementation Fix EventHubEventHistoryTests to use the instantiated eventhub instance not the shared one # Conflicts: # AEPCore.xcodeproj/project.pbxproj # AEPCore/Mocks/PublicTestUtils/MockEventHistoryDatabase.swift # AEPCore/Tests/EventHubTests/EventHubEventHistoryTests.swift # AEPCore/Tests/TestHelpers/MockEventHistory.swift
This was referenced Apr 24, 2025
cdhoffmann
approved these changes
Apr 24, 2025
Contributor
There was a problem hiding this comment.
Looks great! I really want @sbenedicadb to take a look as well though :)
prudrabhat
approved these changes
Apr 25, 2025
prudrabhat
reviewed
Apr 25, 2025
| private var preprocessors = ThreadSafeArray<EventPreprocessor>(identifier: "com.adobe.eventHub.preprocessors.queue") | ||
| private var started = false // true if the `EventHub` is started, false otherwise. Should only be accessed from within the `eventHubQueue` | ||
| private var eventHistory = EventHistory() | ||
| private var eventHistory: EventHistoryService? |
There was a problem hiding this comment.
Can this be made to a Kotlin final/val equivalent
Contributor
Author
There was a problem hiding this comment.
I didn't see any usages either in production or testing where setting this directly is used, so I've updated this from var to let
Update EventHistory init to accommodate this read only access to the backing storage
4f4240d
into
adobe:feature/historical-consequence
17 checks passed
This was referenced Jul 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR creates protocol layers for EventHistory and EventHistoryDatabase for a cleaner testing setup.
The new protocols,
EventHistoryServiceandEventHistoryDatabaseService, simply define the current internally available methods from their respective classes.The existing
EventHistoryandEventHistoryDatabaseclasses have been updated to conform to their respective protocols.EventHubhas been updated to use theEventHistoryServiceprotocol foreventHistoryand use dependency injection to set this value, with the default being the realEventHistoryEventHistoryas the default value, it doesn't change the signature of any previous calls toEventHub()Note
My understanding (please correct me if I'm wrong!) is that this also shouldn't change any real, meaningful runtime behavior of
EventHub, since by moving the instantiation ofEventHistoryfrom the default property value to the initializer,EventHistorycreation and set is being moved from phase 1 to phase 2 of class initialization as described here: https://docs.swift.org/swift-book/documentation/the-swift-programming-language/initialization/#Two-Phase-InitializationEventHistorystill happens completely within the initialization process ofEventHubRelated Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: