lazy

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

lazy

Starts something lazy.

func ConnectDB(ctx context.Context) (*sql.DB, error) {
    db, err := sql.Open("postgres", "postgres://...")
    if err!= nil {
        return nil, err
    }
    return db, nil
}
createDB := lazy.Me(ctx, ConnectDB, WithRetry(iters.Of(time.Millisecond)))
...
v, err := connectDB(ctx)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Me

func Me[T any](ctx context.Context, creator func(ctx context.Context) (T, error), opts ...option) func(ctx context.Context) (T, error)

func WithRetry

func WithRetry(delays iter.Seq[time.Duration]) func(opts *options)

Types

This section is empty.

Jump to

Keyboard shortcuts

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