flex

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodRegex Method = iota
	MethodGlob
	KeyRRNames Key = iota
	KeyRData
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Search(method Method, key Key, value string) Query
}

type HttpResultFunc

type HttpResultFunc func(ctx context.Context, req *http.Request) Result

type Key

type Key int

func (Key) String

func (k Key) String() string

type Method

type Method int

func (Method) String

func (m Method) String() string

type Query

type Query interface {
	// WithRRType sets the rrtype for the query. The default value is ANY.
	WithRRType(rrtype string) Query

	WithExclude(exclude string) Query

	// WithLimit sets the limit for the number of results returned.
	WithLimit(n int) Query

	// WithOffset sets how many rows to skip in the results. This is only applicable to Lookup queries
	// and the API server may return an error if it is set for a Summarize query.
	WithOffset(n int) Query

	// WithTimeFirstBefore selects records with time_first that is before `when`.
	WithTimeFirstBefore(when time.Time) Query
	// WithTimeFirstAfter selects records with time_first that is after `when`.
	WithTimeFirstAfter(when time.Time) Query
	// WithTimeLastBefore selects records with time_last that is before `when`.
	WithTimeLastBefore(when time.Time) Query
	// WithTimeLastAfter selects records with time_last that is after `when`.
	WithTimeLastAfter(when time.Time) Query

	// WithRelativeTimeFirstBefore selects records with time_first that is before now - `since`.
	WithRelativeTimeFirstBefore(since time.Duration) Query
	// WithRelativeTimeFirstAfter selects records with time_first that is after now - `since`.
	WithRelativeTimeFirstAfter(since time.Duration) Query
	// WithRelativeTimeLastBefore selects records with time_last that is before now - `since`.
	WithRelativeTimeLastBefore(since time.Duration) Query
	// WithRelativeTimeLastAfter selects records with time_last that is after now - `since`.
	WithRelativeTimeLastAfter(since time.Duration) Query

	Do(ctx context.Context) Result
}

func NewQuery

func NewQuery(method Method, key Key, value string, url *url.URL, headers http.Header, result HttpResultFunc) Query

type Record

type Record struct {
	RRName    string    `json:"rrname,omitempty"`
	RData     string    `json:"rdata,omitempty"`
	RawRData  []byte    `json:"raw_rdata,omitempty"`
	RRType    string    `json:"rrtype,omitempty"`
	Count     int       `json:"count,omitempty"`
	TimeFirst time.Time `json:"time_first,omitempty"`
	TimeLast  time.Time `json:"time_last,omitempty"`
}

func (Record) MarshalJSON

func (r Record) MarshalJSON() ([]byte, error)

func (*Record) UnmarshalJSON

func (r *Record) UnmarshalJSON(data []byte) error

type Result

type Result interface {
	// Close terminates the query and closes the channel returned by `Ch()`
	Close()
	// Ch returns a channel with the results of the query.
	Ch() <-chan Record
	// Err should be called after the channel has been closed to check if any errors have occurred.
	Err() error
}

Jump to

Keyboard shortcuts

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