run

package module
v0.0.0-...-54416a0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 6 Imported by: 0

README

frun

Go function on steroids.

// TODO: example and tests

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(f func(), opts ...Option) func()

func Wrap00

func Wrap00(
	f func(), opts ...Option,
) func()

Wrap00 wraps a function with 0 inputs and 0 outputs.

func Wrap01

func Wrap01[R1 any](
	f func() R1, opts ...Option,
) func() R1

Wrap01 wraps a function with 0 inputs and 1 outputs.

func Wrap02

func Wrap02[R1, R2 any](
	f func() (R1, R2), opts ...Option,
) func() (R1, R2)

Wrap02 wraps a function with 0 inputs and 2 outputs.

func Wrap10

func Wrap10[T1 any](
	f func(T1), opts ...Option,
) func(T1)

Wrap10 wraps a function with 1 inputs and 0 outputs.

func Wrap11

func Wrap11[T1, R1 any](
	f func(T1) R1, opts ...Option,
) func(T1) R1

Wrap11 wraps a function with 1 inputs and 1 outputs.

func Wrap12

func Wrap12[T1, R1, R2 any](
	f func(T1) (R1, R2), opts ...Option,
) func(T1) (R1, R2)

Wrap12 wraps a function with 1 inputs and 2 outputs.

func Wrap20

func Wrap20[T1, T2 any](
	f func(T1, T2), opts ...Option,
) func(T1, T2)

Wrap20 wraps a function with 2 inputs and 0 outputs.

func Wrap21

func Wrap21[T1, T2, R1 any](
	f func(T1, T2) R1, opts ...Option,
) func(T1, T2) R1

Wrap21 wraps a function with 2 inputs and 1 outputs.

func Wrap22

func Wrap22[T1, T2, R1, R2 any](
	f func(T1, T2) (R1, R2), opts ...Option,
) func(T1, T2) (R1, R2)

Wrap22 wraps a function with 2 inputs and 2 outputs.

func Wrap30

func Wrap30[T1, T2, T3 any](
	f func(T1, T2, T3), opts ...Option,
) func(T1, T2, T3)

Wrap30 wraps a function with 3 inputs and 0 outputs.

func Wrap31

func Wrap31[T1, T2, T3, R1 any](
	f func(T1, T2, T3) R1, opts ...Option,
) func(T1, T2, T3) R1

Wrap31 wraps a function with 3 inputs and 1 outputs.

func Wrap32

func Wrap32[T1, T2, T3, R1, R2 any](
	f func(T1, T2, T3) (R1, R2), opts ...Option,
) func(T1, T2, T3) (R1, R2)

Wrap32 wraps a function with 3 inputs and 2 outputs.

func Wrap40

func Wrap40[T1, T2, T3, T4 any](
	f func(T1, T2, T3, T4), opts ...Option,
) func(T1, T2, T3, T4)

Wrap40 wraps a function with 4 inputs and 0 outputs.

func Wrap41

func Wrap41[T1, T2, T3, T4, R1 any](
	f func(T1, T2, T3, T4) R1, opts ...Option,
) func(T1, T2, T3, T4) R1

Wrap41 wraps a function with 4 inputs and 1 outputs.

func Wrap42

func Wrap42[T1, T2, T3, T4, R1, R2 any](
	f func(T1, T2, T3, T4) (R1, R2), opts ...Option,
) func(T1, T2, T3, T4) (R1, R2)

Wrap42 wraps a function with 4 inputs and 2 outputs.

func WrapCE

func WrapCE(f func(context.Context) error, opts ...Option) func(context.Context) error

func WrapCE11

func WrapCE11(
	f func(context.Context) error, opts ...Option,
) func(context.Context) error

WrapCE11 wraps a function with 1 inputs and 1 outputs.

func WrapCE12

func WrapCE12[R1 any](
	f func(context.Context) (R1, error), opts ...Option,
) func(context.Context) (R1, error)

WrapCE12 wraps a function with 1 inputs and 2 outputs.

func WrapCE21

func WrapCE21[T2 any](
	f func(context.Context, T2) error, opts ...Option,
) func(context.Context, T2) error

WrapCE21 wraps a function with 2 inputs and 1 outputs.

func WrapCE22

func WrapCE22[T2, R1 any](
	f func(context.Context, T2) (R1, error), opts ...Option,
) func(context.Context, T2) (R1, error)

WrapCE22 wraps a function with 2 inputs and 2 outputs.

func WrapCE31

func WrapCE31[T2, T3 any](
	f func(context.Context, T2, T3) error, opts ...Option,
) func(context.Context, T2, T3) error

WrapCE31 wraps a function with 3 inputs and 1 outputs.

func WrapCE32

func WrapCE32[T2, T3, R1 any](
	f func(context.Context, T2, T3) (R1, error), opts ...Option,
) func(context.Context, T2, T3) (R1, error)

WrapCE32 wraps a function with 3 inputs and 2 outputs.

func WrapCE41

func WrapCE41[T2, T3, T4 any](
	f func(context.Context, T2, T3, T4) error, opts ...Option,
) func(context.Context, T2, T3, T4) error

WrapCE41 wraps a function with 4 inputs and 1 outputs.

func WrapCE42

func WrapCE42[T2, T3, T4, R1 any](
	f func(context.Context, T2, T3, T4) (R1, error), opts ...Option,
) func(context.Context, T2, T3, T4) (R1, error)

WrapCE42 wraps a function with 4 inputs and 2 outputs.

func WrapE

func WrapE(f func() error, opts ...Option) func() error

func WrapE01

func WrapE01(
	f func() error, opts ...Option,
) func() error

WrapE01 wraps a function with 0 inputs and 1 outputs.

func WrapE02

func WrapE02[R1 any](
	f func() (R1, error), opts ...Option,
) func() (R1, error)

WrapE02 wraps a function with 0 inputs and 2 outputs.

func WrapE11

func WrapE11[T1 any](
	f func(T1) error, opts ...Option,
) func(T1) error

WrapE11 wraps a function with 1 inputs and 1 outputs.

func WrapE12

func WrapE12[T1, R1 any](
	f func(T1) (R1, error), opts ...Option,
) func(T1) (R1, error)

WrapE12 wraps a function with 1 inputs and 2 outputs.

func WrapE21

func WrapE21[T1, T2 any](
	f func(T1, T2) error, opts ...Option,
) func(T1, T2) error

WrapE21 wraps a function with 2 inputs and 1 outputs.

func WrapE22

func WrapE22[T1, T2, R1 any](
	f func(T1, T2) (R1, error), opts ...Option,
) func(T1, T2) (R1, error)

WrapE22 wraps a function with 2 inputs and 2 outputs.

func WrapE31

func WrapE31[T1, T2, T3 any](
	f func(T1, T2, T3) error, opts ...Option,
) func(T1, T2, T3) error

WrapE31 wraps a function with 3 inputs and 1 outputs.

func WrapE32

func WrapE32[T1, T2, T3, R1 any](
	f func(T1, T2, T3) (R1, error), opts ...Option,
) func(T1, T2, T3) (R1, error)

WrapE32 wraps a function with 3 inputs and 2 outputs.

func WrapE41

func WrapE41[T1, T2, T3, T4 any](
	f func(T1, T2, T3, T4) error, opts ...Option,
) func(T1, T2, T3, T4) error

WrapE41 wraps a function with 4 inputs and 1 outputs.

func WrapE42

func WrapE42[T1, T2, T3, T4, R1 any](
	f func(T1, T2, T3, T4) (R1, error), opts ...Option,
) func(T1, T2, T3, T4) (R1, error)

WrapE42 wraps a function with 4 inputs and 2 outputs.

Types

type Chunks

type Chunks struct {
	// contains filtered or unexported fields
}

func NewChunks

func NewChunks(size, chunkSize int) *Chunks

NewChunks returns a Chunks instance that helps with splitting a slice into chunks.

Example
package main

import (
	"fmt"

	"audit/minos/internal/run"
)

func main() {
	values := make([]int, 100)
	for i := range values {
		values[i] = i
	}

	for c := run.NewChunks(len(values), 10); c.Next(); {
		chunk := values[c.Start():c.End()]
		fmt.Println(len(chunk), chunk)
	}
}
Output:

func (*Chunks) End

func (c *Chunks) End() int

End returns the end of the current chunk. End() is meant to be used as the second parameter in a slice expression.

func (*Chunks) Next

func (c *Chunks) Next() bool

Next returns whether there are remaining chunks. Typicallly this should be used with a for loop.

for c.Next() {
	list[c.Start():c.End()]
}

func (*Chunks) Start

func (c *Chunks) Start() int

Start returns the start of the current chunk.

type CtxErrFunc

type CtxErrFunc func(ctx context.Context) error

type Middleware

type Middleware func(ctx context.Context, f CtxErrFunc) error

type Option

type Option func(r *runner)

func WithConstantBackoff

func WithConstantBackoff(d time.Duration) Option

func WithExponentialBackOff

func WithExponentialBackOff(initialInterval time.Duration) Option

func WithMaxRetries

func WithMaxRetries(max uint64) Option

func WithMiddleware

func WithMiddleware(m Middleware) Option

func WithRecover

func WithRecover() Option

func WithSingleflight

func WithSingleflight() Option

func WithWaitGroup

func WithWaitGroup(wg *sync.WaitGroup) Option

Directories

Path Synopsis
internal
gen

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL