singleflight

package
v0.52.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT, Apache-2.0 Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package singleflight based on github.com/golang/groupcache/singleflight

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

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

Call represents single deduplicated function call.

func (*Call) Do

func (c *Call) Do(fn func() interface{}) interface{}

type Group

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

Group represents a class of work and forms a namespace in which units of work can be executed with duplicate suppression.

func (*Group) Do

func (g *Group) Do(key interface{}, fn func() interface{}) interface{}

Do executes and returns the results of the given function, making sure that only one execution is in-flight for a given key at a time. If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results.

func (*Group) DoAsync

func (g *Group) DoAsync(key interface{}, fn func() interface{})

DoAsync used instead of Do, when there is not need to wait for result. It behaves like go { Group.Do(key, fn) }(), but doesn't create goroutine when there is another execution for given key in-flight.

Jump to

Keyboard shortcuts

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