Module: Phronomy::VectorStore::AsyncBackend Private
- Included in:
- Base
- Defined in:
- lib/phronomy/vector_store/async_backend.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Framework-owned async convenience methods for VectorStore backends.
The backend extension contract is the synchronous interface defined by Base: add/search/remove/clear/size. These async convenience methods are inherited by backends and route that synchronous work through Phronomy's bounded OffloadPool. This keeps OS-thread creation, queue backpressure, submit timeout/cancellation, and completion semantics owned by the framework rather than by each backend.
A future genuine native-async backend may adapt its completion into a Task without an OffloadPool worker, but native async override is not part of the current backend SPI.
Instance Method Summary collapse
-
#add_async(id:, embedding:, metadata: {}, cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#add.
-
#clear_async(cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#clear.
-
#remove_async(id:, cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#remove.
-
#search_async(query_embedding:, k: 5, cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#search.
Instance Method Details
#add_async(id:, embedding:, metadata: {}, cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#add.
29 30 31 32 33 34 35 36 37 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 29 def add_async(id:, embedding:, metadata: {}, cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.offload.submit( timeout: timeout, cancellation_token: cancellation_token, on_full: :raise ) do add(id: id, embedding: , metadata: , cancellation_token: cancellation_token) end end |
#clear_async(cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#clear.
80 81 82 83 84 85 86 87 88 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 80 def clear_async(cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.offload.submit( timeout: timeout, cancellation_token: cancellation_token, on_full: :raise ) do clear end end |
#remove_async(id:, cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#remove.
64 65 66 67 68 69 70 71 72 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 64 def remove_async(id:, cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.offload.submit( timeout: timeout, cancellation_token: cancellation_token, on_full: :raise ) do remove(id: id) end end |
#search_async(query_embedding:, k: 5, cancellation_token: nil, timeout: nil) ⇒ Phronomy::Task
Async variant of Base#search.
47 48 49 50 51 52 53 54 55 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 47 def search_async(query_embedding:, k: 5, cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.offload.submit( timeout: timeout, cancellation_token: cancellation_token, on_full: :raise ) do search(query_embedding: , k: k, cancellation_token: cancellation_token) end end |