Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Use ¶
func Use(o ResourceOpener, input string) (rerr error)
Use opens a resource, calls Frob(input) on the result resource and then closes that resource (in all cases).
Types ¶
type FrobError ¶
type FrobError struct {
// contains filtered or unexported fields
}
FrobError is a possible error from doing some frobbing, your implementation will require calling your Resource's Defrob(string) method. When this error occurs, the FrobError's defrobTag string will contain the string you must pass into Defrob.
type Resource ¶
type Resource interface { // Resource is using composition to inherit the requirements of the io.Closer // interface. What this means is that a Resource implementation will be // expected to have a .Close() method too. io.Closer // Frob does something with the input string. // Because this is an incredibly badly designed system if there is an error // it panics. // // The panicked error may be a FrobError in which case Defrob should be // called with the .defrobTag string property of the error. Frob(string) Defrob(string) }
Resource represents abstract resource with close and frob methods.
type ResourceOpener ¶
ResourceOpener is a function that creates a resource.
It may return a wrapped error of type TransientError. In this case the resource is temporarily unavailable and the caller should retry soon.
type TransientError ¶
type TransientError struct {
// contains filtered or unexported fields
}
TransientError is an error that may occur while opening a resource via ResourceOpener.
func (TransientError) Error ¶
func (e TransientError) Error() string