`actor charge` support
As discussed with @mhamas, I'd like to introduce Actor.charge() equivalent to the Apify CLI actor namespace. It should work locally (without the run id an the run API key) as well as in the production deployment on Apify. Locally it should log to stderr every charge event on apify run and output the aggregated breakdown of event charges at the end of the run.
Syntax proposal:
$ apify actor charge <EVENT_NAME> \
[--eventCount <EVENT_COUNT>] \
[--idempotency-key <IDEMPOTENCY_KEY>]
...
Pay Per Event fired: <amount>, <count> times
...
Charges Breakdown:
-----------------------------------------------
| <event name> | <count> | <each> | <total> |
...
-----------------------------------------------
| Grand total: <sum> |
-----------------------------------------------
...
$ echo $?
0
@mhamas 's Draft PR here: https://github.com/apify/apify-cli/pull/748
Locally it should log to stderr every charge event on apify run and output the aggregated breakdown of event charges at the end of the run.
We discussed this briefly on tooling sync and none of us really had an idea (at least one that wasn't frightening) on how to go about that. The CLI is stateless, and the charge command is not something long running, it literally represents the single console log. Also apify run just runs some script (nodejs/python or anything else really), we don't have control over what is that script doing.
I guess we can close this, given #748 was merged. Feel free to reopen if there is something missing.