Skip to content

Reorganized integration with external libraries

Pre-release
Pre-release
Compare
Choose a tag to compare
@slinkydeveloper slinkydeveloper released this 07 Jul 13:36
2cae3f0

On the behalf of CloudEvents community, I'm pleased to announce the 0.4 release of cloudevents/sdk-rust!

No more integration crates!

From now on, integrations are not going to be shipped as separate crates anymore, but as features within the cloudevents-sdk crate, under the cloudevents::binding module. These features are:

  • actix to use the cloudevents::binding::actix module
  • reqwest to use the cloudevents::binding::reqwest module
  • rdkafka to use the cloudevents::binding::rdkafka module
  • warp to use the cloudevents::binding::warp module (details below)

Check out the refreshed examples for more details: https://github.com/cloudevents/sdk-rust/tree/master/example-projects

Deeper actix-web integration

Thanks to the change described above, we can now provide deeper integrations with the various libraries. As an example, now we provide implementations of actix_web::FromRequest and actix_web::Responder for cloudevents::Event, which allows you to read and write CloudEvents in HTTP envelopes without invoking any additional method:

#[post("/")]
async fn post_event(event: Event) -> Event {
    println!("Received Event: {:?}", event);
    event
}

#[get("/")]
async fn get_event() -> Event {
    EventBuilderV10::new()
        .id("0001")
        .ty("example.test")
        .source("http://localhost/")
        .data("application/json", json!({"hello": "world"}))
        .extension("someint", "10")
        .build()
        .unwrap()
}

Check out the updated actix-web example: https://github.com/cloudevents/sdk-rust/blob/master/example-projects/actix-web-example/

seanmonstar/warp integration

We have a new integration with the web server framework warp, please check it out! For more details: #97

API Breaking changes

There is a breaking change in the type of the source attribute, which now uses an alias type for String. As described in the original issue, because the url::Url type cannot store URI references, we had to modify the type to String to fix incompatibilities. For more details: #106

And more

Other notable changes:

  • Updated warp to 0.3, rdkafka to 0.25 and reqwest to 0.11: #113
  • Fix null attributes in the json unmarshalling, per recent spec update: #142

I wish to thank all the contributors involved in this release!

For a complete list check out the milestone: https://github.com/cloudevents/sdk-rust/milestone/4?closed=1