ChargingManagerImplementation
Hierarchy
- ChargingManager
- ChargingManagerImplementation
Index
Methods
Properties
Methods
__aenter__
Initialize the charging manager - this is called by the
Actorclass and shouldn't be invoked manually.Returns None
__aexit__
Parameters
exc_type: type[BaseException] | None
exc_value: BaseException | None
exc_traceback: TracebackType | None
Returns None
__init__
Parameters
configuration: Configuration
client: ApifyClientAsync
Returns None
calculate_max_event_charge_count_within_limit
Calculate how many instances of an event can be charged before we reach the configured limit.
Parameters
event_name: str
Name of the inspected event.
Returns int | None
calculate_total_charged_amount
Calculate the total amount of money charged for pay-per-event events so far.
Returns Decimal
charge
Charge for a specified number of events - sub-operations of the Actor.
This is relevant only for the pay-per-event pricing model.
Parameters
event_name: str
Name of the event to be charged for.
optionalcount: int = 1
Number of events to charge for.
Returns ChargeResult
compute_chargeable
Compute the maximum number of events of each type that can be charged within the current budget.
Returns dict[str, int | None]
compute_push_data_limit
Compute how many items can be pushed and charged within the current budget.
Accounts for both the explicit event and the synthetic
DEFAULT_DATASET_ITEM_EVENTevent, so that the combined cost per item does not exceed the remaining budget.Parameters
items_count: int
The number of items to be pushed.
event_name: str
The explicit event name to charge for each item.
keyword-onlyis_default_dataset: bool
Whether the data is pushed to the default dataset. If True, the synthetic event cost is included in the combined price.
Returns int
Max number of items that can be pushed within the budget.
get_charged_event_count
Get the number of events with the given name that were charged so far.
Parameters
event_name: str
Name of the inspected event.
Returns int
get_max_total_charge_usd
Get the configured maximum total charge for this Actor run.
Returns Decimal
get_pricing_info
Retrieve detailed information about the effective pricing of the current Actor run.
This can be used for instance when your code needs to support multiple pricing models in transition periods.
Returns ActorPricingInfo
is_event_charge_limit_reached
Return True if the remaining budget is insufficient to charge even a single event of the given type.
Parameters
event_name: str
Returns bool
Properties
charge_lock
Lock to synchronize charge operations. Prevents race conditions between charge and push_data calls.
Implementation of the
ChargingManagerProtocol - this is only meant to be instantiated internally.