Leanplum / Leanplum-Android-SDK

Leanplum's integrated solution delivers meaningful engagement across messaging and the in-app experience.
https://www.leanplum.com
Apache License 2.0
46 stars 40 forks source link

Refactor batching of requests #425

Closed hborisoff closed 4 years ago

hborisoff commented 4 years ago
What Where/Who
JIRA Issue SDK-140
People Involved @hborisoff

Background

There are several changes to the batching functionality:

  1. Removed LeanplumDataBaseManager.migrateFromSharedPreferences as the migration was done several years ago and there aren't any clients using such old sdk version.

  2. Removed synchronized (Request.class) synchronisation code from several places. All of the code was running synced except the LeanplumDataBaseManager.migrateFromSharedPreferences method, which is now removed.

  3. Moved the old inner class RequestsWithEncoding to a separate RequestBatch.java.

  4. Moved the batching codebase from RequestSender to a RequestBatchFactory class. It contains several new public methods:

    • createErrorBatch - called if there is DB error
    • createNextBatch - gets the next batch of events from DB
    • deleteFinishedBatch - deletes the events from DB
  5. UUID parameter After discussion with backend guys the request UUID param needs to be persisted with the requests in the DB because on server-side there is a 'dedup' logic that compares them by uuid and reqId parameters, and ignores the duplicates.

Moved all UUID related code to RequestUuidHelper.java. It contains several public methods: