resource

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MulanPSL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	SharedCalls SharedCalls
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Get

func (m *Manager) Get(key string, create func() (io.Closer, error)) (io.Closer, error)

type SharedCalls

type SharedCalls interface {
	Do(key string, fn func() (interface{}, error)) (interface{}, error)
	DoEx(key string, fn func() (interface{}, error)) (interface{}, bool, error)
}

SharedCalls lets the concurrent calls with the same key to share the call result. When A and B concurrently request the same key, A and B will share the same result. Before the end of A request, B request comes, B will not execute, only wait for the result of A,

func NewSharedCalls

func NewSharedCalls() SharedCalls

Jump to

Keyboard shortcuts

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