filter

package
v2.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 0 Imported by: 36

Documentation

Overview

Package filter contains definitions for NS1 filter chains.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config map[string]interface{}

Config is a flat mapping where values are simple (no slices/maps).

type Filter

type Filter struct {
	Type     string `json:"filter"`
	Disabled bool   `json:"disabled,omitempty"`
	Config   Config `json:"config"`
}

Filter wraps the values of a Record's "filters" attribute

func NewGeofenceCountry

func NewGeofenceCountry(rmNoLoc bool) *Filter

NewGeofenceCountry returns a filter that fences using "country", "us_state", and "ca_province" metadata fields in answers. Only answers in the same country/state/province as the user (or answers with no specified location) are returned. rmNoLoc determines whether to remove answers without location on any match.

func NewGeofenceRegional

func NewGeofenceRegional(rmNoGeo bool) *Filter

NewGeofenceRegional returns a filter that restricts to answers in same geographical region as requester. rmNoGeo determines whether to remove answers without georegion on any match.

func NewGeotargetCountry

func NewGeotargetCountry() *Filter

NewGeotargetCountry returns a filter that sorts answers by distance to requester by country, US state, and/or Canadian province.

func NewGeotargetLatLong

func NewGeotargetLatLong() *Filter

NewGeotargetLatLong returns a filter that sorts answers by distance to user using lat/long.

func NewGeotargetRegional

func NewGeotargetRegional() *Filter

NewGeotargetRegional returns a filter that sorts answers by distance to user by geographical region.

func NewIPv4PrefixShuffle

func NewIPv4PrefixShuffle(n int) *Filter

NewIPv4PrefixShuffle returns a filter that randomly selects IPv4 addresses from prefix list. This filter can only be used A records. n is the number of IPs to randomly select per answer.

func NewNetfenceASN

func NewNetfenceASN(rmNoASN bool) *Filter

NewNetfenceASN returns a filter that restricts to answers where the ASN of requester IP matches ASN list. rmNoASN determines whether to remove answers without asn list on any match.

func NewNetfencePrefix

func NewNetfencePrefix(rmNoIPPrefix bool) *Filter

NewNetfencePrefix returns a filter that restricts to answers where requester IP matches prefix list. rmNoIPPrefix determines whether to remove answers without ip prefixes on any match.

func NewPriority

func NewPriority() *Filter

NewPriority returns a filter that fails over according to prioritized answer tiers.

func NewSelFirstN

func NewSelFirstN(n int) *Filter

NewSelFirstN returns a filter that eliminates all but the first N answers from the list.

func NewSelFirstRegion

func NewSelFirstRegion() *Filter

NewSelFirstRegion returns a filter that keeps only the answers that are in the same region as the first answer.

func NewShedLoad

func NewShedLoad(metric string) *Filter

NewShedLoad returns a filter that "sheds" traffic to answers based on load, using one of several load metrics. You must set values for low_watermark, high_watermark, and the configured load metric, for each answer you intend to subject to load shedding.

func NewShuffle

func NewShuffle() *Filter

NewShuffle returns a filter that randomly sorts the answers.

func NewSticky

func NewSticky(byNetwork bool) *Filter

NewSticky returns a filter that sorts answers uniquely depending on the IP address of the requester. The same requester always gets the same ordering of answers. byNetwork indicates whether to apply the 'stickyness' by subnet(not individual IP).

func NewStickyRegion

func NewStickyRegion(byNetwork bool) *Filter

NewStickyRegion first sorts regions uniquely depending on the IP address of the requester, and then groups all answers together by region. The same requester always gets the same ordering of regions, but answers within each region may be in any order. byNetwork indicates whether to apply the 'stickyness' by subnet(not individual IP).

func NewUp

func NewUp() *Filter

NewUp returns a filter that eliminates all answers where the 'up' metadata field is not true.

func NewWeightedShuffle

func NewWeightedShuffle() *Filter

NewWeightedShuffle returns a filter that shuffles answers randomly based on their weight.

func NewWeightedSticky

func NewWeightedSticky(byNetwork bool) *Filter

NewWeightedSticky returns a filter that shuffles answers randomly per-requester based on weight. byNetwork indicates whether to apply the 'stickyness' by subnet(not individual IP).

func (*Filter) Disable

func (f *Filter) Disable()

Disable a filter.

func (*Filter) Enable

func (f *Filter) Enable()

Enable a filter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL