From 6d89058668e550d8c49cbe186c76ea4281684576 Mon Sep 17 00:00:00 2001 From: byoung Date: Mon, 3 Apr 2023 15:17:20 -0600 Subject: [PATCH 1/5] Added witx definitions for objstr async handle type, and functions to utilize it --- lib/compute-at-edge-abi/compute-at-edge.witx | 14 ++++++++++++++ lib/compute-at-edge-abi/typenames.witx | 2 ++ 2 files changed, 16 insertions(+) diff --git a/lib/compute-at-edge-abi/compute-at-edge.witx b/lib/compute-at-edge-abi/compute-at-edge.witx index 764bb45c..af34d072 100644 --- a/lib/compute-at-edge-abi/compute-at-edge.witx +++ b/lib/compute-at-edge-abi/compute-at-edge.witx @@ -500,6 +500,20 @@ (result $err (expected (error $fastly_status))) ) + (@interface func (export "lookup_async") + (param $store $object_store_handle) + (param $key string) + (param $pending_body_handle_out (@witx pointer $pending_object_store_handle)) + (result $err (expected (error $fastly_status))) + ) + + (@interface func (export "pending_lookup_wait") + (param $store $object_store_handle) + (param $pending_body_handle (@witx pointer $pending_object_store_handle)) + (param $body_handle_out (@witx pointer $body_handle)) + (result $err (expected (error $fastly_status))) + ) + (@interface func (export "insert") (param $store $object_store_handle) (param $key string) diff --git a/lib/compute-at-edge-abi/typenames.witx b/lib/compute-at-edge-abi/typenames.witx index 36291311..d73604fa 100644 --- a/lib/compute-at-edge-abi/typenames.witx +++ b/lib/compute-at-edge-abi/typenames.witx @@ -94,6 +94,8 @@ (typename $dictionary_handle (handle)) ;;; A handle to an Object Store. (typename $object_store_handle (handle)) +;;; A handle to a pending Object Store request. +(typename $pending_object_store_handle (handle)) ;;; A handle to a Secret Store. (typename $secret_store_handle (handle)) ;;; A handle to an individual secret. From cc3cf86e835635c4cc34da094ff10a01f04c5046 Mon Sep 17 00:00:00 2001 From: byoung Date: Thu, 27 Apr 2023 16:35:55 -0600 Subject: [PATCH 2/5] Build out object store's pending_lookup with PeekableTask --- lib/compute-at-edge-abi/compute-at-edge.witx | 3 +- lib/src/error.rs | 4 ++ lib/src/session.rs | 60 +++++++++++++++++++- lib/src/session/async_item.rs | 23 ++++++++ lib/src/wiggle_abi.rs | 2 +- lib/src/wiggle_abi/obj_store_impl.rs | 39 +++++++++++++ 6 files changed, 127 insertions(+), 4 deletions(-) diff --git a/lib/compute-at-edge-abi/compute-at-edge.witx b/lib/compute-at-edge-abi/compute-at-edge.witx index af34d072..183910e7 100644 --- a/lib/compute-at-edge-abi/compute-at-edge.witx +++ b/lib/compute-at-edge-abi/compute-at-edge.witx @@ -508,8 +508,7 @@ ) (@interface func (export "pending_lookup_wait") - (param $store $object_store_handle) - (param $pending_body_handle (@witx pointer $pending_object_store_handle)) + (param $pending_body_handle $pending_object_store_handle) (param $body_handle_out (@witx pointer $body_handle)) (result $err (expected (error $fastly_status))) ) diff --git a/lib/src/error.rs b/lib/src/error.rs index 4a164f2c..531d8c0e 100644 --- a/lib/src/error.rs +++ b/lib/src/error.rs @@ -238,6 +238,10 @@ pub enum HandleError { #[error("Invalid pending request handle: {0}")] InvalidPendingRequestHandle(crate::wiggle_abi::types::PendingRequestHandle), + /// A lookup handle was not valid. + #[error("Invalid pending lookup handle: {0}")] + InvalidPendingLookupHandle(crate::wiggle_abi::types::PendingObjectStoreHandle), + /// A dictionary handle was not valid. #[error("Invalid dictionary handle: {0}")] InvalidDictionaryHandle(crate::wiggle_abi::types::DictionaryHandle), diff --git a/lib/src/session.rs b/lib/src/session.rs index 0dd7e92e..254be038 100644 --- a/lib/src/session.rs +++ b/lib/src/session.rs @@ -18,7 +18,7 @@ use { upstream::{SelectTarget, TlsConfig}, wiggle_abi::types::{ self, BodyHandle, ContentEncodings, DictionaryHandle, EndpointHandle, - ObjectStoreHandle, PendingRequestHandle, RequestHandle, ResponseHandle, SecretHandle, + ObjectStoreHandle, PendingObjectStoreHandle, PendingRequestHandle, RequestHandle, ResponseHandle, SecretHandle, SecretStoreHandle, }, }, @@ -639,6 +639,52 @@ impl Session { self.object_store.lookup(obj_store_key, obj_key) } + /// Insert a [`PendingLookup`] into the session. + /// + /// This method returns a new [`PendingObjectStoreHandle`], which can then be used to access + /// and mutate the pending lookup. + pub fn insert_pending_lookup( + &mut self, + pending: PeekableTask, ObjectStoreError>>, + ) -> PendingObjectStoreHandle { + self.async_items + .push(Some(AsyncItem::PendingLookup(pending))) + .into() + } + + /// Take ownership of a [`PendingLookup`], given its [`PendingObjectStoreHandle`]. + /// + /// Returns a [`HandleError`] if the handle is not associated with a pending lookup in the + /// session. + pub fn take_pending_lookup( + &mut self, + handle: PendingObjectStoreHandle, + ) -> Result, ObjectStoreError>>, HandleError> { + // check that this is a pending request before removing it + let _ = self.pending_lookup(handle)?; + + self.async_items + .get_mut(handle.into()) + .and_then(Option::take) + .and_then(AsyncItem::into_pending_lookup) + .ok_or(HandleError::InvalidPendingLookupHandle(handle)) + } + + /// Get a reference to a [`PendingLookup`], given its [`PendingObjectStoreHandle`]. + /// + /// Returns a [`HandleError`] if the handle is not associated with a lookup in the + /// session. + pub fn pending_lookup( + &self, + handle: PendingObjectStoreHandle, + ) -> Result<&PeekableTask, ObjectStoreError>>, HandleError> { + self.async_items + .get(handle.into()) + .and_then(Option::as_ref) + .and_then(AsyncItem::as_pending_lookup) + .ok_or(HandleError::InvalidPendingLookupHandle(handle)) + } + // ----- Secret Store API ----- pub fn secret_store_handle(&mut self, name: &str) -> Option { @@ -912,3 +958,15 @@ impl From for types::AsyncItemHandle { types::AsyncItemHandle::from(h.as_u32()) } } + +impl From for AsyncItemHandle { + fn from(h: PendingObjectStoreHandle) -> AsyncItemHandle { + AsyncItemHandle::from_u32(h.into()) + } +} + +impl From for PendingObjectStoreHandle { + fn from(h: AsyncItemHandle) -> PendingObjectStoreHandle { + PendingObjectStoreHandle::from(h.as_u32()) + } +} diff --git a/lib/src/session/async_item.rs b/lib/src/session/async_item.rs index 747e98f0..d8bde5fb 100644 --- a/lib/src/session/async_item.rs +++ b/lib/src/session/async_item.rs @@ -1,3 +1,4 @@ +use crate::object_store::ObjectStoreError; use crate::{body::Body, error::Error, streaming_body::StreamingBody}; use anyhow::anyhow; use futures::Future; @@ -14,6 +15,7 @@ pub enum AsyncItem { Body(Body), StreamingBody(StreamingBody), PendingReq(PeekableTask>), + PendingLookup(PeekableTask, ObjectStoreError>>), } impl AsyncItem { @@ -70,6 +72,20 @@ impl AsyncItem { } } + pub fn as_pending_lookup(&self) -> Option<&PeekableTask, ObjectStoreError>>> { + match self { + Self::PendingLookup(req) => Some(req), + _ => None, + } + } + + pub fn into_pending_lookup(self) -> Option, ObjectStoreError>>> { + match self { + Self::PendingLookup(req) => Some(req), + _ => None, + } + } + pub fn as_pending_req(&self) -> Option<&PeekableTask>> { match self { Self::PendingReq(req) => Some(req), @@ -96,6 +112,7 @@ impl AsyncItem { Self::StreamingBody(body) => body.await_ready().await, Self::Body(body) => body.await_ready().await, Self::PendingReq(req) => req.await_ready().await, + Self::PendingLookup(obj) => obj.await_ready().await, } } @@ -110,6 +127,12 @@ impl From>> for AsyncItem { } } +impl From, ObjectStoreError>>> for AsyncItem { + fn from(req: PeekableTask, ObjectStoreError>>) -> Self { + Self::PendingLookup(req) + } +} + #[derive(Debug)] pub enum PeekableTask { Waiting(oneshot::Receiver>), diff --git a/lib/src/wiggle_abi.rs b/lib/src/wiggle_abi.rs index c8923220..a6d7fe16 100644 --- a/lib/src/wiggle_abi.rs +++ b/lib/src/wiggle_abi.rs @@ -70,7 +70,7 @@ wiggle::from_witx!({ errors: { fastly_status => Error }, async: { fastly_async_io::{select}, - fastly_object_store::{insert}, + fastly_object_store::{insert, lookup_async, pending_lookup_wait}, fastly_http_body::{append, read, write}, fastly_http_req::{pending_req_select, pending_req_poll, pending_req_wait, send, send_async, send_async_streaming}, } diff --git a/lib/src/wiggle_abi/obj_store_impl.rs b/lib/src/wiggle_abi/obj_store_impl.rs index 40c2958c..320abb6c 100644 --- a/lib/src/wiggle_abi/obj_store_impl.rs +++ b/lib/src/wiggle_abi/obj_store_impl.rs @@ -1,5 +1,8 @@ //! fastly_obj_store` hostcall implementations. +use crate::session::PeekableTask; +use super::types::PendingObjectStoreHandle; + use { crate::{ body::Body, @@ -49,6 +52,42 @@ impl FastlyObjectStore for Session { } } + async fn lookup_async<'a>( + &mut self, + store: ObjectStoreHandle, + key: &GuestPtr, + opt_pending_body_handle_out: &GuestPtr, + ) -> Result<(), Error> { + let store = self.get_obj_store_key(store).unwrap(); + let key = ObjectKey::new(&*key.as_str()?.ok_or(Error::SharedMemory)?)?; + // just create a future that's already ready + let fut = futures::future::ok(self.obj_lookup(store, &key)); + let task = PeekableTask::spawn(fut).await; + opt_pending_body_handle_out.write(self.insert_pending_lookup(task))?; + Ok(()) + } + + async fn pending_lookup_wait<'a>( + &mut self, + pending_body_handle: PendingObjectStoreHandle, + opt_body_handle_out: &GuestPtr, + ) -> Result<(), Error> { + let pending_obj = self + .take_pending_lookup(pending_body_handle)? + .recv() + .await?; + // proceed with the normal match from lookup() + match pending_obj { + Ok(obj) => { + let new_handle = self.insert_body(Body::from(obj)); + opt_body_handle_out.write(new_handle)?; + Ok(()) + } + Err(ObjectStoreError::MissingObject) => Ok(()), + Err(err) => Err(err.into()), + } + } + async fn insert<'a>( &mut self, store: ObjectStoreHandle, From 4d07609c373bec4844a5063ac4e87ea2cb47ef8b Mon Sep 17 00:00:00 2001 From: byoung Date: Thu, 27 Apr 2023 16:42:23 -0600 Subject: [PATCH 3/5] formatting --- lib/src/session.rs | 4 ++-- lib/src/wiggle_abi/obj_store_impl.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/session.rs b/lib/src/session.rs index 254be038..ad42663d 100644 --- a/lib/src/session.rs +++ b/lib/src/session.rs @@ -18,8 +18,8 @@ use { upstream::{SelectTarget, TlsConfig}, wiggle_abi::types::{ self, BodyHandle, ContentEncodings, DictionaryHandle, EndpointHandle, - ObjectStoreHandle, PendingObjectStoreHandle, PendingRequestHandle, RequestHandle, ResponseHandle, SecretHandle, - SecretStoreHandle, + ObjectStoreHandle, PendingObjectStoreHandle, PendingRequestHandle, RequestHandle, + ResponseHandle, SecretHandle, SecretStoreHandle, }, }, cranelift_entity::{entity_impl, PrimaryMap}, diff --git a/lib/src/wiggle_abi/obj_store_impl.rs b/lib/src/wiggle_abi/obj_store_impl.rs index 320abb6c..1235c308 100644 --- a/lib/src/wiggle_abi/obj_store_impl.rs +++ b/lib/src/wiggle_abi/obj_store_impl.rs @@ -1,7 +1,7 @@ //! fastly_obj_store` hostcall implementations. -use crate::session::PeekableTask; use super::types::PendingObjectStoreHandle; +use crate::session::PeekableTask; use { crate::{ From 9379d6c20aabc76dba1df0bca79c8d478c591eb0 Mon Sep 17 00:00:00 2001 From: byoung Date: Mon, 1 May 2023 09:33:58 -0600 Subject: [PATCH 4/5] Renaming ObjectStore -> Kv, minor cleanup --- lib/compute-at-edge-abi/compute-at-edge.witx | 4 +- lib/compute-at-edge-abi/typenames.witx | 4 +- lib/src/error.rs | 4 +- lib/src/session.rs | 39 +++++++++----------- lib/src/session/async_item.rs | 20 +++++----- lib/src/wiggle_abi/obj_store_impl.rs | 6 +-- 6 files changed, 38 insertions(+), 39 deletions(-) diff --git a/lib/compute-at-edge-abi/compute-at-edge.witx b/lib/compute-at-edge-abi/compute-at-edge.witx index 183910e7..00d5c29d 100644 --- a/lib/compute-at-edge-abi/compute-at-edge.witx +++ b/lib/compute-at-edge-abi/compute-at-edge.witx @@ -503,12 +503,12 @@ (@interface func (export "lookup_async") (param $store $object_store_handle) (param $key string) - (param $pending_body_handle_out (@witx pointer $pending_object_store_handle)) + (param $pending_body_handle_out (@witx pointer $pending_kv_lookup_handle)) (result $err (expected (error $fastly_status))) ) (@interface func (export "pending_lookup_wait") - (param $pending_body_handle $pending_object_store_handle) + (param $pending_body_handle $pending_kv_lookup_handle) (param $body_handle_out (@witx pointer $body_handle)) (result $err (expected (error $fastly_status))) ) diff --git a/lib/compute-at-edge-abi/typenames.witx b/lib/compute-at-edge-abi/typenames.witx index d73604fa..84a0c1dd 100644 --- a/lib/compute-at-edge-abi/typenames.witx +++ b/lib/compute-at-edge-abi/typenames.witx @@ -94,8 +94,8 @@ (typename $dictionary_handle (handle)) ;;; A handle to an Object Store. (typename $object_store_handle (handle)) -;;; A handle to a pending Object Store request. -(typename $pending_object_store_handle (handle)) +;;; A handle to a pending KV request. +(typename $pending_kv_lookup_handle (handle)) ;;; A handle to a Secret Store. (typename $secret_store_handle (handle)) ;;; A handle to an individual secret. diff --git a/lib/src/error.rs b/lib/src/error.rs index 531d8c0e..95d9a73a 100644 --- a/lib/src/error.rs +++ b/lib/src/error.rs @@ -239,8 +239,8 @@ pub enum HandleError { InvalidPendingRequestHandle(crate::wiggle_abi::types::PendingRequestHandle), /// A lookup handle was not valid. - #[error("Invalid pending lookup handle: {0}")] - InvalidPendingLookupHandle(crate::wiggle_abi::types::PendingObjectStoreHandle), + #[error("Invalid pending KV lookup handle: {0}")] + InvalidPendingKvLookupHandle(crate::wiggle_abi::types::PendingKvLookupHandle), /// A dictionary handle was not valid. #[error("Invalid dictionary handle: {0}")] diff --git a/lib/src/session.rs b/lib/src/session.rs index ad42663d..a14096c7 100644 --- a/lib/src/session.rs +++ b/lib/src/session.rs @@ -3,7 +3,7 @@ mod async_item; mod downstream; -pub use async_item::{AsyncItem, PeekableTask}; +pub use async_item::{AsyncItem, PeekableTask, PendingKvTask}; use { self::downstream::DownstreamResponse, @@ -18,7 +18,7 @@ use { upstream::{SelectTarget, TlsConfig}, wiggle_abi::types::{ self, BodyHandle, ContentEncodings, DictionaryHandle, EndpointHandle, - ObjectStoreHandle, PendingObjectStoreHandle, PendingRequestHandle, RequestHandle, + ObjectStoreHandle, PendingKvLookupHandle, PendingRequestHandle, RequestHandle, ResponseHandle, SecretHandle, SecretStoreHandle, }, }, @@ -641,25 +641,22 @@ impl Session { /// Insert a [`PendingLookup`] into the session. /// - /// This method returns a new [`PendingObjectStoreHandle`], which can then be used to access + /// This method returns a new [`PendingKvLookupHandle`], which can then be used to access /// and mutate the pending lookup. - pub fn insert_pending_lookup( - &mut self, - pending: PeekableTask, ObjectStoreError>>, - ) -> PendingObjectStoreHandle { + pub fn insert_pending_lookup(&mut self, pending: PendingKvTask) -> PendingKvLookupHandle { self.async_items - .push(Some(AsyncItem::PendingLookup(pending))) + .push(Some(AsyncItem::PendingKvLookup(pending))) .into() } - /// Take ownership of a [`PendingLookup`], given its [`PendingObjectStoreHandle`]. + /// Take ownership of a [`PendingLookup`], given its [`PendingKvLookupHandle`]. /// /// Returns a [`HandleError`] if the handle is not associated with a pending lookup in the /// session. pub fn take_pending_lookup( &mut self, - handle: PendingObjectStoreHandle, - ) -> Result, ObjectStoreError>>, HandleError> { + handle: PendingKvLookupHandle, + ) -> Result { // check that this is a pending request before removing it let _ = self.pending_lookup(handle)?; @@ -667,22 +664,22 @@ impl Session { .get_mut(handle.into()) .and_then(Option::take) .and_then(AsyncItem::into_pending_lookup) - .ok_or(HandleError::InvalidPendingLookupHandle(handle)) + .ok_or(HandleError::InvalidPendingKvLookupHandle(handle)) } - /// Get a reference to a [`PendingLookup`], given its [`PendingObjectStoreHandle`]. + /// Get a reference to a [`PendingLookup`], given its [`PendingKvLookupHandle`]. /// /// Returns a [`HandleError`] if the handle is not associated with a lookup in the /// session. pub fn pending_lookup( &self, - handle: PendingObjectStoreHandle, - ) -> Result<&PeekableTask, ObjectStoreError>>, HandleError> { + handle: PendingKvLookupHandle, + ) -> Result<&PendingKvTask, HandleError> { self.async_items .get(handle.into()) .and_then(Option::as_ref) .and_then(AsyncItem::as_pending_lookup) - .ok_or(HandleError::InvalidPendingLookupHandle(handle)) + .ok_or(HandleError::InvalidPendingKvLookupHandle(handle)) } // ----- Secret Store API ----- @@ -959,14 +956,14 @@ impl From for types::AsyncItemHandle { } } -impl From for AsyncItemHandle { - fn from(h: PendingObjectStoreHandle) -> AsyncItemHandle { +impl From for AsyncItemHandle { + fn from(h: PendingKvLookupHandle) -> AsyncItemHandle { AsyncItemHandle::from_u32(h.into()) } } -impl From for PendingObjectStoreHandle { - fn from(h: AsyncItemHandle) -> PendingObjectStoreHandle { - PendingObjectStoreHandle::from(h.as_u32()) +impl From for PendingKvLookupHandle { + fn from(h: AsyncItemHandle) -> PendingKvLookupHandle { + PendingKvLookupHandle::from(h.as_u32()) } } diff --git a/lib/src/session/async_item.rs b/lib/src/session/async_item.rs index d8bde5fb..16d0cc75 100644 --- a/lib/src/session/async_item.rs +++ b/lib/src/session/async_item.rs @@ -6,6 +6,8 @@ use futures::FutureExt; use http::Response; use tokio::sync::oneshot; +pub type PendingKvTask = PeekableTask, ObjectStoreError>>; + /// Represents either a full body, or the write end of a streaming body. /// /// This enum is needed because we reuse the handle for a body when it is transformed into a streaming @@ -15,7 +17,7 @@ pub enum AsyncItem { Body(Body), StreamingBody(StreamingBody), PendingReq(PeekableTask>), - PendingLookup(PeekableTask, ObjectStoreError>>), + PendingKvLookup(PendingKvTask), } impl AsyncItem { @@ -72,16 +74,16 @@ impl AsyncItem { } } - pub fn as_pending_lookup(&self) -> Option<&PeekableTask, ObjectStoreError>>> { + pub fn as_pending_lookup(&self) -> Option<&PendingKvTask> { match self { - Self::PendingLookup(req) => Some(req), + Self::PendingKvLookup(req) => Some(req), _ => None, } } - pub fn into_pending_lookup(self) -> Option, ObjectStoreError>>> { + pub fn into_pending_lookup(self) -> Option { match self { - Self::PendingLookup(req) => Some(req), + Self::PendingKvLookup(req) => Some(req), _ => None, } } @@ -112,7 +114,7 @@ impl AsyncItem { Self::StreamingBody(body) => body.await_ready().await, Self::Body(body) => body.await_ready().await, Self::PendingReq(req) => req.await_ready().await, - Self::PendingLookup(obj) => obj.await_ready().await, + Self::PendingKvLookup(obj) => obj.await_ready().await, } } @@ -127,9 +129,9 @@ impl From>> for AsyncItem { } } -impl From, ObjectStoreError>>> for AsyncItem { - fn from(req: PeekableTask, ObjectStoreError>>) -> Self { - Self::PendingLookup(req) +impl From for AsyncItem { + fn from(task: PendingKvTask) -> Self { + Self::PendingKvLookup(task) } } diff --git a/lib/src/wiggle_abi/obj_store_impl.rs b/lib/src/wiggle_abi/obj_store_impl.rs index 1235c308..20cbf901 100644 --- a/lib/src/wiggle_abi/obj_store_impl.rs +++ b/lib/src/wiggle_abi/obj_store_impl.rs @@ -1,6 +1,6 @@ //! fastly_obj_store` hostcall implementations. -use super::types::PendingObjectStoreHandle; +use super::types::PendingKvLookupHandle; use crate::session::PeekableTask; use { @@ -56,7 +56,7 @@ impl FastlyObjectStore for Session { &mut self, store: ObjectStoreHandle, key: &GuestPtr, - opt_pending_body_handle_out: &GuestPtr, + opt_pending_body_handle_out: &GuestPtr, ) -> Result<(), Error> { let store = self.get_obj_store_key(store).unwrap(); let key = ObjectKey::new(&*key.as_str()?.ok_or(Error::SharedMemory)?)?; @@ -69,7 +69,7 @@ impl FastlyObjectStore for Session { async fn pending_lookup_wait<'a>( &mut self, - pending_body_handle: PendingObjectStoreHandle, + pending_body_handle: PendingKvLookupHandle, opt_body_handle_out: &GuestPtr, ) -> Result<(), Error> { let pending_obj = self From 1c69b6d7b029ed4be0ac89999aefa77a877a811e Mon Sep 17 00:00:00 2001 From: byoung Date: Wed, 3 May 2023 09:03:44 -0600 Subject: [PATCH 5/5] more pending_lookup -> pending_kv_lookup renames --- lib/src/session.rs | 12 ++++++------ lib/src/session/async_item.rs | 4 ++-- lib/src/wiggle_abi/obj_store_impl.rs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/src/session.rs b/lib/src/session.rs index a14096c7..36c3f792 100644 --- a/lib/src/session.rs +++ b/lib/src/session.rs @@ -643,7 +643,7 @@ impl Session { /// /// This method returns a new [`PendingKvLookupHandle`], which can then be used to access /// and mutate the pending lookup. - pub fn insert_pending_lookup(&mut self, pending: PendingKvTask) -> PendingKvLookupHandle { + pub fn insert_pending_kv_lookup(&mut self, pending: PendingKvTask) -> PendingKvLookupHandle { self.async_items .push(Some(AsyncItem::PendingKvLookup(pending))) .into() @@ -653,17 +653,17 @@ impl Session { /// /// Returns a [`HandleError`] if the handle is not associated with a pending lookup in the /// session. - pub fn take_pending_lookup( + pub fn take_pending_kv_lookup( &mut self, handle: PendingKvLookupHandle, ) -> Result { // check that this is a pending request before removing it - let _ = self.pending_lookup(handle)?; + let _ = self.pending_kv_lookup(handle)?; self.async_items .get_mut(handle.into()) .and_then(Option::take) - .and_then(AsyncItem::into_pending_lookup) + .and_then(AsyncItem::into_pending_kv_lookup) .ok_or(HandleError::InvalidPendingKvLookupHandle(handle)) } @@ -671,14 +671,14 @@ impl Session { /// /// Returns a [`HandleError`] if the handle is not associated with a lookup in the /// session. - pub fn pending_lookup( + pub fn pending_kv_lookup( &self, handle: PendingKvLookupHandle, ) -> Result<&PendingKvTask, HandleError> { self.async_items .get(handle.into()) .and_then(Option::as_ref) - .and_then(AsyncItem::as_pending_lookup) + .and_then(AsyncItem::as_pending_kv_lookup) .ok_or(HandleError::InvalidPendingKvLookupHandle(handle)) } diff --git a/lib/src/session/async_item.rs b/lib/src/session/async_item.rs index 16d0cc75..46a443cd 100644 --- a/lib/src/session/async_item.rs +++ b/lib/src/session/async_item.rs @@ -74,14 +74,14 @@ impl AsyncItem { } } - pub fn as_pending_lookup(&self) -> Option<&PendingKvTask> { + pub fn as_pending_kv_lookup(&self) -> Option<&PendingKvTask> { match self { Self::PendingKvLookup(req) => Some(req), _ => None, } } - pub fn into_pending_lookup(self) -> Option { + pub fn into_pending_kv_lookup(self) -> Option { match self { Self::PendingKvLookup(req) => Some(req), _ => None, diff --git a/lib/src/wiggle_abi/obj_store_impl.rs b/lib/src/wiggle_abi/obj_store_impl.rs index 20cbf901..1d0cc908 100644 --- a/lib/src/wiggle_abi/obj_store_impl.rs +++ b/lib/src/wiggle_abi/obj_store_impl.rs @@ -63,7 +63,7 @@ impl FastlyObjectStore for Session { // just create a future that's already ready let fut = futures::future::ok(self.obj_lookup(store, &key)); let task = PeekableTask::spawn(fut).await; - opt_pending_body_handle_out.write(self.insert_pending_lookup(task))?; + opt_pending_body_handle_out.write(self.insert_pending_kv_lookup(task))?; Ok(()) } @@ -73,7 +73,7 @@ impl FastlyObjectStore for Session { opt_body_handle_out: &GuestPtr, ) -> Result<(), Error> { let pending_obj = self - .take_pending_lookup(pending_body_handle)? + .take_pending_kv_lookup(pending_body_handle)? .recv() .await?; // proceed with the normal match from lookup()