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
// Copyright 2025 The Drasi Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Configuration types for HTTP adaptive reactions.
use ;
use HashMap;
use AdaptiveBatchConfig;
use QueryConfig;
/// HTTP Adaptive reaction configuration with adaptive batching
///
/// This reaction extends the standard HTTP reaction with intelligent batching and
/// HTTP/2 connection pooling, automatically adjusting batch size and timing based
/// on throughput patterns.
///
/// # Key Features
///
/// - **Intelligent Batching**: Groups multiple results based on traffic patterns
/// - **Batch Endpoint**: Sends batches to `{base_url}/batch` endpoint
/// - **Adaptive Algorithm**: Dynamically adjusts batch size and wait time
/// - **HTTP/2 Pooling**: Maintains persistent connections for better performance
/// - **Individual Fallback**: Uses query-specific routes for single results
///
/// # Batch Endpoint Format
///
/// Batches are sent as POST requests to `{base_url}/batch` with an array of
/// `BatchResult` objects containing query_id, results array, timestamp, and count.
///
/// # Example
///
/// ```rust,ignore
/// use drasi_lib::config::{ReactionConfig, ReactionSpecificConfig};
/// use drasi_lib::reactions::http_adaptive::HttpAdaptiveReactionConfig;
/// use drasi_lib::reactions::common::AdaptiveBatchConfig;
/// use std::collections::HashMap;
///
/// let config = ReactionConfig {
/// id: "adaptive-webhook".to_string(),
/// queries: vec!["user-changes".to_string()],
/// auto_start: true,
/// config: ReactionSpecificConfig::HttpAdaptive(HttpAdaptiveReactionConfig {
/// base_url: "https://api.example.com".to_string(),
/// token: Some("your-api-token".to_string()),
/// timeout_ms: 10000,
/// routes: HashMap::new(),
/// adaptive: AdaptiveBatchConfig {
/// adaptive_min_batch_size: 20,
/// adaptive_max_batch_size: 500,
/// adaptive_window_size: 10, // 1 second
/// adaptive_batch_timeout_ms: 1000,
/// },
/// }),
/// priority_queue_capacity: None,
/// };
/// ```