Skip to content

Commit

Permalink
Merge branch 'dev-v3.0.0' into main-ci-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyansong-adbe authored Jan 15, 2021
2 parents 5c3943e + e3882cf commit 8a421af
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 409 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ on:
required: true
default: '1.0.0'

action_verification:
description: 'Pod/SPM verification ("no" to skip)'
required: true
default: 'yes'

action_tag:
description: 'create tag ("no" to skip)'
required: true
Expand Down Expand Up @@ -65,14 +60,14 @@ jobs:
make check-version VERSION=${{ github.event.inputs.tag }}
- name: SPM integration test
if: ${{ github.event.inputs.action_verification == 'yes' }}
if: ${{ github.event.inputs.action_tag == 'yes' }}
run: |
set -eo pipefail
echo SPM integration test starts:
make test-SPM-integration
- name: podspec file verification
if: ${{ github.event.inputs.action_verification == 'yes' }}
if: ${{ github.event.inputs.action_tag == 'yes' }}
run: |
set -eo pipefail
echo podspec file verification starts:
Expand All @@ -89,6 +84,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# pod lib lint AEPServices.podspec --allow-warnings --swift-version=5.1

- name: Publish Pods - AEPServices
if: ${{ github.event.inputs.release_AEPServices == 'yes' }}
run: |
Expand Down
1 change: 0 additions & 1 deletion AEPIdentity/Sources/IdentityHitProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class IdentityHitProcessor: HitProcessing {
}

// MARK: HitProcessing
var batchLimit = 0

func retryInterval(for entity: DataEntity) -> TimeInterval {
return TimeInterval(30)
Expand Down
2 changes: 0 additions & 2 deletions AEPServices/Mocks/MockHitProcessor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
import Foundation

public class MockHitProcessor: HitProcessing {
public var batchLimit: Int

public init() {
self.batchLimit = 0
}

public func retryInterval(for entity: DataEntity) -> TimeInterval {
Expand Down
3 changes: 0 additions & 3 deletions AEPServices/Sources/utility/hitprocessor/HitProcessing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import Foundation
/// A class of types who provide the functionality for processing hits
public protocol HitProcessing: class {

/// batchLimit: an `Int` specifies the number of hits to be batched to start processing hits
var batchLimit: Int { get set}

/// Determines the interval at which a hit should be retried
/// - Parameter entity: The hit whose retry interval is to be computed
func retryInterval(for entity: DataEntity) -> TimeInterval
Expand Down
33 changes: 3 additions & 30 deletions AEPServices/Sources/utility/hitprocessor/PersistentHitQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public class PersistentHitQueue: HitQueuing {
private static let DEFAULT_RETRY_INTERVAL = TimeInterval(30)
private var suspended = true
private let queue = DispatchQueue(label: "com.adobe.mobile.persistenthitqueue")
private var currentBatchSize = 0
private var batching = false

/// Creates a new `HitQueue` with the underlying `DataQueue` which is used to persist hits
/// - Parameter dataQueue: a `DataQueue` used to persist hits
Expand All @@ -39,23 +37,15 @@ public class PersistentHitQueue: HitQueuing {

public func beginProcessing() {
queue.async { self.suspended = false }
batching = self.processor.batchLimit > 0
processNextHit()
}

// Processes the queued hits ignoring the batchLimit
public func forceProcessing() {
queue.async { self.suspended = false }
processNextHit(ignoreBatchLimit: true)
}

public func suspend() {
queue.async { self.suspended = true }
}

public func clear() {
_ = dataQueue.clear()
self.currentBatchSize = 0
}

public func count() -> Int {
Expand All @@ -68,20 +58,8 @@ public class PersistentHitQueue: HitQueuing {
}

/// A recursive function for processing hits, it will continue processing all the hits until none are left in the data queue
/// - Parameter ignoreBatchLimit: a `Bool` flag to determine batching hits
private func processNextHit(ignoreBatchLimit: Bool = false) {
private func processNextHit() {
queue.async {
if self.batching && !ignoreBatchLimit {
// check if number of queued hits > batchLimit and currently we are not processing a batch of hits
if self.dataQueue.count() >= self.processor.batchLimit && self.currentBatchSize == 0 {
// There is no batch being processed currently so set the currentBatchSize to batchLimit
self.currentBatchSize = self.processor.batchLimit
}

// Only process hits if number of queued hits >= batchLimit
guard self.currentBatchSize > 0 else { return }
}

guard !self.suspended else { return }
guard let hit = self.dataQueue.peek() else { return } // nothing left in the queue, stop processing

Expand All @@ -91,16 +69,11 @@ public class PersistentHitQueue: HitQueuing {
// successful processing of hit, remove it from the queue, move to next hit
_ = self?.dataQueue.remove()

if self?.batching ?? false {
// Successfully processed hit, so update the currentBatchSize to reflect remaining number of hits to be processed
self?.currentBatchSize -= 1
}

self?.processNextHit(ignoreBatchLimit: ignoreBatchLimit)
self?.processNextHit()
} else {
// processing hit failed, leave it in the queue, retry after the retry interval
self?.queue.asyncAfter(deadline: .now() + (self?.processor.retryInterval(for: hit) ?? PersistentHitQueue.DEFAULT_RETRY_INTERVAL)) {
self?.processNextHit(ignoreBatchLimit: ignoreBatchLimit)
self?.processNextHit()
}
}

Expand Down
Loading

0 comments on commit 8a421af

Please sign in to comment.