sourcer

package
v0.0.0-...-22f70c5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package sourcer provides abstractions for accessing various data repositories in an iterative manner. It defines interfaces for data sources and data sourcers which can be implemented to read and iterate over data from different repositories.

Index

Constants

This section is empty.

Variables

View Source
var (
	SourceTypeValue = map[string]SourceType{
		"unspecified": SourceTypeUnspecified,
		"filesystem":  SourceTypeFilesystem,
	}

	SourceTypeString = map[SourceType]string{
		SourceTypeUnspecified: "unspecified",
		SourceTypeFilesystem:  "filesystem",
	}
)
View Source
var NilSource = nilSource{
	ReadCloser: io.NopCloser(nil),
}

NilSource is a no-op sentinel Source.

Functions

This section is empty.

Types

type Source

type Source interface {
	io.ReadCloser

	// Name returns the name of the source.
	Name() string

	// CreateTime returns the time when the source was created.
	CreateTime() time.Time

	// UpdateTime returns the time when the source was last modified.
	UpdateTime() time.Time
}

Source is a data source that can be read from.

type SourceType

type SourceType int
const (
	SourceTypeUnspecified SourceType = iota
	SourceTypeFilesystem
)

type Sourcer

type Sourcer interface {
	// Next returns the next piece of data to be parsed.
	Next() (Source, error)

	// Remaining returns the number of pieces of data remaining to be parsed.
	Remaining() int

	// Size returns the total number of pieces of data to be parsed.
	Size() int
}

Sourcer is an iterator that provides data to be parsed.

type SourcerMock

type SourcerMock struct {
	// NextFunc mocks the Next method.
	NextFunc func() (Source, error)

	// RemainingFunc mocks the Remaining method.
	RemainingFunc func() int

	// SizeFunc mocks the Size method.
	SizeFunc func() int
	// contains filtered or unexported fields
}

SourcerMock is a mock implementation of Sourcer.

func TestSomethingThatUsesSourcer(t *testing.T) {

	// make and configure a mocked Sourcer
	mockedSourcer := &SourcerMock{
		NextFunc: func() (Source, error) {
			panic("mock out the Next method")
		},
		RemainingFunc: func() int {
			panic("mock out the Remaining method")
		},
		SizeFunc: func() int {
			panic("mock out the Size method")
		},
	}

	// use mockedSourcer in code that requires Sourcer
	// and then make assertions.

}

func (*SourcerMock) Next

func (mock *SourcerMock) Next() (Source, error)

Next calls NextFunc.

func (*SourcerMock) NextCalls

func (mock *SourcerMock) NextCalls() []struct {
}

NextCalls gets all the calls that were made to Next. Check the length with:

len(mockedSourcer.NextCalls())

func (*SourcerMock) Remaining

func (mock *SourcerMock) Remaining() int

Remaining calls RemainingFunc.

func (*SourcerMock) RemainingCalls

func (mock *SourcerMock) RemainingCalls() []struct {
}

RemainingCalls gets all the calls that were made to Remaining. Check the length with:

len(mockedSourcer.RemainingCalls())

func (*SourcerMock) Size

func (mock *SourcerMock) Size() int

Size calls SizeFunc.

func (*SourcerMock) SizeCalls

func (mock *SourcerMock) SizeCalls() []struct {
}

SizeCalls gets all the calls that were made to Size. Check the length with:

len(mockedSourcer.SizeCalls())

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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