Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/elastic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@ appveyor = { repository = "elastic-rs/elastic" }

[features]
default = [
"sync_sender",
"async_sender",
"geo-types"
]

sync_sender = [
"reqwest"
]

async_sender = [
"reqwest",
"futures",
"tokio",
"tokio-threadpool"
]

rustls-tls = [
"reqwest/rustls-tls"
]
Expand All @@ -40,16 +53,16 @@ quick-error = "~1"
error-chain = "~0.11"
log = "~0.4"
uuid = { version = "~0.7", features = [ "v4" ] }
url = "~2"
url = "~1"
bytes = "~0.4"
http = "~0.1"
serde = "~1"
serde_json = "~1"
serde_derive = "~1"
reqwest = { version = "~0.9", default-features = false }
futures = "~0.1"
tokio = "~0.1"
tokio-threadpool = "~0.1"
reqwest = { version = "~0.9", optional = true, default-features = false }
futures = { version = "~0.1", optional = true }
tokio = { version = "~0.1", optional = true }
tokio-threadpool = { version = "~0.1", optional = true }
fluent_builder = "~0.6"
crossbeam-channel = "~0.3"
chrono = { version = "~0.4.0", features = [ "serde" ]}
Expand Down
2 changes: 1 addition & 1 deletion src/elastic/src/client/asynchronous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl AsyncClientBuilder {
pre_send: self.pre_send,
};

let addresses = self.nodes.build(params, sender.clone());
let addresses = self.nodes.build(params);

Ok(AsyncClient { sender, addresses })
}
Expand Down
34 changes: 27 additions & 7 deletions src/elastic/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,13 +543,15 @@ For more details see the [`responses`][responses-mod] module.
pub mod requests;
pub mod responses;

#[cfg(feature="async_sender")]
mod asynchronous;
#[cfg(feature="sync_sender")]
mod synchronous;

pub use self::{
asynchronous::*,
synchronous::*,
};
#[cfg(feature="async_sender")]
pub use self::asynchronous::*;
#[cfg(feature="sync_sender")]
pub use self::synchronous::*;

#[doc(inline)]
pub use crate::http::sender::{
Expand Down Expand Up @@ -615,7 +617,7 @@ tokio::runtime::current_thread::block_on_all(response_future)?;
#[derive(Clone)]
pub struct Client<TSender> {
sender: TSender,
addresses: NodeAddresses<TSender>,
addresses: NodeAddresses,
}

impl<TSender> Client<TSender>
Expand Down Expand Up @@ -644,6 +646,16 @@ where
index: index.into(),
}
}

/**
Creates a new client with a manually created sender and list of node addresses.
*/
pub fn from_sender(sender: TSender, addresses: NodeAddresses) -> Self {
Self {
sender,
addresses,
}
}
}

/**
Expand Down Expand Up @@ -674,10 +686,18 @@ pub mod prelude {
pub use super::{
requests::prelude::*,
responses::prelude::*,
AsyncClient,
AsyncClientBuilder,
PreRequestParams,
RequestParams,
};

#[cfg(feature="async_sender")]
pub use super::{
AsyncClient,
AsyncClientBuilder,
};

#[cfg(feature="sync_sender")]
pub use super::{
SyncClient,
SyncClientBuilder,
};
Expand Down
Loading