Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1211 +/- ##
==========================================
+ Coverage 93.79% 93.82% +0.02%
==========================================
Files 54 54
Lines 3803 3821 +18
==========================================
+ Hits 3567 3585 +18
Misses 236 236
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pijukatel
left a comment
There was a problem hiding this comment.
It feels like an attachment to conceptually same method, that should have separate implementation though.
Actor.charge in normal actor runs is responsible for
- book keeping of the events + newly persistence
- limit enforcement
- API call
in multi tenant sever actor there is no enforcement and the bookkeeping is pointless so it is there only for the API call. So this similar but different method goes through the same code paths, but has so much dead code along the way.
In order to make this distinction more clear I would be in favor of some separation. For example something in this direction:
Having overloads for normal charge
async def charge(
self,
event_name: str,
*,
count: int = 1,
idempotency_key: str | None = None,
Server charge where the request_id is actually mandatory
async def charge(
self,
event_name: str,
*,
count: int = 1,
idempotency_key: str | None = None,
request_id: str,
And the method should clearly delegate to distinct internal functions
async def charge(...)
# param checks and warnings
if ...
return _server_charge(...)
return _charge(...)
vdusek
left a comment
There was a problem hiding this comment.
One more comment regarding docs. Otherwise LGTM.
|
|
||
| ### Charge in multi-tenant Server Actors | ||
|
|
||
| A multi-tenant [Server Actor](https://docs.apify.com/platform/actors/development/programming-interface/standby) run serves requests from many users. To charge the user who made a request rather than the account that started the run, pass the request's `X-Actor-Request-ID` header value as `request_id`. Multi-tenant runs reject charges without it. |
There was a problem hiding this comment.
Could we mention somewhere here that "server Actor" is the new name for "standby Actor"? Something like what we have in https://docs.apify.com/api/client/python/docs/concepts/server-actors.
request_idparam inActor.charge()#1193