Renamed features
Moved all bindings under a binding crate Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
This commit is contained in:
parent
cd98c6705e
commit
c292e7c92e
|
|
@ -97,7 +97,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
toolchain: ${{ matrix.toolchain }}
|
toolchain: ${{ matrix.toolchain }}
|
||||||
args: --target wasm32-unknown-unknown --features cloudevents-reqwest
|
args: --target wasm32-unknown-unknown --features reqwest-binding
|
||||||
|
|
||||||
# Build examples
|
# Build examples
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ categories = ["web-programming", "encoding", "data-structures"]
|
||||||
name = "cloudevents"
|
name = "cloudevents"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
cloudevents-actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
|
actix-binding = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
|
||||||
cloudevents-reqwest = ["reqwest", "async-trait", "lazy_static", "bytes"]
|
reqwest-binding = ["reqwest", "async-trait", "lazy_static", "bytes"]
|
||||||
cloudevents-rdkafka = ["rdkafka", "lazy_static", "bytes"]
|
rdkafka-binding = ["rdkafka", "lazy_static", "bytes"]
|
||||||
cloudevents-warp = ["warp", "lazy_static", "bytes", "http", "hyper"]
|
warp-binding = ["warp", "lazy_static", "bytes", "http", "hyper"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "^1.0", features = ["derive"] }
|
serde = { version = "^1.0", features = ["derive"] }
|
||||||
|
|
|
||||||
10
README.md
10
README.md
|
|
@ -25,10 +25,10 @@ The core modules include definitions for the `Event` and
|
||||||
mechanism to support various Protocol Bindings, each of which is
|
mechanism to support various Protocol Bindings, each of which is
|
||||||
enabled by a specific [feature flag]:
|
enabled by a specific [feature flag]:
|
||||||
|
|
||||||
* `cloudevents-actix`: Integration with [actix](https://actix.rs/).
|
* `actix-binding`: Integration with [actix](https://actix.rs/).
|
||||||
* `cloudevents-warp`: Integration with [warp](https://github.com/seanmonstar/warp/).
|
* `warp-binding`: Integration with [warp](https://github.com/seanmonstar/warp/).
|
||||||
* `cloudevents-reqwest`: Integration with [reqwest](https://github.com/seanmonstar/reqwest).
|
* `reqwest-binding`: Integration with [reqwest](https://github.com/seanmonstar/reqwest).
|
||||||
* `cloudevents-rdkafka`: Integration with [rdkafka](https://fede1024.github.io/rust-rdkafka).
|
* `rdkafka-binding`: Integration with [rdkafka](https://fede1024.github.io/rust-rdkafka).
|
||||||
|
|
||||||
This crate is continuously tested to work with GNU libc, WASM and musl
|
This crate is continuously tested to work with GNU libc, WASM and musl
|
||||||
toolchains.
|
toolchains.
|
||||||
|
|
@ -40,7 +40,7 @@ enabling your Protocol Binding of choice:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cloudevents-sdk = { version = "0.3.1", features = ["cloudevents-actix"] }
|
cloudevents-sdk = { version = "0.3.1", features = ["actix-binding"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you can start creating events:
|
Now you can start creating events:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ authors = ["Francesco Guardiani <francescoguard@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-actix"] }
|
cloudevents-sdk = { path = "../..", features = ["actix-binding"] }
|
||||||
actix-web = "^3"
|
actix-web = "^3"
|
||||||
actix-cors = "^0.5"
|
actix-cors = "^0.5"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = "^0.1.33"
|
async-trait = "^0.1.33"
|
||||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-rdkafka"] }
|
cloudevents-sdk = { path = "../..", features = ["rdkafka-binding"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
bytes = "^1.0"
|
bytes = "^1.0"
|
||||||
url = { version = "^2.1", features = ["serde"] }
|
url = { version = "^2.1", features = ["serde"] }
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use futures::StreamExt;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
use cloudevents::{EventBuilder, EventBuilderV10};
|
use cloudevents::{EventBuilder, EventBuilderV10};
|
||||||
use cloudevents::rdkafka::{FutureRecordExt, MessageExt, MessageRecord};
|
use cloudevents::binding::rdkafka::{FutureRecordExt, MessageExt, MessageRecord};
|
||||||
|
|
||||||
use rdkafka::config::{ClientConfig, RDKafkaLogLevel};
|
use rdkafka::config::{ClientConfig, RDKafkaLogLevel};
|
||||||
use rdkafka::consumer::stream_consumer::StreamConsumer;
|
use rdkafka::consumer::stream_consumer::StreamConsumer;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reqwest = "^0.11"
|
reqwest = "^0.11"
|
||||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-reqwest"] }
|
cloudevents-sdk = { path = "../..", features = ["reqwest-binding"] }
|
||||||
url = { version = "^2.1" }
|
url = { version = "^2.1" }
|
||||||
web-sys = { version = "0.3.39", features = ["Window", "Location"] }
|
web-sys = { version = "0.3.39", features = ["Window", "Location"] }
|
||||||
wasm-bindgen-futures = "0.4.12"
|
wasm-bindgen-futures = "0.4.12"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use cloudevents::reqwest::RequestBuilderExt;
|
use cloudevents::binding::reqwest::RequestBuilderExt;
|
||||||
use cloudevents::{EventBuilder, EventBuilderV10};
|
use cloudevents::{EventBuilder, EventBuilderV10};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ categories = ["web-programming", "encoding"]
|
||||||
license-file = "../LICENSE"
|
license-file = "../LICENSE"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-warp"] }
|
cloudevents-sdk = { path = "../..", features = ["warp-binding"] }
|
||||||
warp = "^0.3"
|
warp = "^0.3"
|
||||||
tokio = { version = "^1.0", features = ["full"] }
|
tokio = { version = "^1.0", features = ["full"] }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use cloudevents::warp::{filter, reply};
|
use cloudevents::binding::warp::{filter, reply};
|
||||||
use warp::Filter;
|
use warp::Filter;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
//! To deserialize an HTTP request as CloudEvent:
|
//! To deserialize an HTTP request as CloudEvent:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use cloudevents::actix::HttpRequestExt;
|
//! use cloudevents::binding::actix::HttpRequestExt;
|
||||||
//! use actix_web::{HttpRequest, web, post};
|
//! use actix_web::{HttpRequest, web, post};
|
||||||
//!
|
//!
|
||||||
//! #[post("/")]
|
//! #[post("/")]
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
//! To serialize a CloudEvent to an HTTP response:
|
//! To serialize a CloudEvent to an HTTP response:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use cloudevents::actix::HttpResponseBuilderExt;
|
//! use cloudevents::binding::actix::HttpResponseBuilderExt;
|
||||||
//! use actix_web::{HttpRequest, web, get, HttpResponse};
|
//! use actix_web::{HttpRequest, web, get, HttpResponse};
|
||||||
//! use cloudevents::{EventBuilderV10, EventBuilder};
|
//! use cloudevents::{EventBuilderV10, EventBuilder};
|
||||||
//! use serde_json::json;
|
//! use serde_json::json;
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
//! Provides protocol binding implementations for [`Event`].
|
||||||
|
|
||||||
|
#[cfg(feature = "actix-binding")]
|
||||||
|
pub mod actix;
|
||||||
|
#[cfg(feature = "rdkafka-binding")]
|
||||||
|
pub mod rdkafka;
|
||||||
|
#[cfg(feature = "reqwest-binding")]
|
||||||
|
pub mod reqwest;
|
||||||
|
#[cfg(feature = "warp-binding")]
|
||||||
|
pub mod warp;
|
||||||
|
|
@ -164,7 +164,7 @@ mod private {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::rdkafka::kafka_producer_record::MessageRecord;
|
use crate::binding::rdkafka::kafka_producer_record::MessageRecord;
|
||||||
|
|
||||||
use crate::{EventBuilder, EventBuilderV10};
|
use crate::{EventBuilder, EventBuilderV10};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
//! use cloudevents::Event;
|
//! use cloudevents::Event;
|
||||||
//! use rdkafka::producer::{FutureProducer, FutureRecord};
|
//! use rdkafka::producer::{FutureProducer, FutureRecord};
|
||||||
//! use rdkafka::util::Timeout;
|
//! use rdkafka::util::Timeout;
|
||||||
//! use cloudevents::rdkafka::{MessageRecord, FutureRecordExt};
|
//! use cloudevents::binding::rdkafka::{MessageRecord, FutureRecordExt};
|
||||||
//!
|
//!
|
||||||
//! # async fn produce(producer: &FutureProducer, event: Event) -> Result<(), Box<dyn std::error::Error>> {
|
//! # async fn produce(producer: &FutureProducer, event: Event) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//! let message_record = MessageRecord::from_event(event)?;
|
//! let message_record = MessageRecord::from_event(event)?;
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use rdkafka::consumer::{StreamConsumer, DefaultConsumerContext, Consumer, CommitMode};
|
//! use rdkafka::consumer::{StreamConsumer, DefaultConsumerContext, Consumer, CommitMode};
|
||||||
//! use cloudevents::rdkafka::MessageExt;
|
//! use cloudevents::binding::rdkafka::MessageExt;
|
||||||
//! use futures::StreamExt;
|
//! use futures::StreamExt;
|
||||||
//!
|
//!
|
||||||
//! # async fn consume(consumer: StreamConsumer<DefaultConsumerContext>) -> Result<(), Box<dyn std::error::Error>> {
|
//! # async fn consume(consumer: StreamConsumer<DefaultConsumerContext>) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
//! This module integrates the [cloudevents-sdk](https://docs.rs/cloudevents-sdk) with [reqwest](https://docs.rs/reqwest/) to easily send and receive CloudEvents.
|
//! This module integrates the [cloudevents-sdk](https://docs.rs/cloudevents-sdk) with [reqwest](https://docs.rs/reqwest/) to easily send and receive CloudEvents.
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use cloudevents::reqwest::{RequestBuilderExt, ResponseExt};
|
//! use cloudevents::binding::reqwest::{RequestBuilderExt, ResponseExt};
|
||||||
//! use cloudevents::{EventBuilderV10, EventBuilder};
|
//! use cloudevents::{EventBuilderV10, EventBuilder};
|
||||||
//! use serde_json::json;
|
//! use serde_json::json;
|
||||||
//!
|
//!
|
||||||
|
|
@ -16,7 +16,7 @@ impl warp::reject::Reject for EventFilterError {}
|
||||||
/// # Extracts [`crate::Event`] from incoming request
|
/// # Extracts [`crate::Event`] from incoming request
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use cloudevents::warp::filter::to_event;
|
/// use cloudevents::binding::warp::filter::to_event;
|
||||||
/// use warp::Filter;
|
/// use warp::Filter;
|
||||||
/// use warp::Reply;
|
/// use warp::Reply;
|
||||||
///
|
///
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use warp::{Filter, Reply};
|
//! use warp::{Filter, Reply};
|
||||||
//! use cloudevents::warp::reply::from_event;
|
//! use cloudevents::binding::warp::reply::from_event;
|
||||||
//! use cloudevents::warp::filter::to_event;
|
//! use cloudevents::binding::warp::filter::to_event;
|
||||||
//!
|
//!
|
||||||
//! let routes = warp::any()
|
//! let routes = warp::any()
|
||||||
//! // extracting event from request
|
//! // extracting event from request
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
//! use http::StatusCode;
|
//! use http::StatusCode;
|
||||||
//! use serde_json::json;
|
//! use serde_json::json;
|
||||||
//! use warp::{Filter, Reply};
|
//! use warp::{Filter, Reply};
|
||||||
//! use cloudevents::warp::reply::from_event;
|
//! use cloudevents::binding::warp::reply::from_event;
|
||||||
//!
|
//!
|
||||||
//! let routes = warp::any().map(|| {
|
//! let routes = warp::any().map(|| {
|
||||||
//! let event = EventBuilderV10::new()
|
//! let event = EventBuilderV10::new()
|
||||||
|
|
@ -8,7 +8,7 @@ use warp::reply::Response;
|
||||||
/// # Serializes [`crate::Event`] as a http response
|
/// # Serializes [`crate::Event`] as a http response
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use cloudevents::warp::reply::from_event;
|
/// use cloudevents::binding::warp::reply::from_event;
|
||||||
/// use cloudevents::Event;
|
/// use cloudevents::Event;
|
||||||
/// use warp::Filter;
|
/// use warp::Filter;
|
||||||
/// use warp::Reply;
|
/// use warp::Reply;
|
||||||
21
src/lib.rs
21
src/lib.rs
|
|
@ -36,7 +36,7 @@
|
||||||
//! Cloudevents uses a set of [feature flags] to conditionally compile
|
//! Cloudevents uses a set of [feature flags] to conditionally compile
|
||||||
//! only the module associated with the Protocol Binding you need:
|
//! only the module associated with the Protocol Binding you need:
|
||||||
//!
|
//!
|
||||||
//! - `cloudevents-actix`: Enables the [actix] module. This
|
//! - `actix-binding`: Enables the [actix] protocol binding module. This
|
||||||
//! extends the [`actix_web::HttpRequest`] with a
|
//! extends the [`actix_web::HttpRequest`] with a
|
||||||
//! [`to_event`](actix::HttpRequestExt::to_event) function, the
|
//! [`to_event`](actix::HttpRequestExt::to_event) function, the
|
||||||
//! [`actix_web::dev::HttpResponseBuilder`] with an
|
//! [`actix_web::dev::HttpResponseBuilder`] with an
|
||||||
|
|
@ -44,12 +44,9 @@
|
||||||
//! and implementations for [`actix_web::FromRequest`] and
|
//! and implementations for [`actix_web::FromRequest`] and
|
||||||
//! [`actix_web::Responder`] in order to take advantage of actix-web's
|
//! [`actix_web::Responder`] in order to take advantage of actix-web's
|
||||||
//! [Extractors] and [Responders]
|
//! [Extractors] and [Responders]
|
||||||
//!
|
//! - `reqwest-binding`: Enables the [reqwest] protocol binding module.
|
||||||
//! - `cloudevents-reqwest`: Enables the [reqwest] module.
|
//! - `warp-binding`: Enables the [warp] protocol binding module.
|
||||||
//!
|
//! - `rdkafka-binding`: Enables the [rdkafka] protocol binding module to
|
||||||
//! - `cloudevents-warp`: Enables the [warp] module.
|
|
||||||
//!
|
|
||||||
//! - `cloudevents-rdkafka`: Enables the [rdkafka] module to
|
|
||||||
//! seamlessly consume/produce cloudevents within Kafka messages.
|
//! seamlessly consume/produce cloudevents within Kafka messages.
|
||||||
//!
|
//!
|
||||||
//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
|
//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
|
||||||
|
|
@ -58,17 +55,9 @@
|
||||||
|
|
||||||
#![deny(broken_intra_doc_links)]
|
#![deny(broken_intra_doc_links)]
|
||||||
|
|
||||||
#[cfg(feature = "cloudevents-actix")]
|
|
||||||
pub mod actix;
|
|
||||||
#[cfg(feature = "cloudevents-rdkafka")]
|
|
||||||
pub mod rdkafka;
|
|
||||||
#[cfg(feature = "cloudevents-reqwest")]
|
|
||||||
pub mod reqwest;
|
|
||||||
#[cfg(feature = "cloudevents-warp")]
|
|
||||||
pub mod warp;
|
|
||||||
|
|
||||||
pub mod event;
|
pub mod event;
|
||||||
pub mod message;
|
pub mod message;
|
||||||
|
pub mod binding;
|
||||||
|
|
||||||
pub use event::Data;
|
pub use event::Data;
|
||||||
pub use event::Event;
|
pub use event::Event;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue