1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
use ;
/// # Pool
///
/// Module for LDAP connection pooling using [`deadpool`](https://docs.rs/deadpool/latest/deadpool/index.html).
///
/// A single LDAP connection is able to handle multiple operations concurrently, but beyond a certain
/// point it will become a bottleneck. This is where pooling comes in.
///
/// The pool keeps multiple connections alive and gives them to you upon request (or makes you wait for one to become available.)
///
///
/// ## Do I need connection pooling?
///
/// As always, there's no substitute for benchmarking on your particular usecase.
///
/// But as a general rule of thumb: If your code is some sort of service, e.g. a website needing to authenticate users as they try to login, use pooling. On the other hand if your code is a oneshot executable, such as the `ldapsearch` CLI tool, don't bother with pooling.
///
///
/// ## Example
///
/// ```no_run
/// use simple_ldap::{
/// LdapConfig,
/// pool::build_connection_pool
/// };
/// use std::num::NonZeroUsize;
/// use url::Url;
///
/// #[tokio::main]
/// async fn main() -> () {
/// let ldap_config = LdapConfig {
/// bind_dn: String::from("cn=manager"),
/// bind_password: String::from("password"),
/// ldap_url: Url::parse("ldap://localhost:1389/dc=example,dc=com").unwrap(),
/// dn_attribute: None,
/// connection_settings: None
/// };
/// let pool_size = NonZeroUsize::new(10).unwrap();
///
/// // Build the ldap connection pool.
/// let pool = build_connection_pool(ldap_config, pool_size).await.unwrap();
///
/// // Get clients from the pool.
/// let mut client_from_pool = pool.get().await.unwrap();
///
/// // Perform operations on them just as with a normal LdapClient.
/// let result = client_from_pool.create_group("New Group", "dc=example,dc=com", "Some Description").await;
/// }
/// ```
///
///
/// ## Unbind
///
/// You cannot `unbind` the clients got from the pool.
/// Just return them to the pool. It will take care of it.
///
use NonZeroUsize;
use debug;
use crate::;
// Export the pool types in a standard manner.
// Check the source to see the types this exposes
managed_reexports!;
/// Manager for deadpool.
/// LDAP Manager for the `deadpool` managed connection pool.
/// Create a new connection pool.
pub async