MCPcopy Create free account
hub / github.com/comaps/comaps / LoadMetaConfig

Method LoadMetaConfig

libs/storage/map_files_downloader.cpp:189–232  ·  view source on GitHub ↗

static

Source from the content-addressed store, hash-verified

187
188// static
189MetaConfig MapFilesDownloader::LoadMetaConfig()
190{
191 Platform & pl = GetPlatform();
192
193 // If user sets a custom download server, skip metaserver entirely.
194 std::string const customServer = pl.CustomMapServerUrl();
195 if (!customServer.empty())
196 {
197 LOG(LINFO, ("Using custom map server URL:", customServer));
198
199 MetaConfig metaConfig;
200 metaConfig.m_serversList = {customServer};
201 return metaConfig;
202 }
203
204 std::string const metaServerUrl = url::Join(pl.MetaServerUrl(), "servers");
205 std::string httpResult;
206
207 if (!metaServerUrl.empty())
208 {
209 LOG(LINFO, ("Requesting metaserver", metaServerUrl));
210 platform::HttpClient request(metaServerUrl);
211 request.SetRawHeader("X-OM-DataVersion", std::to_string(m_dataVersion));
212 request.SetRawHeader("X-OM-AppVersion", pl.Version());
213 request.SetRawHeader("Accept-Language", GetAcceptLanguage());
214 request.SetTimeout(10.0); // timeout in seconds
215 request.RunHttpRequest(httpResult);
216 }
217
218 auto metaConfig = downloader::ParseMetaConfig(httpResult);
219 if (!metaConfig)
220 {
221 metaConfig = downloader::ParseMetaConfig(pl.DefaultUrlsJSON());
222 CHECK(metaConfig, ());
223 LOG(LWARNING, ("Can't get metaserver configuration, using default servers:", metaConfig->m_serversList));
224 }
225 else
226 {
227 LOG(LINFO, ("Got servers list:", metaConfig->m_serversList));
228 }
229
230 CHECK(!metaConfig->m_serversList.empty(), ());
231 return *metaConfig;
232}
233
234void MapFilesDownloader::GetMetaConfig(MetaConfigCallback const & callback)
235{

Callers

nothing calls this directly

Calls 10

to_stringFunction · 0.85
GetAcceptLanguageFunction · 0.85
ParseMetaConfigFunction · 0.85
MetaServerUrlMethod · 0.80
VersionMethod · 0.80
DefaultUrlsJSONMethod · 0.80
JoinFunction · 0.50
emptyMethod · 0.45
SetTimeoutMethod · 0.45
RunHttpRequestMethod · 0.45

Tested by

no test coverage detected