Update polling interval example of using 51Degrees IP intelligence.
This example shows how to use 51Degrees on-premise IP intelligence to process IP address before and after IPI file will be updated.
This example is available in full on GitHub.
In detail, the example shows how to
1. Specify config for engine:
This setting specifies the performance profile that will be used when initializing the C library.
config := ipi_interop.NewConfigIpi(ipi_interop.InMemory)
2. Initialization of the engine with the following parameters:
//Create on-premise engine
engine, err := ipi_onpremise.New(
// Optimized config provided
ipi_onpremise.WithConfigIpi(config),
// Path to your data file
ipi_onpremise.WithDataFile(params.DataFile),
// WithLicenseKey sets the license key to use when pulling the data file
// A license key can be obtained with a subscription from https://51degrees.com/pricing
ipi_onpremise.WithLicenseKey(params.LicenseKey),
// WithAutoUpdate enables or disables auto update
ipi_onpremise.WithAutoUpdate(true),
// Set the frequency in minutes that the pipeline should
// check for updates to data files. A recommended
// polling interval in a production environment is
// around 30 minutes.
ipi_onpremise.WithPollingInterval(3),
// Set the max amount of time in seconds that should be
// added to the polling interval. This is useful in datacenter
// applications where multiple instances may be polling for
// updates at the same time. A recommended amount in production
// environments is 600 seconds.
ipi_onpremise.WithRandomization(1),
// Enable update on startup, the auto update system
// will be used to check for an update before the
// device detection engine is created.
ipi_onpremise.WithUpdateOnStart(false),
// Optionally provide your own file URL
ipi_onpremise.WithDataUpdateUrl("<custom URL>"),
// By default a temp copy should be created, unless you are using InMemory performance profile
// ipi_onpremise.WithTempDataCopy(false),
// File System Watcher is by default enabled
// ipi_onpremise.WithFileWatch(false),
// By default logging is on
// ipi_onpremise.WithLogging(false),
// Custom logger implementing LogWriter interface can be passed
// ipi_onpremise.WithCustomLogger()
// Set properties for checking, default is [] = all properties
// ipi_onpremise.WithProperties([]string{}),
)