Documentation ¶
Index ¶
- Constants
- func NewIdempotentCloser(closer io.Closer) io.Closer
- type CloserList
- type FileDetailer
- type IOMode
- type LineFunc
- type ResourceID
- type ResourceProvider
- func NewFileProvider(path string, ioMode IOMode, fileMode os.FileMode, optional bool) (ResourceProvider, error)
- func NewLineProvider(fn func(string)) ResourceProvider
- func NewLogProvider(log loggee.Logger, severity Severity) ResourceProvider
- func NewNonClosingReaderProvider(reader io.Reader) ResourceProvider
- func NewNonClosingWriterProvider(writer io.Writer) ResourceProvider
- func NewURLProvider(url string, timeout time.Duration, optional bool) (ResourceProvider, error)
- type ResourceProviderMap
- type Severity
Constants ¶
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) )
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 ¶
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 LineFunc ¶
type LineFunc func(string)
LineFunc is a callback function type that is called per line written to a line provider.
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 ¶
NewURLProvider creates a url provider.
type ResourceProviderMap ¶
type ResourceProviderMap map[ResourceID]ResourceProvider
ResourceProviderMap is a map collection of resource prooviders.
func (ResourceProviderMap) Copy ¶
func (m ResourceProviderMap) Copy() ResourceProviderMap
Copy creates a copy of a resource map.