refactor!: Rename StorageManager to StorageInstanceManager and use it to centralize storage instance caching#3584
Conversation
fc1d565 to
afc367c
Compare
fc3505c to
4f69d63
Compare
barjin
left a comment
There was a problem hiding this comment.
Thank you @janbuchar !
Here are a few ideas while I still have the context from the previous PR.
| client, | ||
| config, | ||
| clientOpener, | ||
| clientCacheKey, |
There was a problem hiding this comment.
With client, clientOpener, and clientCacheKey, the client- prefix is imo too overloaded to read this comfortably.
Maybe it's time to switch to the backend naming? iiuc, client and clientCacheKey refer to the "big" client (backend), and clientOpener refers to the DatasetClient etc., right?
barjin
left a comment
There was a problem hiding this comment.
Thank you @janbuchar , I have a few more ideas / questions, see below ⬇️
| // pass in failed requests back to the `crawler.run()`, otherwise they would be considered as handled and | ||
| // ignored - as a failed requests is still handled. | ||
| if (this.requestQueue?.name === 'default' && purgeRequestQueue) { | ||
| const isDefaultQueue = this.requestQueue?.name === 'default' || this.requestQueue?.name === '__default__'; |
There was a problem hiding this comment.
| const isDefaultQueue = this.requestQueue?.name === 'default' || this.requestQueue?.name === '__default__'; | |
| const isDefaultQueue = this.requestQueue?.name === 'default' || this.requestQueue?.alias === '__default__'; |
Is this right? I haven't got used to this new paradigm yet, but __default__ seems to be referenced to as an alias throughout this PR.
There was a problem hiding this comment.
No, that actually worked only for memory storage and we'll completely rewrite that one soon. I reverted the change here and instead made a workaround in memory storage - 3cda48c
This comment was marked as resolved.
This comment was marked as resolved.
beta.56 (apify/crawlee#3584) renamed `StorageManager` → `StorageInstanceManager` and reshaped the public storage open path. The static `StorageManager.openStorage(cls, id, client)` helper is gone; each storage class now exposes `static open(id, options?)` with a `storageClient` option for routing through a custom backend. - `actor.ts`: `_openStorage` now calls `storageClass.open(id, { storageClient })` instead of `StorageManager.openStorage(...)`. `StorageOpenOptions` replaces `StorageManagerOptions`. - `key_value_store.ts`: import `StorageOpenOptions` for the `open()` override signature. - `actor.test.ts`: the `openDataset` / `openRequestQueue` `forceCloud` tests now spy on the storage class's own `open()` (no more `StorageManager.prototype`), and assert the `storageClient` lives one level deeper in the options object. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
beta.56 (apify/crawlee#3584) renamed `StorageManager` → `StorageInstanceManager` and reshaped the public storage open path. The static `StorageManager.openStorage(cls, id, client)` helper is gone; each storage class now exposes `static open(id, options?)` with a `storageClient` option for routing through a custom backend. - `actor.ts`: `_openStorage` now calls `storageClass.open(id, { storageClient })` instead of `StorageManager.openStorage(...)`. `StorageOpenOptions` replaces `StorageManagerOptions`. - `key_value_store.ts`: import `StorageOpenOptions` for the `open()` override signature. - `actor.test.ts`: the `openDataset` / `openRequestQueue` `forceCloud` tests now spy on the storage class's own `open()` (no more `StorageManager.prototype`), and assert the `storageClient` lives one level deeper in the options object. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
beta.56 (apify/crawlee#3584) renamed `StorageManager` → `StorageInstanceManager` and reshaped the public storage open path. The static `StorageManager.openStorage(cls, id, client)` helper is gone; each storage class now exposes `static open(id, options?)` with a `storageClient` option for routing through a custom backend. - `actor.ts`: `_openStorage` now calls `storageClass.open(id, { storageClient })` instead of `StorageManager.openStorage(...)`. `StorageOpenOptions` replaces `StorageManagerOptions`. - `key_value_store.ts`: import `StorageOpenOptions` for the `open()` override signature. - `actor.test.ts`: the `openDataset` / `openRequestQueue` `forceCloud` tests now spy on the storage class's own `open()` (no more `StorageManager.prototype`), and assert the `storageClient` lives one level deeper in the options object. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
beta.56 (apify/crawlee#3584) renamed `StorageManager` → `StorageInstanceManager` and reshaped the public storage open path. The static `StorageManager.openStorage(cls, id, client)` helper is gone; each storage class now exposes `static open(id, options?)` with a `storageClient` option for routing through a custom backend. - `actor.ts`: `_openStorage` now calls `storageClass.open(id, { storageClient })` instead of `StorageManager.openStorage(...)`. `StorageOpenOptions` replaces `StorageManagerOptions`. - `key_value_store.ts`: import `StorageOpenOptions` for the `open()` override signature. - `actor.test.ts`: the `openDataset` / `openRequestQueue` `forceCloud` tests now spy on the storage class's own `open()` (no more `StorageManager.prototype`), and assert the `storageClient` lives one level deeper in the options object. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.