reader

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextReader

type ContextReader interface {
	// Get reads from the url and returns DefaultClient errors
	// This operation's deadline and cancellation depends on ctx
	// You should close the Body when you finished reading from it
	Get(ctx context.Context) (*http.Response, error)
}

ContextReader reads from the url with the specified context

type CtxReader

type CtxReader struct {
	// contains filtered or unexported fields
}

CtxReader implements ContextReader interface

func NewCtxReader

func NewCtxReader(url string) *CtxReader

NewCtxReader requires a sanitised url

func (*CtxReader) Get

func (c *CtxReader) Get(ctx context.Context) (*http.Response, error)

Get uses GET verb for retreiving the data TODO: implement other verbs

type MockCtxReader

type MockCtxReader struct {
	ContextReadFunc func(ctx context.Context) (*http.Response, error)
	// contains filtered or unexported fields
}

func NewMockCtxReader

func NewMockCtxReader(url string) *MockCtxReader

func (*MockCtxReader) Get

func (m *MockCtxReader) Get(ctx context.Context) (*http.Response, error)

type MockExpvarReader

type MockExpvarReader struct {
	StartFunc func() chan struct{}
	// contains filtered or unexported fields
}

func NewMockExpvarReader

func NewMockExpvarReader(jobs chan context.Context, resCh chan *ReadJobResult, f func(context.Context)) *MockExpvarReader

func (*MockExpvarReader) JobChan

func (m *MockExpvarReader) JobChan() chan context.Context

func (*MockExpvarReader) ResultChan

func (m *MockExpvarReader) ResultChan() chan *ReadJobResult

func (*MockExpvarReader) Start

func (m *MockExpvarReader) Start() chan struct{}

type ReadJob

type ReadJob struct {
	Ctx context.Context
	Err chan error
}

ReadJob is sent with a context and a channel to read the errors

type ReadJobResult

type ReadJobResult struct {
	Time time.Time
	Res  io.ReadCloser
	Err  error
}

ReadJobResult is constructed everytime a new record is fetched. The time is set after the request was successfully read

type TargetReader

type TargetReader interface {
	// The engine will send a signal to this channel to inform the reader when to read from the target.
	// The engine never blocks if the reader is not able to process the requests. It is the reader's job to provide large enough
	// channel, otherwise it will cause goroutine leakage.
	// The context might be canceled depending how the user sets the timeouts.
	JobChan() chan context.Context

	// The engine runs the reading job in another goroutine. Therefore it is the reader's job not to send send a lot of results back
	// to the engine, otherwise it might cause crash on readers and the application itself.
	ResultChan() chan *ReadJobResult

	// The reader's loop should be inside a goroutine, and return a channel.
	// This channel should be closed one it's work is finished and wants to quit.
	Start() chan struct{}

	Name() string
}

TargetReader recieves job requests to read from the target, and returns its success results with in a JobResult channel.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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