Skip to content

feat: Implement charge() for multi-tenant Server Actors - #1211

Open
janbuchar wants to merge 2 commits into
masterfrom
multi-tenant-charge
Open

janbuchar wants to merge 2 commits into
masterfrom
multi-tenant-charge

Conversation

@janbuchar

Copy link
Copy Markdown
Contributor

@janbuchar janbuchar added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 29, 2026
@janbuchar
janbuchar requested a review from szaganek as a code owner October 29, 2026 16:30
@janbuchar
janbuchar requested review from Pijukatel and vdusek October 29, 2026 16:30
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Oct 29, 2026
Comment on lines +294 to +299
response = await http.put(
f'{api_url}/v2/acts/{actor.id}',
headers={**auth, 'Content-Type': 'application/json'},
content=json.dumps({'actorStandby': {'isEnabled': True, 'tenancy': 'MULTI_TENANT'}}),
)
assert response.status_code == 200, response.text

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be better after apify/apify-client-python#1169

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.44%. Comparing base (4ff9c35) to head (a2d9e6c).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
src/apify/_charging.py 90.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1211      +/-   ##
==========================================
+ Coverage   93.25%   93.44%   +0.19%     
==========================================
  Files          54       54              
  Lines        3766     3800      +34     
==========================================
+ Hits         3512     3551      +39     
+ Misses        254      249       -5     
Flag Coverage Δ
e2e 31.31% <23.07%> (-0.21%) ⬇️
integration 51.07% <30.76%> (-0.33%) ⬇️
unit 90.31% <92.30%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Pijukatel Pijukatel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like an attachment to conceptually same method, that should have separate implementation though.

Actor.charge in normal actor runs is responsible for

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(...)

Comment thread pyproject.toml
]
dependencies = [
"apify-client[brotli]>=3.3.0,<4.0.0",
"apify-client[brotli]==3.4.1b2",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apify client 3.4.0 was released, so you can update it

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for the request_id param in Actor.charge()

4 participants