Documentation
¶
Overview ¶
Package limit provides means to limit the duration of functions It is meant to complement samber/lo utilities like Attempt and WaitFor .
Functions in this package pair well with lang.ReaderContains or regexp.MatchReader which are not context-aware and can take a long time, especially on slow or unbounded readers like process pipes or network streams.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithTimeout ¶
WithTimeout attempts to run the given context-unaware function within the given timeout duration. Use WithinCtx directly if there is parent context or the function is context-aware.
func WithinCtx ¶
WithinCtx attempts to run the given function until the context expires. The function itself can, optionally, limit its own execution on the same context. Returns the result of the function and whether the function completed while the context was valid. Functions with multiple return values can use samber/lo Tuples to pack them.
This utility can turn a function which is not context-aware, or only partially so, into a strictly context-aware one. Additionally, in combination with context.WithDeadline, it can put time limits on execution attempts.
Types ¶
This section is empty.