- ///////////////////////////////////////
- // A. Update user state with new resource instance amount
- // TODO: Check if we are at beginning of billing period, so as to use
- // costPolicy.computeResourceInstanceAmountForNewBillingPeriod
- val DefaultResourceInstanceAmount = costPolicy.getResourceInstanceInitialAmount
-
- val previousAmount = currentUserState.getResourceInstanceAmount(resource, instanceId, DefaultResourceInstanceAmount)
- val newAmount = costPolicy.computeNewResourceInstanceAmount(previousAmount, currentResourceEvent.value)
-
- _workingUserState = _workingUserState.copyForResourcesSnapshotUpdate(resource, instanceId, newAmount, nowMillis)
- // A. Update user state with new resource instance amount
- ///////////////////////////////////////
-
-
- ///////////////////////////////////////
- // B. Update user state with new credit
- val previousRCEventM = findPreviousRCEventOf(currentResourceEvent, costPolicy, previousRCEventsMap)
- _workingUserState.findResourceInstanceSnapshot(resource, instanceId)
- // B. Update user state with new credit
- ///////////////////////////////////////
-
-
- ///////////////////////////////////////
- // C. Update ??? state with wallet entries
-
- // C. Update ??? state with wallet entries
- ///////////////////////////////////////
+ RCD("Found costPolicy = %s".format(costPolicy))
+
+ // If this is an event for which no action is required, then OK, proceed with the next one
+ // Basically, we do nothing for ON events but we treat everything polymorphically here
+ costPolicy.isBillableEventBasedOnValue(currentResourceEvent.value) match {
+ case true ⇒
+ ///////////////////////////////////////
+ // A. Update user state with new resource instance amount
+ // TODO: Check if we are at beginning of billing period, so as to use
+ // costPolicy.computeResourceInstanceAmountForNewBillingPeriod
+ val DefaultResourceInstanceAmount = costPolicy.getResourceInstanceInitialAmount
+ RCD("DefaultResourceInstanceAmount = %s".format(DefaultResourceInstanceAmount))
+
+ val previousAmount = currentUserState.getResourceInstanceAmount(resource, instanceId, DefaultResourceInstanceAmount)
+ RCD("previousAmount = %s".format(previousAmount))
+ val newAmount = costPolicy.computeNewResourceInstanceAmount(previousAmount, currentResourceEvent.value)
+ RCD("newAmount = %s".format(newAmount))
+
+ _workingUserState = _workingUserState.copyForResourcesSnapshotUpdate(resource, instanceId, newAmount, nowMillis)
+ // A. Update user state with new resource instance amount
+ ///////////////////////////////////////
+
+
+ ///////////////////////////////////////
+ // B. Update user state with new credit
+ val previousRCEventM = findPreviousRCEventOf(currentResourceEvent, costPolicy, previousRCEventsMap)
+ _workingUserState.findResourceInstanceSnapshot(resource, instanceId)
+ // B. Update user state with new credit
+ ///////////////////////////////////////
+
+
+ ///////////////////////////////////////
+ // C. Update ??? state with wallet entries
+
+ // C. Update ??? state with wallet entries
+ ///////////////////////////////////////
+
+ case false ⇒ // costPolicy.isBillableEventBasedOnValue(currentResourceEvent.value)
+ RCD("Ignoring not billabe (%s) %s".format(
+ currentResourceEvent.beautifyValue(defaultResourcesMap),
+ currentResourceEvent.toDebugString(defaultResourcesMap, true)))
+ }