-
Hello, I'm currently implementing my own connector adapter to use the SDK in a wasm binary with custom bindings: // Adapter is an empty struct. (I tried to use connector_fn but had that function future freezing, never woken up by my runtime somehow)
impl Service<http::Request<SdkBody>> for Adapter {
type Response = http::Response<SdkBody>;
type Error = ConnectorError;
#[allow(clippy::type_complexity)]
type Future = std::pin::Pin<
Box<dyn std::future::Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>,
>;
fn poll_ready(
&mut self,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<SdkBody>) -> Self::Future {
log(format!(
"CloudWatch: adapter: sending request to {}",
req.uri()
));
// The specific bindings call that is a future
let fut = make_http_request(self.try_into_bindings_request(req).unwrap());
Box::pin(async move {
Ok(http::Response::new(SdkBody::from(
fut.await.map_err(downcast_error)?.body,
)))
})
}
} Everything works fine, except that the request Request { method: POST, uri: /, version: HTTP/1.1, headers: {"content-type": "application/x-www-form-urlencoded", "content-length": "94"}, body: SdkBody { inner: Once(Some(b"Action=ListMetrics&Version=2010-08-01&Namespace=AWS%2FRDS&MetricName=MaximumUsedTransactionIDs")), retryable: true } } is what I'm getting as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 11 replies
-
From inspecting the // Building a SdkConfig from the wasm app configuration:
impl From<&Config> for SdkConfig {
fn from(conf: &Config) -> Self {
SdkConfig::builder()
.region(Region::new(conf.region.clone()))
.credentials_provider(SharedCredentialsProvider::new(Credentials::from_keys(
&conf.access_key_id.0,
&conf.secret_access_key.0,
None,
)))
.build()
}
} And then this assertion fails when I call it let shared_config = SdkConfig::from(&config);
shared_config
.endpoint_resolver()
.ok_or_else(|| Error::Invocation {
message: "The shared config does not have an endpoint resolver!!".to_string(),
})?;
let config = aws_sdk_cloudwatch::config::Builder::from(&shared_config)
.retry_config(RetryConfig::disabled())
.build();
// ... Since I'm never mentioning an override of the endpoint resolver, I was expecting to obtain a default one that works. I'm mostly trying to avoid |
Beta Was this translation helpful? Give feedback.
I rewrote the deserialization/serialization/signature from scratch on every endpoint I wanted to use, see for example https://github.com/fiberplane/providers/blob/main/providers/cloudwatch/src/client/cloudwatch.rs and https://github.com/fiberplane/providers/blob/main/providers/cloudwatch/src/client/canonical_request.rs
Note that since then, I thought the AWS SDK got rid of the version of
ring
that was triggering the compilation issues for thewasm32-unknown-unknown
targets. Maybe just compiling will workEDIT: Or rather. as mentionned above, that a trait was created (
AsyncTimer
but it might have changed name) that allows to inject your time function into the SDK