export

package
v0.0.0-...-119eded Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Each

func Each(conn *sql.DB, batchSize uint, callback func(*Nameserver) error) (err error)

Each iterates over all Nameserver records and calls the callback for each. If the callback returns an error, the iteration stops and that error is returned (note: other errors can be returned from this as well).

Types

type Exporter

type Exporter struct {
	Destination string // Destination is the output directory
	Debug       bool
	Connection  *sql.DB
	BatchSize   uint
	// contains filtered or unexported fields
}

func (*Exporter) Run

func (ex *Exporter) Run() error

Run starts the export and wait until it is finished

type Nameserver

type Nameserver struct {
	ID          int        `json:"-"`
	State       string     `json:"-"`
	IP          string     `json:"ip"`
	Name        *string    `json:"name"`
	Country     *string    `json:"country_id"`
	City        *string    `json:"city"`
	Version     *string    `json:"version"`
	Error       *string    `json:"error"`
	DNSSEC      *bool      `json:"dnssec"`
	Reliability float64    `json:"reliability"`
	CheckedAt   *time.Time `json:"checked_at"`
	CreatedAt   time.Time  `json:"created_at"`
}

Nameserver describes a database record.

func (*Nameserver) GetString

func (ns *Nameserver) GetString(attr string) string

GetString returns a string representation of the attribute given.

func (*Nameserver) IsValid

func (ns *Nameserver) IsValid() bool

IsValid tells you whether this Nameserver is valid (i.e. not "new" or "failed").

type Writer

type Writer struct {
	Channel chan *Nameserver
	// contains filtered or unexported fields
}

A Writer waites for new Nameserver instances to process and write away.

func NewWriter

func NewWriter(pathname, basename string) (*Writer, error)

NewWriter starts a new Writer life cycle. It returns a channel to which you send Nameserver instances. These are then transformed into different files (namely `${pathname}/${basename}.{txt,csv,json}`), so you need to pass in a path- and base name. When you're done, just close the done-channel and the internal caches are flushed and the files are closed.

func (*Writer) Close

func (w *Writer) Close() error

Close finishes the current Write life cycle.

func (*Writer) Count

func (w *Writer) Count() uint

Count returns the number of records written

Jump to

Keyboard shortcuts

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