providers

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IOModeInput file can be used for input.
	IOModeInput = IOMode(1 << iota)

	// IOModeOutput file can be used for output.
	IOModeOutput

	// IOModeError file can be used for errors.
	IOModeError

	// IOModeTruncate file should be truncated.
	IOModeTruncate

	// IOModeAppend file should be appended to.
	IOModeAppend

	// IOModeNone is the default empty mde.
	IOModeNone = IOMode(0)
)
View Source
const (
	// LogInfo is an informational level of logging.
	LogInfo = Severity(iota)
	// LogWarn is a warning level of logging.
	LogWarn
	// LogError is an error level of logging.
	LogError
)

Variables

This section is empty.

Functions

func NewIdempotentCloser

func NewIdempotentCloser(closer io.Closer) io.Closer

NewIdempotentCloser creates a closer that calls the underlying closer once only.

Types

type CloserList

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

CloserList is a list of io.Closers.

func NewCloserList

func NewCloserList(items ...interface{}) *CloserList

NewCloserList creates a new closer list.

func (*CloserList) Append

func (cl *CloserList) Append(items ...interface{}) *CloserList

Append a closer or slice of closers to the closerlist.

func (*CloserList) Close

func (cl *CloserList) Close() error

Close closes all closers in the list returning all errors as a single error.

type FileDetailer added in v0.2.1

type FileDetailer interface {

	// URL returns the url
	URL() *url.URL

	// FilePath returns the os path to the file
	FilePath() string

	// IOMode is th eio moe supported by the file
	IOMode() IOMode

	// File mode is the file's permission mask
	FileMode() os.FileMode

	// InMode returns true if the mode is supported by the file
	InMode(mode IOMode) bool
}

FileDetailer provides details on a file based resource provider.

type IOMode

type IOMode uint32

IOMode indicates the modes of operation the file detail supports.

func (IOMode) String

func (mode IOMode) String() string

String converts IOMode to a string representation.

type LineFunc

type LineFunc func(string)

LineFunc is a callback function type that is called per line written to a line provider.

func (LineFunc) OpenRead

func (lf LineFunc) OpenRead(ctx context.Context) (io.ReadCloser, error)

OpenRead returns an error if called as reads are not possible from a line provider.

func (LineFunc) OpenWrite

func (lf LineFunc) OpenWrite(ctx context.Context) (io.WriteCloser, error)

OpenWrite opens resource for writing.

type ResourceID

type ResourceID string

ResourceID is a the ID of a resource.

type ResourceProvider

type ResourceProvider interface {
	OpenRead(ctx context.Context) (io.ReadCloser, error)
	OpenWrite(ctx context.Context) (io.WriteCloser, error)
}

ResourceProvider creates resources. Implementers must implement both functions but can return an error for un supported requests. For example a Web Getter cannot be opened for writes so should return an error. All resources returned without an error should expect Close to be called on the ReadCloser or WriteCloser.

func NewFileProvider

func NewFileProvider(path string, ioMode IOMode, fileMode os.FileMode, optional bool) (ResourceProvider, error)

NewFileProvider creates a file provider.

func NewLineProvider

func NewLineProvider(fn func(string)) ResourceProvider

NewLineProvider writes lines of text to a output function.

func NewLogProvider

func NewLogProvider(log loggee.Logger, severity Severity) ResourceProvider

NewLogProvider creates provider that writes to a log.

func NewNonClosingReaderProvider

func NewNonClosingReaderProvider(reader io.Reader) ResourceProvider

NewNonClosingReaderProvider attaches an existing reader (i.e. stdin) to a provider.

func NewNonClosingWriterProvider

func NewNonClosingWriterProvider(writer io.Writer) ResourceProvider

NewNonClosingWriterProvider attaches an existing writer (i.e. stdout) to a provider.

func NewURLProvider

func NewURLProvider(url string, timeout time.Duration, optional bool) (ResourceProvider, error)

NewURLProvider creates a url provider.

type ResourceProviderMap

type ResourceProviderMap map[ResourceID]ResourceProvider

ResourceProviderMap is a map collection of resource prooviders.

func (ResourceProviderMap) Copy

Copy creates a copy of a resource map.

type Severity

type Severity int

Severity is the level to log messages at in a log provider.

Jump to

Keyboard shortcuts

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