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:
|
||||
command: build
|
||||
toolchain: ${{ matrix.toolchain }}
|
||||
args: --target wasm32-unknown-unknown --features cloudevents-reqwest
|
||||
args: --target wasm32-unknown-unknown --features reqwest-binding
|
||||
|
||||
# Build examples
|
||||
- uses: actions-rs/cargo@v1
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ categories = ["web-programming", "encoding", "data-structures"]
|
|||
name = "cloudevents"
|
||||
|
||||
[features]
|
||||
cloudevents-actix = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
|
||||
cloudevents-reqwest = ["reqwest", "async-trait", "lazy_static", "bytes"]
|
||||
cloudevents-rdkafka = ["rdkafka", "lazy_static", "bytes"]
|
||||
cloudevents-warp = ["warp", "lazy_static", "bytes", "http", "hyper"]
|
||||
actix-binding = ["actix-web", "async-trait", "lazy_static", "bytes", "futures"]
|
||||
reqwest-binding = ["reqwest", "async-trait", "lazy_static", "bytes"]
|
||||
rdkafka-binding = ["rdkafka", "lazy_static", "bytes"]
|
||||
warp-binding = ["warp", "lazy_static", "bytes", "http", "hyper"]
|
||||
|
||||
[dependencies]
|
||||
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
|
||||
enabled by a specific [feature flag]:
|
||||
|
||||
* `cloudevents-actix`: Integration with [actix](https://actix.rs/).
|
||||
* `cloudevents-warp`: Integration with [warp](https://github.com/seanmonstar/warp/).
|
||||
* `cloudevents-reqwest`: Integration with [reqwest](https://github.com/seanmonstar/reqwest).
|
||||
* `cloudevents-rdkafka`: Integration with [rdkafka](https://fede1024.github.io/rust-rdkafka).
|
||||
* `actix-binding`: Integration with [actix](https://actix.rs/).
|
||||
* `warp-binding`: Integration with [warp](https://github.com/seanmonstar/warp/).
|
||||
* `reqwest-binding`: Integration with [reqwest](https://github.com/seanmonstar/reqwest).
|
||||
* `rdkafka-binding`: Integration with [rdkafka](https://fede1024.github.io/rust-rdkafka).
|
||||
|
||||
This crate is continuously tested to work with GNU libc, WASM and musl
|
||||
toolchains.
|
||||
|
|
@ -40,7 +40,7 @@ enabling your Protocol Binding of choice:
|
|||
|
||||
```toml
|
||||
[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:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ authors = ["Francesco Guardiani <francescoguard@gmail.com>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-actix"] }
|
||||
cloudevents-sdk = { path = "../..", features = ["actix-binding"] }
|
||||
actix-web = "^3"
|
||||
actix-cors = "^0.5"
|
||||
lazy_static = "1.4.0"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
async-trait = "^0.1.33"
|
||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-rdkafka"] }
|
||||
cloudevents-sdk = { path = "../..", features = ["rdkafka-binding"] }
|
||||
lazy_static = "1.4.0"
|
||||
bytes = "^1.0"
|
||||
url = { version = "^2.1", features = ["serde"] }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use futures::StreamExt;
|
|||
use serde_json::json;
|
||||
|
||||
use cloudevents::{EventBuilder, EventBuilderV10};
|
||||
use cloudevents::rdkafka::{FutureRecordExt, MessageExt, MessageRecord};
|
||||
use cloudevents::binding::rdkafka::{FutureRecordExt, MessageExt, MessageRecord};
|
||||
|
||||
use rdkafka::config::{ClientConfig, RDKafkaLogLevel};
|
||||
use rdkafka::consumer::stream_consumer::StreamConsumer;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ crate-type = ["cdylib"]
|
|||
|
||||
[dependencies]
|
||||
reqwest = "^0.11"
|
||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-reqwest"] }
|
||||
cloudevents-sdk = { path = "../..", features = ["reqwest-binding"] }
|
||||
url = { version = "^2.1" }
|
||||
web-sys = { version = "0.3.39", features = ["Window", "Location"] }
|
||||
wasm-bindgen-futures = "0.4.12"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use cloudevents::reqwest::RequestBuilderExt;
|
||||
use cloudevents::binding::reqwest::RequestBuilderExt;
|
||||
use cloudevents::{EventBuilder, EventBuilderV10};
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ categories = ["web-programming", "encoding"]
|
|||
license-file = "../LICENSE"
|
||||
|
||||
[dependencies]
|
||||
cloudevents-sdk = { path = "../..", features = ["cloudevents-warp"] }
|
||||
cloudevents-sdk = { path = "../..", features = ["warp-binding"] }
|
||||
warp = "^0.3"
|
||||
tokio = { version = "^1.0", features = ["full"] }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use cloudevents::warp::{filter, reply};
|
||||
use cloudevents::binding::warp::{filter, reply};
|
||||
use warp::Filter;
|
||||
|
||||
#[tokio::main]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
//! To deserialize an HTTP request as CloudEvent:
|
||||
//!
|
||||
//! ```
|
||||
//! use cloudevents::actix::HttpRequestExt;
|
||||
//! use cloudevents::binding::actix::HttpRequestExt;
|
||||
//! use actix_web::{HttpRequest, web, post};
|
||||
//!
|
||||
//! #[post("/")]
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
//! 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 cloudevents::{EventBuilderV10, EventBuilder};
|
||||
//! 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)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::rdkafka::kafka_producer_record::MessageRecord;
|
||||
use crate::binding::rdkafka::kafka_producer_record::MessageRecord;
|
||||
|
||||
use crate::{EventBuilder, EventBuilderV10};
|
||||
use chrono::Utc;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
//! use cloudevents::Event;
|
||||
//! use rdkafka::producer::{FutureProducer, FutureRecord};
|
||||
//! 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>> {
|
||||
//! let message_record = MessageRecord::from_event(event)?;
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
//!
|
||||
//! ```
|
||||
//! use rdkafka::consumer::{StreamConsumer, DefaultConsumerContext, Consumer, CommitMode};
|
||||
//! use cloudevents::rdkafka::MessageExt;
|
||||
//! use cloudevents::binding::rdkafka::MessageExt;
|
||||
//! use futures::StreamExt;
|
||||
//!
|
||||
//! # 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.
|
||||
//!
|
||||
//! ```
|
||||
//! use cloudevents::reqwest::{RequestBuilderExt, ResponseExt};
|
||||
//! use cloudevents::binding::reqwest::{RequestBuilderExt, ResponseExt};
|
||||
//! use cloudevents::{EventBuilderV10, EventBuilder};
|
||||
//! use serde_json::json;
|
||||
//!
|
||||
|
|
@ -16,7 +16,7 @@ impl warp::reject::Reject for EventFilterError {}
|
|||
/// # Extracts [`crate::Event`] from incoming request
|
||||
///
|
||||
/// ```
|
||||
/// use cloudevents::warp::filter::to_event;
|
||||
/// use cloudevents::binding::warp::filter::to_event;
|
||||
/// use warp::Filter;
|
||||
/// use warp::Reply;
|
||||
///
|
||||
|
|
@ -7,8 +7,8 @@
|
|||
//!
|
||||
//! ```
|
||||
//! use warp::{Filter, Reply};
|
||||
//! use cloudevents::warp::reply::from_event;
|
||||
//! use cloudevents::warp::filter::to_event;
|
||||
//! use cloudevents::binding::warp::reply::from_event;
|
||||
//! use cloudevents::binding::warp::filter::to_event;
|
||||
//!
|
||||
//! let routes = warp::any()
|
||||
//! // extracting event from request
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
//! use http::StatusCode;
|
||||
//! use serde_json::json;
|
||||
//! use warp::{Filter, Reply};
|
||||
//! use cloudevents::warp::reply::from_event;
|
||||
//! use cloudevents::binding::warp::reply::from_event;
|
||||
//!
|
||||
//! let routes = warp::any().map(|| {
|
||||
//! let event = EventBuilderV10::new()
|
||||
|
|
@ -8,7 +8,7 @@ use warp::reply::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 warp::Filter;
|
||||
/// 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
|
||||
//! 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
|
||||
//! [`to_event`](actix::HttpRequestExt::to_event) function, the
|
||||
//! [`actix_web::dev::HttpResponseBuilder`] with an
|
||||
|
|
@ -44,12 +44,9 @@
|
|||
//! and implementations for [`actix_web::FromRequest`] and
|
||||
//! [`actix_web::Responder`] in order to take advantage of actix-web's
|
||||
//! [Extractors] and [Responders]
|
||||
//!
|
||||
//! - `cloudevents-reqwest`: Enables the [reqwest] module.
|
||||
//!
|
||||
//! - `cloudevents-warp`: Enables the [warp] module.
|
||||
//!
|
||||
//! - `cloudevents-rdkafka`: Enables the [rdkafka] module to
|
||||
//! - `reqwest-binding`: Enables the [reqwest] protocol binding module.
|
||||
//! - `warp-binding`: Enables the [warp] protocol binding module.
|
||||
//! - `rdkafka-binding`: Enables the [rdkafka] protocol binding module to
|
||||
//! seamlessly consume/produce cloudevents within Kafka messages.
|
||||
//!
|
||||
//! [feature flags]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section
|
||||
|
|
@ -58,17 +55,9 @@
|
|||
|
||||
#![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 message;
|
||||
pub mod binding;
|
||||
|
||||
pub use event::Data;
|
||||
pub use event::Event;
|
||||
|
|
|
|||
Loading…
Reference in New Issue