-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmod.rs
More file actions
80 lines (69 loc) · 2.67 KB
/
mod.rs
File metadata and controls
80 lines (69 loc) · 2.67 KB
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
//! Auction orchestration module for managing multi-provider bidding.
//!
//! This module provides an extensible framework for running auctions across
//! multiple providers (Prebid, Amazon APS, Google GAM, etc.) with support for
//! parallel execution and mediation strategies.
//!
//! Note: Individual auction providers are located in the `integrations` module
//! (e.g., `crate::integrations::aps`, `crate::integrations::prebid`).
use error_stack::Report;
use crate::error::TrustedServerError;
use crate::settings::Settings;
use std::sync::Arc;
pub mod config;
pub mod context;
pub mod endpoints;
pub mod formats;
pub mod orchestrator;
pub mod provider;
pub mod types;
pub use config::AuctionConfig;
pub use context::{build_url_with_context_params, ContextQueryParams, ContextValue};
pub use orchestrator::AuctionOrchestrator;
pub use provider::AuctionProvider;
pub use types::{
AdFormat, AuctionContext, AuctionRequest, AuctionResponse, Bid, BidStatus, MediaType,
};
/// Type alias for provider builder functions.
type ProviderBuilder =
fn(&Settings) -> Result<Vec<Arc<dyn AuctionProvider>>, Report<TrustedServerError>>;
/// Returns the list of all available provider builder functions.
///
/// This list is used to auto-discover and register auction providers from settings.
/// Each builder function checks the settings for its specific provider configuration
/// and returns any enabled providers.
fn provider_builders() -> &'static [ProviderBuilder] {
&[
crate::integrations::prebid::register_auction_provider,
crate::integrations::aps::register_providers,
crate::integrations::adserver_mock::register_providers,
]
}
/// Build a new auction orchestrator for the current settings.
///
/// This constructor registers all auction providers discovered from the provided settings.
/// Callers can reuse the returned [`AuctionOrchestrator`] across requests.
///
/// # Arguments
/// * `settings` - Application settings used to configure the orchestrator and providers
///
/// # Errors
///
/// Returns an error when an enabled auction provider has invalid configuration.
pub fn build_orchestrator(
settings: &Settings,
) -> Result<AuctionOrchestrator, Report<TrustedServerError>> {
log::info!("Building auction orchestrator");
let mut orchestrator = AuctionOrchestrator::new(settings.auction.clone());
// Auto-discover and register all auction providers from settings
for builder in provider_builders() {
for provider in builder(settings)? {
orchestrator.register_provider(provider);
}
}
log::info!(
"Auction orchestrator built with {} providers",
orchestrator.provider_count()
);
Ok(orchestrator)
}