Documentation
¶
Index ¶
- func ConstOf[S any, T any](t T) func(S) T
- func Contextualize[CC, ERC, IRC, T any](contextualizer Contextualizer[CC, ERC, IRC, T], configCtx CC, ...) func(externalRuntimeCtx ERC) (T, error)
- func Contextualize1[CC, ERC, IRC, S1, T any](contextualizer Contextualizer[CC, ERC, IRC, T], configCtx CC, ...) func(externalRuntimeCtx ERC, s1 S1) (T, error)
- func Contextualize1V[CC, ERC, IRC, S1 any](contextualizer Contextualizer[CC, ERC, IRC, types.Unit], configCtx CC, ...) func(externalRuntimeCtx ERC, s1 S1)
- func Contextualize2[CC, ERC, IRC, S1, S2, T any](contextualizer Contextualizer[CC, ERC, IRC, T], configCtx CC, ...) func(externalRuntimeCtx ERC, s1 S1, s2 S2) (T, error)
- func Duration(msg string, start time.Time)
- func Ignore(v ...any)
- func LiftToNullary[S, T any](f func(S) T) func(func() S) func() T
- func MapToSlice[K comparable, V any](m map[K]V) []V
- func PointerOf[T any](v T) *T
- func SafeCast[T any](x any) T
- func SliceContains[T comparable](slice []T, value T) bool
- func SliceFilter[S any](xs []S, f func(S) bool) []S
- func SliceMap[S, T any](xs []S, f func(S) T) []T
- func SliceMapWithIndex[S, T any](xs []S, f func(int, S) T) []T
- func SliceReverse[S any](xs []S) []S
- func SliceToBoolSet[T comparable](s []T) map[T]bool
- func SliceToUnitSet[T comparable](s []T) map[T]types.Unit
- func SliceWindow(slice []any, limit, offset int) []any
- func Slug(title string) string
- func Sort(slice []any, less func(i, j int) bool)
- func ThunkOf[T any](t T) func() T
- func TimeLeft(deadline time.Time) time.Duration
- func Todo[T any]() T
- func Trace(name string) func()
- func Track(msg string) (string, time.Time)
- type Contextualizer
- type Uuid
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contextualize ¶
func Contextualize[CC, ERC, IRC, T any]( contextualizer Contextualizer[CC, ERC, IRC, T], configCtx CC, f func(externalRuntimeCtx ERC, internalRuntimeCtx IRC) (T, error), ) func(externalRuntimeCtx ERC) (T, error)
Contextualize returns a function that is the partial application of f within the execution context provided by contextualizer.
func Contextualize1 ¶
func Contextualize1[CC, ERC, IRC, S1, T any]( contextualizer Contextualizer[CC, ERC, IRC, T], configCtx CC, f func(externalRuntimeCtx ERC, internalRuntimeCtx IRC, s1 S1) (T, error), ) func(externalRuntimeCtx ERC, s1 S1) (T, error)
Contextualize1 returns a function that is the partial application of f within the execution context provided by contextualizer.
func Contextualize1V ¶
func Contextualize1V[CC, ERC, IRC, S1 any]( contextualizer Contextualizer[CC, ERC, IRC, types.Unit], configCtx CC, f func(externalRuntimeCtx ERC, internalRuntimeCtx IRC, s1 S1), ) func(externalRuntimeCtx ERC, s1 S1)
Contextualize1V returns a function that is the partial application of f within the execution context provided by contextualizer.
func Contextualize2 ¶
func Contextualize2[CC, ERC, IRC, S1, S2, T any]( contextualizer Contextualizer[CC, ERC, IRC, T], configCtx CC, f func(externalRuntimeCtx ERC, internalRuntimeCtx IRC, s1 S1, s2 S2) (T, error), ) func(externalRuntimeCtx ERC, s1 S1, s2 S2) (T, error)
Contextualize2 returns a function that is the partial application of f within the execution context provided by contextualizer.
func Ignore ¶
func Ignore(v ...any)
Ignore is used to remove "unused variable" compilation wrrors without having to remove the variable(s).
func LiftToNullary ¶
func LiftToNullary[S, T any](f func(S) T) func(func() S) func() T
func MapToSlice ¶
func MapToSlice[K comparable, V any](m map[K]V) []V
func SliceContains ¶
func SliceContains[T comparable](slice []T, value T) bool
func SliceFilter ¶
func SliceMapWithIndex ¶
func SliceReverse ¶
func SliceReverse[S any](xs []S) []S
func SliceToBoolSet ¶
func SliceToBoolSet[T comparable](s []T) map[T]bool
SliceToBoolSet returns a set containing the values in the receiver.
func SliceToUnitSet ¶
func SliceToUnitSet[T comparable](s []T) map[T]types.Unit
SliceToUnitSet returns a set containing the values in the receiver.
func SliceWindow ¶
func TimeLeft ¶
TimeLeft converts a deadline to a timeout by subtracting the current time from the deadline. If the difference is negative, it returns zero.
Types ¶
type Contextualizer ¶
type Contextualizer[CC, ERC, IRC, T any] func( configCtx CC, externalRuntimeCtx ERC, block func(externalRuntimeCtx ERC, internalRuntimeCtx IRC) (T, error), ) (T, error)
Contextualizer represents a higher-order function that executes another function within a context. An example is a function that executes a target function while delimiting the target function within a transaction.
- configCtx represents configuration data that is passed to the higher-orfer function. For example, a database object.
- externalRuntimeCtx represents a runtime context input for use by both the Contextualizer and the target function. For example, context.Context.
- internalRuntimeCtx is a runtime argument produced by the Contextualizer and passed to the target function. For example, a transaction object.