CDN Support - larz7/larzworksamples GitHub Wiki
Overview
This page documents how web services interact with the product CDN.
Mobile CDN
The CDN tag used by mobile app is determined by the CDN settings set in InventoryService. The setting is per environment (dev/qa/prod).
Three types of CDN settings are supported to indicate what CDN tag should be used:
-
custom
- allow specification of deviceID(s) to CDN tag mapping
-
carrier
- allow specification of carrier(s) to CDN tag mapping
-
default
- the default CDN tag
The settings is specified in Inventory under the CDN type. You can look at current settings through a GET call to:
https://xxxxx-1-0.inventory.xxx.xxxx.com:8443/v2/artifact/cdn (Example is for dev env)
CDN cache
The service maintains a cache of CDN settings stored in InventoryService, and refreshes the cache every hour by default. You can use service config :xxxxxxx.xx.sdk.device.mobileCDN.cacheRefresh to adjust the refresh frequency.
Refresh is executed by a GET call to:
https://xxxxx-1-0.inventory.xxx.xxxx.com:8443/v2/artifact/cdn
To parse the response to convert to a CDN mapping use: Map(key -> cdnTag)
Map key can be either "default", "someCarrierID_carrier" or "someDeviceID_deviceid"; Map value is the cdnTag name.
Deciding which CDN tag to use
For mobile apps, during bootup call. The service will search for the cdnTag to use in the following order. The mobile deviceid (guci) and the carrier is used in the CDN search.
Custom(deviceid) -> Carrier -> Default -> default CDN
If there is a hit in any stage of the search, the cdnTag found will be used and search will not be continued.
The default CDN is the value defined in service config: xxxxx.xx.sdk.device.mobileCDN.default. If the value is not found, the fall back is to prod_xxxx cdn tag.
How to look up CDN settings in InventoryService
To lookup current CDN settings, do a GET call to InventoryService:
GET /v2/artifact/cdn/xxxxx-mobile-app/config
OR
GET /v2/artifact/cdn
(For /v2/artifact/cdn - The response of this call is cached. To force refresh of the cache, pass in query string ?refresh=true. One use case is to check your CDN settings update just made.)
How to update CDN settings in InventoryService
To update the CDN settings in InventoryService, either create the CDN artifact (if it does not exist already), or just update existing CDN settings.
Both update and create will wipe the existing CDN setting for the id (default/carrier/custom) and replace with the new one.
To update, run a PUT call on InventoryService /v2/artifact with JSON body:
PUT /v2/artifact
Example to update custom CDN settings:
{
"kind": "cdn",
"scope": "xxxxx-mobile-app",
"family": "config",
"id": "custom",
"metadata": [
{
"cdnTag": "cdn_test",
"deviceID": [
"xxxxxxxxxxxxxxxxxxxxxxxxxx"
]
},
{
"cdnTag": "xxxx_prod_mobile_B",
"deviceID": [
"xxxxxxxx",
"xxxxxxxx"
]
}
]
}
Example to update carrier CDN settings:
{
"kind": "cdn",
"scope": "xxxxx-mobile-app",
"family": "config",
"id": "carrier",
"metadata": [
{
"cdnTag": "cdn_xxx",
"carrier": [
"xxxxx"
]
},
{
"cdnTag": "cdn_non_xxx",
"carrier": [
"xxxx",
"xxx"
]
}
]
}
To create, do a POST call on InventoryService /v2/artifact, with a multi part body payload:
content -> a dummy file, it is not used at all for CDN settings, but required by InventoryService details -> JSON for the cdn artifact to create.
Example to create "default" CDN setting: (default has single cdnTag value only)
POST /v2/artifact
Form-data
content - File - empty dummy file. unused.
details - Text
{
"kind": "cdn",
"scope": "xxxxxx-mobile-app",
"family": "config",
"id": "default",
"metadata": {
"cdnTag": "defaultCDNTag"
},
"modifiers": {
"private": "true"
}
}