-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apify.call should "survive" migration #4
Comments
I can't much imagine how this would work. When you restart the actor, there is no way to make the execution jump right to |
Sure, that is why we discuss it here. Yes, the actor would repeat everything else. It doesn't have be to necessarily default behavior (if we find it confusing) of Apify.call. But in 99.9% cases, you would like to continue waiting for the current call (without changing the input or settings). For example,the queue and list are also persisted so if you have a crawler and then Apify.call, after restart it will most likely just jump directly into the waiting for Apify.call to return. |
Technically, we could add an |
(yet another use for hidden fields in KVS) |
Good idea, we can even generate the |
@jancurn But then we could |
You can construct the |
and we need this more than ever now 😬 was going o post about call idempotencyKey, but here it is... so calling and thinking further, we can have an |
I agree to start with Then we can think further if/how to integrate this into Apify.call. |
Guys, you know there is already an internal function called We can start by documenting it making it public. |
exporting that right away would be nice. right now we have 2 actors take literally takes a day to complete, and they wait on each others completion. |
Wouldn't that case be better served by a webhook? |
we could, would need some refactoring and moving code outside |
I think there is no harm making |
I think this could be tackled similarly to the statistic class, but instead of an autoincrement id, quickly hash the input to make it unique between calls, this way allows more than 1 call/callTask: const run = await Apify.call('apify/send-mail', {
to: 'email@example',
});
// if the run is done, it returns immediately, otherwise, waits. the hash can be a simple CRC32 of the Calls are then saved to {
"hexHashOfInput": {
"id": "HG7ML7M8z78YcAPEB", // the runId
"actorTaskId": "KJHSKHausidyaJKHs", // ditto
// save the bits we care about to be able to retrieve it later
}
} the lookup for the input should be straightforward. querying the state of the run and issuing a Good part of using hashes: doesn't leak information about the call/callTask on KV, hash is space efficient and stable |
@pocesar I think this is an ideal candidate for the apify-utils repo :) BTW: I think your solution might be quite bloated on the storage. You would need to clean-up the records in the call as well. On the other hand, a single JSON might suffer when you call thousands of times and grow too large. Maybe some compromise :) Let's discuss it on apify-utils :) |
@metalwarrior665 the thing is I plan to do a couple of utility PAs that other people can call from their actors (like a microservice). having this working at SDK level instead of having the person to require an external dependency on their code would be ideal |
Guys, great points. Just letting you know that |
example: had to write all the boilerplate in the README https://apify.com/pocesar/sitemap-to-request-queue otherwise it will do the same things again on migration and waste a couple of minutes to add 0 requests to the queue |
This will be resolved by the new apify-extra package, will close this once it is released |
Right now, Apify.call doesn't save any state upon migration so if the user is not careful, he will loose reference to the called runs and they will be called again.
The current solution is to save the run ID into KV store and do some waiting loop manually.
Ideally Apify.call would do this automatically. Not sure if this can be done without any extra parameters automatically or we the user would have to specify it with a string param.
The text was updated successfully, but these errors were encountered: