chore(analytics): opensearch client creation based on config (#7810)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Shivansh Mathur
2025-04-17 13:32:22 +05:30
committed by GitHub
parent 5690864fd2
commit 2067bc3520
8 changed files with 61 additions and 23 deletions

View File

@ -2245,7 +2245,10 @@ pub mod routes {
.collect();
analytics::search::msearch_results(
&state.opensearch_client,
state
.opensearch_client
.as_ref()
.ok_or_else(|| error_stack::report!(OpenSearchError::NotEnabled))?,
req,
search_params,
SEARCH_INDEXES.to_vec(),
@ -2392,9 +2395,16 @@ pub mod routes {
})
})
.collect();
analytics::search::search_results(&state.opensearch_client, req, search_params)
.await
.map(ApplicationResponse::Json)
analytics::search::search_results(
state
.opensearch_client
.as_ref()
.ok_or_else(|| error_stack::report!(OpenSearchError::NotEnabled))?,
req,
search_params,
)
.await
.map(ApplicationResponse::Json)
},
&auth::JWTAuth {
permission: Permission::ProfileAnalyticsRead,