ns1-go.v2: gopkg.in/ns1/ns1-go.v2/rest/model/filter Index | Files

package filter

import "gopkg.in/ns1/ns1-go.v2/rest/model/filter"

Package filter contains definitions for NS1 filter chains.

Index

Package Files

doc.go filter.go

type Config Uses

type Config map[string]interface{}

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

type Filter Uses

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 Uses

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 Uses

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 Uses

func NewGeotargetCountry() *Filter

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

func NewGeotargetLatLong Uses

func NewGeotargetLatLong() *Filter

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

func NewGeotargetRegional Uses

func NewGeotargetRegional() *Filter

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

func NewIPv4PrefixShuffle Uses

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 Uses

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 Uses

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 Uses

func NewPriority() *Filter

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

func NewSelFirstN Uses

func NewSelFirstN(n int) *Filter

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

func NewSelFirstRegion Uses

func NewSelFirstRegion() *Filter

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

func NewShedLoad Uses

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 Uses

func NewShuffle() *Filter

NewShuffle returns a filter that randomly sorts the answers.

func NewSticky Uses

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 Uses

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 Uses

func NewUp() *Filter

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

func NewWeightedShuffle Uses

func NewWeightedShuffle() *Filter

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

func NewWeightedSticky Uses

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 Uses

func (f *Filter) Disable()

Disable a filter.

func (*Filter) Enable Uses

func (f *Filter) Enable()

Enable a filter.

Package filter is imported by 12 packages. Updated 2019-12-06. Refresh now. Tools for package owners.