Skip to content

Commit 39cb7dc

Browse files
remove strategy field from config
1 parent e69d0ce commit 39cb7dc

File tree

8 files changed

+47
-42
lines changed

8 files changed

+47
-42
lines changed

TESTING.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ Edit `trusted-server.toml` to customize the auction:
6262
# Enable/disable orchestrator
6363
[auction]
6464
enabled = true
65-
strategy = "parallel_mediation" # or "parallel_only"
6665
bidders = ["prebid", "aps"]
67-
mediator = "gam"
66+
mediator = "gam" # If set: mediation, if omitted: highest bid wins
6867
timeout_ms = 2000
6968

7069
# Mock provider configs
@@ -87,9 +86,8 @@ gam_win_rate = 30 # GAM wins 30% of the time
8786
```toml
8887
[auction]
8988
enabled = true
90-
strategy = "parallel_mediation"
9189
bidders = ["prebid", "aps"]
92-
mediator = "gam"
90+
mediator = "gam" # Mediator configured = parallel mediation strategy
9391
```
9492

9593
**Expected Flow:**
@@ -103,9 +101,8 @@ mediator = "gam"
103101
```toml
104102
[auction]
105103
enabled = true
106-
strategy = "parallel_only"
107104
bidders = ["prebid", "aps"]
108-
# No mediator
105+
# No mediator = parallel only strategy
109106
```
110107

111108
**Expected Flow:**

crates/common/src/auction/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,8 @@ Manages the execution of an auction flow, coordinates providers, and collects re
402402
```toml
403403
[auction]
404404
enabled = true
405-
strategy = "parallel_mediation"
406405
bidders = ["prebid", "aps"]
407-
mediator = "gam"
406+
mediator = "gam" # Setting mediator enables parallel mediation strategy
408407
timeout_ms = 2000
409408
```
410409

@@ -420,8 +419,8 @@ timeout_ms = 2000
420419
```toml
421420
[auction]
422421
enabled = true
423-
strategy = "parallel_only"
424422
bidders = ["prebid", "aps"]
423+
# No mediator = parallel only strategy (highest CPM wins)
425424
timeout_ms = 2000
426425
```
427426

@@ -439,12 +438,15 @@ All auction settings are configured directly under `[auction]`:
439438
```toml
440439
[auction]
441440
enabled = true # Enable/disable auction orchestration
442-
strategy = "parallel_mediation" # Auction strategy
443441
bidders = ["prebid", "aps"] # List of bidder providers
444-
mediator = "gam" # Optional mediator (only for parallel_mediation)
442+
mediator = "gam" # Optional: if set, uses mediation; if omitted, highest bid wins
445443
timeout_ms = 2000 # Overall auction timeout
446444
```
447445

446+
**Strategy Auto-Detection:**
447+
- When `mediator` is configured → Runs **parallel mediation** (bidders in parallel, mediator decides winner)
448+
- When `mediator` is omitted → Runs **parallel only** (bidders in parallel, highest CPM wins)
449+
448450
### Provider Configuration
449451

450452
Each provider has its own configuration section:

crates/common/src/auction/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,19 @@ fn convert_to_openrtb_response(
385385
}));
386386
}
387387

388+
// Determine strategy name for response metadata
389+
let strategy_name = if settings.auction.has_mediator() {
390+
"parallel_mediation"
391+
} else {
392+
"parallel_only"
393+
};
394+
388395
let response_body = json!({
389396
"id": auction_id,
390397
"seatbid": seatbids,
391398
"ext": {
392399
"orchestrator": {
393-
"strategy": settings.auction.strategy,
400+
"strategy": strategy_name,
394401
"bidders": result.bidder_responses.len(),
395402
"total_bids": result.total_bids(),
396403
"time_ms": result.total_time_ms

crates/common/src/auction/orchestrator.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,35 @@ impl AuctionOrchestrator {
3838
self.providers.len()
3939
}
4040

41-
/// Execute an auction using the configured strategy.
41+
/// Execute an auction using the auto-detected strategy.
42+
///
43+
/// Strategy is determined by mediator configuration:
44+
/// - If mediator is configured: runs parallel mediation (bidders → mediator decides)
45+
/// - If no mediator: runs parallel only (bidders → highest CPM wins)
4246
pub async fn run_auction(
4347
&self,
4448
request: &AuctionRequest,
4549
context: &AuctionContext<'_>,
4650
) -> Result<OrchestrationResult, Report<TrustedServerError>> {
4751
let start_time = Instant::now();
4852

49-
log::info!("Running auction with strategy: {}", self.config.strategy);
53+
// Auto-detect strategy based on mediator configuration
54+
let (strategy_name, result) = if self.config.has_mediator() {
55+
(
56+
"parallel_mediation",
57+
self.run_parallel_mediation(request, context).await?,
58+
)
59+
} else {
60+
(
61+
"parallel_only",
62+
self.run_parallel_only(request, context).await?,
63+
)
64+
};
5065

51-
let result = match self.config.strategy.as_str() {
52-
"parallel_mediation" => self.run_parallel_mediation(request, context).await,
53-
"parallel_only" => self.run_parallel_only(request, context).await,
54-
strategy => Err(Report::new(TrustedServerError::Auction {
55-
message: format!(
56-
"Unknown auction strategy '{}'. Valid strategies: parallel_mediation, parallel_only",
57-
strategy
58-
),
59-
})),
60-
}?;
66+
log::info!(
67+
"Running auction with strategy: {} (auto-detected from mediator config)",
68+
strategy_name
69+
);
6170

6271
Ok(OrchestrationResult {
6372
total_time_ms: start_time.elapsed().as_millis() as u64,
@@ -429,7 +438,6 @@ mod tests {
429438
async fn test_no_bidders_configured() {
430439
let config = AuctionConfig {
431440
enabled: true,
432-
strategy: "parallel_only".to_string(),
433441
bidders: vec![],
434442
mediator: None,
435443
timeout_ms: 2000,

crates/common/src/auction_config_types.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ pub struct AuctionConfig {
99
#[serde(default)]
1010
pub enabled: bool,
1111

12-
/// Auction strategy: "parallel_mediation", "parallel_only"
13-
#[serde(default = "default_strategy")]
14-
pub strategy: String,
15-
1612
/// Provider names that participate in bidding
1713
/// Simply list the provider names (e.g., ["prebid", "aps"])
1814
#[serde(default)]
1915
pub bidders: Vec<String>,
2016

2117
/// Optional mediator provider name (e.g., "gam")
18+
/// When set, runs parallel mediation strategy (bidders in parallel, then mediator decides)
19+
/// When omitted, runs parallel only strategy (bidders in parallel, highest CPM wins)
2220
pub mediator: Option<String>,
2321

2422
/// Timeout in milliseconds
@@ -30,10 +28,6 @@ pub struct AuctionConfig {
3028
pub creative_store: String,
3129
}
3230

33-
fn default_strategy() -> String {
34-
"parallel_mediation".to_string()
35-
}
36-
3731
fn default_timeout() -> u32 {
3832
2000
3933
}

crates/common/src/integrations/aps_readme.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ Run APS alongside other bidders:
6060
```toml
6161
[auction]
6262
enabled = true
63-
strategy = "parallel_only"
6463
bidders = ["aps", "prebid"]
6564
timeout_ms = 2000
65+
# No mediator = parallel only (highest CPM wins)
6666
```
6767

6868
**Benefits:**
@@ -77,9 +77,8 @@ Use GAM to mediate all bids:
7777
```toml
7878
[auction]
7979
enabled = true
80-
strategy = "parallel_mediation"
8180
bidders = ["aps", "prebid"]
82-
mediator = "gam"
81+
mediator = "gam" # Enables parallel mediation (GAM decides winner)
8382
timeout_ms = 2000
8483
```
8584

docs/APS_QUICKSTART.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ INFO APS returned 2 bids in 150ms
8787
```toml
8888
[auction]
8989
enabled = true
90-
strategy = "parallel_only"
9190
bidders = ["aps"]
91+
# No mediator = parallel only (highest CPM wins)
9292
```
9393

9494
### APS + Prebid (Parallel)
@@ -98,9 +98,9 @@ Best for maximum revenue:
9898
```toml
9999
[auction]
100100
enabled = true
101-
strategy = "parallel_only"
102101
bidders = ["aps", "prebid"]
103102
timeout_ms = 2000
103+
# No mediator = all bidders compete, highest CPM wins
104104

105105
[integrations.aps]
106106
enabled = true
@@ -120,9 +120,8 @@ Let GAM decide winners:
120120
```toml
121121
[auction]
122122
enabled = true
123-
strategy = "parallel_mediation"
124123
bidders = ["aps", "prebid"]
125-
mediator = "gam"
124+
mediator = "gam" # Setting mediator enables parallel mediation
126125
```
127126

128127
## Testing Without Live Credentials

trusted-server.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ rewrite_sdk = true
7272
# Auction orchestration configuration
7373
[auction]
7474
enabled = true
75-
strategy = "parallel_mediation" # Options: "parallel_mediation", "parallel_only"
7675
bidders = ["prebid", "aps_mock"] # Use mock providers for testing
77-
mediator = "gam_mock"
76+
mediator = "gam_mock" # When set: parallel mediation, when omitted: parallel only
7877
timeout_ms = 2000
7978

8079
# Mock APS Configuration (for testing)

0 commit comments

Comments
 (0)