Page MenuHomePhabricator

Implement StorageManager in MEP
Closed, ResolvedPublic


We need to implement the persistence layer of the new Event Platform Client library. Some general thoughts are:

  1. Setup a new Core Data database, like how EventLoggingService works.
  2. Add ability for StorageManager to hold and manipulate a buffer of Events in memory. These are events coming from the library before the library has downloaded a stream configuration, so there's no where to post these to yet.
  3. Add ability for StorageManager to persist, delete, and restore stored items of any type according to a key. Our queue of events in part 2 leans on this when the app closes and the user has not yet downloaded a stream configuration.
  4. Add ability for StorageManager to save post items (these will contain event data and meta data with stream information), update post items, purge stale post items, and pull a batch of events for the network manager to post. NetworkManager use these periodically to pull data to fetch.
  5. Ensure StorageManager's deviceID matches and is in sync with EventLoggingService's appInstallID.

Interface thoughts:

	func persistBuffer()
	func restoreBuffer()
	func deleteBuffer()
	var buffer: [Event]
	func appendEventToBuffer(event: Event)
	func removeBufferAtIndex(index: Int)
	func savePostItem(with body: String) //body could be a more structured object
	func updatePostItem(success: Bool)
	func deleteStalePostItems()
	func fetchPostItemsToPost() -> [PostItem]

class Event: NSManagedObject {
        let stream: String
        let schema: String
        let data: [String: Any]
        let domain: String?

class PostItem: NSManagedObject {
        let body: String //again this could be a more structured set of data
        let recorded: Date
        let posted: Date
        let failed: Bool

Event Timeline

Tsevener renamed this task from Implement StorageManager in MEP library to Implement StorageManager in MEP.Jul 30 2020, 4:17 PM
Tsevener triaged this task as Medium priority.Jul 31 2020, 9:39 PM

StorageManager is implemented in PR, in analytics' court for end-to-end testing.

Marking as resolved. For record-keeping: we decided to remove storage managing functionality for the initial release. There are still some open questions around specification (e.g. how many events we want to persist and how), so for the version 1 release and the pilot we are going with a simpler version of the library which does not persist anything.

PR is approved (albeit not yet merged) so calling this done.