# DeviceAtlas Carrier Detection API Config # Carrier Detection API Config provides options to customize the way the API behaves in terms of memory use and device properties. ## Contents ## * [DaConfig type](#config_type) * [How it works](#how_it_works) * [Configuration examples](#config_examples) * [General tips](#general_tips) <a name="config_type"></a> ### Config Type ### * [Real Ip](#RealIp) <a name="RealIp"></a> #### Real IP #### Boolean value to enable/disable the addition of the IP address used during the detection. User-Agent/Dynamic properties: `realip` **Config field:** `DaConfig.RealIp` **Possible values:** true/false **Default Value:** false <a name="how_it_works"></a> ### How it works ### This section describes how to use the `DaConfig` type to modify the behavior of the `deviceatlas.device.DaGo` instance when performing the device properties lookup. <a name="use_default_settings"></a> #### Use of the default settings #### When a new instance of the `deviceatlas.device.DaGo` is created, internally another instance of the `DaConfig` type is generated with the default settings. ```go da := device.New() defer da.Free() ``` <a name="use_custom_settings"></a> #### Use of custom settings #### In order to use custom settings, it is required to explicitly create a `DaConfig` object, configure the settings and pass it to the `deviceatlas.device.DaGo` instance. **Preferred method** ```go config := &carrier.DaConfig{RealIp: true} da := device.New() defer da.Free() da.Config(config) ... alternatively ... config := &device.DaConfig{RealIp: true} da := device.NewWithConfig(config) defer da.Free() ``` <a name="config_examples"></a> ### Configuration examples ### In order to enhance performance, reduce memory footprint and, in general, provide a better user experience, it is highly recommended to configure the API with the most convenient settings for a given use case. ```go var config *carrier.DaConfig config = carrier.NewConfig() config.RealIp = true ``` <a name="general_tips"></a> ### General tips ### <a name="batch_processing"></a> #### Maximizing CPU utilization #### The latest version of the carrier API runs without problems in a multi-process environment, however custom code must be created to access the API in a multi-process way to achieve the optimal hardware utilization. The following are general recommendations to obtain optimal results from the hardware: * A single carrier API instance can be used in a goroutine context. * The default GOMAXPROCS value can be used or can be adjusted to use a subset of available cores. * The recommended number of concurrent processes should not be greater than the number of cores in the system. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ Copyright (c) DeviceAtlas 2022. All Rights Reserved. _ https://deviceatlas.com <!-- HTML+JS for document formatting when opened in browser --> <div class="btn-group" id="main-menu" style="float:right"><a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Menu<span class="caret"></span></a><ul class="dropdown-menu"><li><a href="README.html">Main</a></li><li><a href="README.DeviceApi.html">Building dependencies and API</a></li><li><a href="README.DeviceApi-Web.html">Device Detection for Web</a></li><li><a href="README.DeviceApi-Apps.html">Device Detection for Apps</a></li><li><a href="./ApiDocs/device.html">Device API Docs</a></li><li class="divider"></li><li><a href="README.DeviceApi-Config.html">Device Detection API Config</a></li><li><a href="README.Upgrade.html">Device Detection API Upgrade</a></li><li class="divider"></li><li><a href="README.CarrierApi.html">Carrier Identification API</a></li><li><a href="./ApiDocs/carrier.html">Carrier API Docs</a></li><li class="divider"></li><li class="disabled"><a href="README.CarrierApi-Config.html">Carrier Detection API Config</a></li></ul></div>