Module: Phronomy::VectorStore::AsyncBackend
- Included in:
- Base
- Defined in:
- lib/phronomy/vector_store/async_backend.rb
Overview
Mixin that defines the async interface for VectorStore backends.
Mixing this module into a VectorStore class provides three choices:
Do nothing — inherits default implementations from Base that route through BlockingAdapterPool (the previous behaviour).
Override selectively — override only the async methods where the backend has a native async driver, while the remaining methods fall back to the pool.
Implement all natively — override all async methods to avoid pool allocation entirely.
Instance Method Summary collapse
-
#add_async(id:, embedding:, metadata: {}, cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#add.
-
#clear_async(cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#clear.
-
#remove_async(id:, cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#remove.
-
#search_async(query_embedding:, k: 5, cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#search.
Instance Method Details
#add_async(id:, embedding:, metadata: {}, cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#add.
Submits the add call to BlockingAdapterPool by default. Override to use a native async driver.
43 44 45 46 47 48 49 50 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 43 def add_async(id:, embedding:, metadata: {}, cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.blocking_io.submit( timeout: timeout, cancellation_token: cancellation_token ) do add(id: id, embedding: , metadata: , cancellation_token: cancellation_token) end end |
#clear_async(cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#clear.
Submits the clear call to BlockingAdapterPool by default. Override to use a native async driver.
100 101 102 103 104 105 106 107 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 100 def clear_async(cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.blocking_io.submit( timeout: timeout, cancellation_token: cancellation_token ) do clear end end |
#remove_async(id:, cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#remove.
Submits the remove call to BlockingAdapterPool by default. Override to use a native async driver.
82 83 84 85 86 87 88 89 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 82 def remove_async(id:, cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.blocking_io.submit( timeout: timeout, cancellation_token: cancellation_token ) do remove(id: id) end end |
#search_async(query_embedding:, k: 5, cancellation_token: nil, timeout: nil) ⇒ BlockingAdapterPool::PendingOperation
Async variant of Base#search.
Submits the search call to BlockingAdapterPool by default. Override to use a native async driver.
63 64 65 66 67 68 69 70 |
# File 'lib/phronomy/vector_store/async_backend.rb', line 63 def search_async(query_embedding:, k: 5, cancellation_token: nil, timeout: nil) Phronomy::Runtime.instance.blocking_io.submit( timeout: timeout, cancellation_token: cancellation_token ) do search(query_embedding: , k: k, cancellation_token: cancellation_token) end end |