Skip to content

Allow invoke_with_response_stream client calls #898

@zak-cloudnc

Description

@zak-cloudnc

I think this is not implemented yet, but I want to be able to invoke a lambda run with cargo lambda watch with the invoke_with_response_stream style of control plane call to the lambda.

test example (fails)

    #[tokio::test]
    async fn test_local_with_control_plane() {
        let config = aws_config::load_defaults(BehaviorVersion::latest()).await;

        let creds = Credentials::from_keys("dummy", "dummy", None);

        let mut config_builder = aws_sdk_lambda::config::Builder::from(&config)
            .endpoint_url("http://0.0.0.0:9000")
            .region(Region::new("us-east-1"))
            .credentials_provider(creds);

        let lambda_client = aws_sdk_lambda::Client::from_conf(config_builder.build());

        let mut res = lambda_client
            .invoke_with_response_stream()
            .function_name("_")
            .payload(Blob::new("hello world"))
            .send()
            .await.unwrap();

        loop {
            match res.event_stream.recv().await {
                Ok(None) => break,
                Ok(Some(event)) => match event {
                    InvokeWithResponseStreamResponseEvent::InvokeComplete(_) => {
                        println!("invoke complete");
                        break;
                    }
                    InvokeWithResponseStreamResponseEvent::PayloadChunk(payload) => {
                        dbg!(&payload);
                    }
                    _ => todo!(),
                },
                err => {
                    dbg!(err);
                }
            }
        }
    }

My understanding is that the watch crate needs to be extended to implement the route "/2015-03-31/functions/:function_name/response-streaming-invocations" and wrap the streamed chunks in the AWS event stream message framing.

I'd be willing to give this a crack if time allows, but want to sense check that this is a desired thing to have in this repo first (and that I'm not just missing something obvious).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions