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
// Sonic
//
// Fast, lightweight and schema-less search backend
// Copyright: 2026, Rémi Bardon <remi@remibardon.name>
// License: Mozilla Public License v2.0 (MPL v2.0)
//! Documentation in progress. See examples.
//!
compile_error!;
pub use crateCommand;
pub use crate;
pub use crateSonicMultiplexer;
/// Number of commands which can be queued between two cycles of the event loop.
///
/// The difference in allocated memory is quite small so there’s no reason to
/// keep this very low. We might make this configurable someday.
const COMMAND_QUEUE_SIZE: usize = 64;
/// Number of [`mio`] events that can be processed in a single event loop cycle.
/// Real usage should be less than or equal to 3 times the number of Sonic
/// channels you’ve attached to a single [`SonicMultiplexer`].
///
/// The difference in allocated memory is quite small so there’s no reason to
/// keep this very low. We might make this configurable someday.
const MIO_EVENTS_CAPACITY: usize = 3 * 16;
/// Capacity of the buffer where Sonic responses are written to before being
/// processed. Sonic server responses are usually quite short so no need to
/// make it huge.
///
/// We chose 2 * 4KiB (common memory page size) as the default, which should
/// be good for most use cases. We might make this configurable someday.
const TCP_READ_BUFFER_CAPACITY: usize = 2 * 4096;
/// Capacity of the buffer where Sonic commands are written to before being
/// flushed to the TCP stream. Ideally, it should be larger than your Sonic
/// server’s buffer size (which is often 20 000).
///
/// We chose 16 * 4KiB (common memory page size) as the default, which should
/// be good for most use cases. We might make this configurable someday.
const TCP_WRITE_BUFFER_CAPACITY: usize = 65_536;
/// Safety timeout when sending events to channels.
///
/// This timeout can be reached if channel capacities are too low.
const SEND_TIMEOUT: Duration = from_secs;
/// Safety timeout when reading events from channels.
///
/// This timeout has to take into account TCP packets travel time, parsing and
/// processing, hence why it’s so high. It should not be reached, but it’s there
/// as a safety precaution.
const RECV_TIMEOUT: Duration = from_secs;