Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenStringer ¶
OpenStringer is an Opener which also has a String method which should return the name of the resource being opened (e.g. a file or URL).
type Opener ¶
type Opener interface {
Open() (io.ReadCloser, error)
}
Opener is an interface to a resource which can be repeatedly Opened (and the returned ReadCloser can be subsequently read). Each call to Open should return a ReadCloser which reads from the beginning of the resource. In the case of an error while reading, Open will be called again to retry reading the entire resource.
type Option ¶
type Option func(*Source)
Option is a functional option to pass to NewSource.
func WithConcurrency ¶
WithConcurrency returns an Option which sets the number of goroutines fetching files simultaneously.
func WithMaxRetries ¶
WithMaxRetries returns an Option which sets the max number of retries per file on a Source.
func WithOpenStringers ¶
func WithOpenStringers(os []OpenStringer) Option
WithOpenStringers returns an Option which adds the slice of OpenStringers to the set of data sources a Source will read from.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source satisfies the PDK.Source interface for CSV data. Each line in a CSV file will be returned by a call to record as a map[string]string where the keys are taken from the first line of the CSV. Source is safe for concurrent use.
The Source takes care of retrying failed reads/downloads and making sure not to return duplicate data. TODO: this functionality needs more testing.
func NewSource ¶
NewSource creates a pdk.Source for CSV data. The source of the raw data can be set by using Options defined in this package. e.g.
src := NewSource(WithURLs([]string{"myfile1.csv", "myfile2.csv", "http://example.com/myfile3.csv"}))