Documentation ¶
Index ¶
- Variables
- type Engine
- type EngineOptions
- func WithAutoUpdate(enabled bool) EngineOptions
- func WithConfigHash(configHash *dd.ConfigHash) EngineOptions
- func WithCustomLogger(logger LogWriter) EngineOptions
- func WithDataFile(path string) EngineOptions
- func WithDataUpdateUrl(urlStr string) EngineOptions
- func WithFileWatch(enabled bool) EngineOptions
- func WithLicenseKey(key string) EngineOptions
- func WithLogging(enabled bool) EngineOptions
- func WithMaxRetries(retries int) EngineOptions
- func WithPollingInterval(seconds int) EngineOptions
- func WithProduct(product string) EngineOptions
- func WithProperties(properties []string) EngineOptions
- func WithRandomization(seconds int) EngineOptions
- func WithTempDataCopy(enabled bool) EngineOptions
- func WithTempDataDir(dir string) EngineOptions
- func WithUpdateOnStart(enabled bool) EngineOptions
- type Evidence
- type FileResponse
- type FileWatcher
- type LogWriter
- type Watcher
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoDataFileProvided = errors.New("no data file provided") ErrTooManyRetries = errors.New("too many retries to pull data file") ErrFileNotModified = errors.New("data file not modified") ErrLicenseKeyRequired = errors.New("auto update set to true, no custom URL specified, license key is required, set it using WithLicenseKey") )
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is an implementation of the on-premise (based on a local data file) device detection. It encapsulates the automatic data file updates feature - to periodically fetch and reload the new data file. File system watcher feature allows to monitor for changes to the local data file and reload it when it changes. Custom URL can be used to fetch data files, the polling interval is configurable The 51degrees distributor service can also be used with a licenseKey For more information see With... options and examples
func New ¶
func New(opts ...EngineOptions) (*Engine, error)
New creates an instance of the on-premise device detection engine. WithDataFile must be provided to specify the path to the data file, otherwise initialization will fail
func (*Engine) GetHttpHeaderKeys ¶
func (e *Engine) GetHttpHeaderKeys() []dd.EvidenceKey
GetHttpHeaderKeys returns all HTTP headers that can be used as evidence for device detection
func (*Engine) NewResultsHash ¶ added in v4.4.38
func (e *Engine) NewResultsHash(evidenceCapacity uint32, overridesCapacity uint32) *dd.ResultsHash
Create a new raw ResultsHash object.
type EngineOptions ¶
func WithAutoUpdate ¶
func WithAutoUpdate(enabled bool) EngineOptions
WithAutoUpdate enables or disables auto update default is true if enabled, engine will automatically pull the data file from the distributor or custom URL if disabled options like WithDataUpdateUrl, WithLicenseKey will be ignored
func WithConfigHash ¶ added in v4.4.33
func WithConfigHash(configHash *dd.ConfigHash) EngineOptions
WithConfigHash allows to configure the Hash matching algorithm. See dd.ConfigHash type for all available settings: PerformanceProfile, Drift, Difference, Concurrency By default initialized with dd.Balanced performance profile dd.NewConfigHash(dd.Balanced)
func WithCustomLogger ¶
func WithCustomLogger(logger LogWriter) EngineOptions
WithCustomLogger sets a custom logger
func WithDataFile ¶
func WithDataFile(path string) EngineOptions
WithDataFile sets the path to the local data file, this parameter is required to start the engine
func WithDataUpdateUrl ¶
func WithDataUpdateUrl(urlStr string) EngineOptions
WithDataUpdateUrl sets a custom URL to download the data file from
func WithFileWatch ¶
func WithFileWatch(enabled bool) EngineOptions
WithFileWatch enables or disables file watching in case 3rd party updates the data file engine will automatically reload the data file. Default is true
func WithLicenseKey ¶
func WithLicenseKey(key string) EngineOptions
WithLicenseKey sets the license key to use when pulling the data file this option can only be used when using the default data file url from 51Degrees, it will be appended as a query parameter
func WithLogging ¶
func WithLogging(enabled bool) EngineOptions
WithLogging enables or disables the logger
func WithMaxRetries ¶
func WithMaxRetries(retries int) EngineOptions
WithMaxRetries sets the maximum number of retries to pull the data file if request fails
func WithPollingInterval ¶
func WithPollingInterval(seconds int) EngineOptions
WithPollingInterval sets the interval in seconds to pull the data file
func WithProduct ¶
func WithProduct(product string) EngineOptions
WithProduct sets the product to use when pulling the data file when distributor service is used licenseKey has to be provided using WithLicenseKey
func WithProperties ¶ added in v4.4.33
func WithProperties(properties []string) EngineOptions
WithProperties sets properties that the engine retrieves from the data file for each device detection result instance default is [] which will include all possible properties
func WithRandomization ¶
func WithRandomization(seconds int) EngineOptions
WithRandomization sets the randomization time in seconds default is 10 minutes if set, when scheduling the file pulling, it will add randomization time to the interval this is useful to avoid multiple engines pulling the data file at the same time in case of multiple engines/instances
func WithTempDataCopy ¶
func WithTempDataCopy(enabled bool) EngineOptions
WithTempDataCopy enables or disables creating a temp copy of the data file default is true if enabled, engine will create a temp copy of the data file and use it for detection rather than original data file if disabled, engine will use the original data file to initialize the manager this is useful when 3rd party updates the data file on the file system
func WithTempDataDir ¶ added in v4.4.33
func WithTempDataDir(dir string) EngineOptions
WithTempDataDir sets the directory to store the temp data file default is system temp directory
func WithUpdateOnStart ¶
func WithUpdateOnStart(enabled bool) EngineOptions
WithUpdateOnStart enables or disables update on start if enabled, engine will pull the data file from the distributor (or custom URL) once initialized default is false
type Evidence ¶
type Evidence struct { Prefix dd.EvidencePrefix Key string Value string }
Evidence struct encapsulates the evidence provided as input to the Process function Evidence is usually an HTTP header, thus Prefix would be dd.HttpHeaderString, but can also be a query param (dd.HttpEvidenceQuery) or a cookie (dd.HttpEvidenceCookie)
type FileResponse ¶
type FileResponse struct {
// contains filtered or unexported fields
}
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}