Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion svc/pkg/ip/ops/info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,25 @@ async fn handle(ctx: OperationContext<ip::info::Request>) -> GlobalResult<ip::in

// Fetch info
let ip_info = match provider {
ip::info::Provider::IpInfoIo => fetch_ip_info_io(&ctx, ctx.ts(), &ip_str).await?,
ip::info::Provider::IpInfoIo => {
ctx.cache()
.fetch_one_proto("ipinfo.ip", ip_str, {
let ctx = ctx.clone();
move |mut cache, ip_str| {
let ctx = ctx.clone();
async move {
let ip_info = fetch_ip_info_io(&ctx, ctx.ts(), &ip_str).await?;
if let Some(ip_info) = ip_info {
cache.resolve(&ip_str, ip_info);
} else {
// TODO(RVT-3792): Cache miss will hit database all of the time
}
Ok(cache)
}
}
})
.await?
}
};

Ok(ip::info::Response { ip_info })
Expand Down