Documentation ¶
Index ¶
- func ContextRoundTripper(ctx context.Context, rt http.RoundTripper) http.RoundTripper
- func JoinURL(base, suffix string) (string, error)
- func LoadLocation(name string) (*time.Location, error)
- func WrapCacheableContext(next http.Handler) http.Handler
- type AlignedTicker
- type ContextCache
- type ContextPreparer
- type ContextWaitGroup
- type Prepare
- type PrepareStmt
- type Preparer
- type QueryError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextRoundTripper ¶
func ContextRoundTripper(ctx context.Context, rt http.RoundTripper) http.RoundTripper
ContextRoundTripper will return an http.RoundTripper that will replace all request contexts with the provided one. This means that values and deadlines for all requests will be bound to the original context.
func JoinURL ¶
JoinURL will join a base URL and suffix, taking care to preserve and merge query parameters.
func LoadLocation ¶
LoadLocation works like time.LoadLocation but caches the result for the life of the process.
Types ¶
type AlignedTicker ¶
AlignedTicker works like a time.Ticker except it will align the first tick. This makes it useful in situations where something should run on-the-minute for example.
func NewAlignedTicker ¶
func NewAlignedTicker(round, variance time.Duration) *AlignedTicker
NewAlignedTicker will create and start a new AlignedTicker. The first tick will be adjusted to round, with variance added.
For example (time.Minute, time.Second) will align ticks to on-the-minute plus 0-1 second.
func (*AlignedTicker) Stop ¶
func (a *AlignedTicker) Stop()
Stop will stop the running ticker and close the channel.
type ContextCache ¶
type ContextCache interface { Load(ctx context.Context, id string) interface{} Store(ctx context.Context, id string, value interface{}) LoadOrStore(context.Context, string, func() (interface{}, error)) (interface{}, error) }
A ContextCache is used to cache and load values on a per-context basis. No values will be stored unless the context.Context has passed through WrapCacheableContext.
func NewContextCache ¶
func NewContextCache() ContextCache
NewContextCache creates a new ContextCache
type ContextPreparer ¶
type ContextWaitGroup ¶
type ContextWaitGroup struct {
// contains filtered or unexported fields
}
func NewContextWaitGroup ¶
func NewContextWaitGroup(ctx context.Context) *ContextWaitGroup
func (*ContextWaitGroup) Add ¶
func (c *ContextWaitGroup) Add(n int)
func (*ContextWaitGroup) Done ¶
func (c *ContextWaitGroup) Done()
func (*ContextWaitGroup) Wait ¶
func (c *ContextWaitGroup) Wait()
func (*ContextWaitGroup) WaitCh ¶
func (c *ContextWaitGroup) WaitCh() <-chan struct{}
type Prepare ¶
Prepare is used to prepare SQL statements.
If Ctx is specified, it will be used to prepare all statements. Only the first error is recorded. Subsequent calls to `P` are ignored after a failure.
type PrepareStmt ¶
func (*PrepareStmt) PrepareFor ¶
func (p *PrepareStmt) PrepareFor(ctx context.Context, cp ContextPreparer) (*sql.Stmt, error)