hugo: Index | Files

package lazy

import ""


Package Files

init.go once.go

type Init Uses

type Init struct {
    // contains filtered or unexported fields

Init holds a graph of lazily initialized dependencies.

func New Uses

func New() *Init

New creates a new empty Init.

func (*Init) Add Uses

func (ini *Init) Add(initFn func() (interface{}, error)) *Init

Add adds a func as a new child dependency.

func (*Init) AddWithTimeout Uses

func (ini *Init) AddWithTimeout(timeout time.Duration, f func(ctx context.Context) (interface{}, error)) *Init

AddWithTimeout is same as Add, but with a timeout that aborts initialization.

func (*Init) Branch Uses

func (ini *Init) Branch(initFn func() (interface{}, error)) *Init

Branch creates a new dependency branch based on an existing and adds the given dependency as a child.

func (*Init) BranchWithTimeout Uses

func (ini *Init) BranchWithTimeout(timeout time.Duration, f func(ctx context.Context) (interface{}, error)) *Init

BranchdWithTimeout is same as Branch, but with a timeout.

func (*Init) Do Uses

func (ini *Init) Do() (interface{}, error)

Do initializes the entire dependency graph.

func (*Init) Reset Uses

func (ini *Init) Reset()

Reset resets the current and all its dependencies.

Package lazy imports 5 packages (graph) and is imported by 9 packages. Updated 2020-05-04. Refresh now. Tools for package owners.