Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchError ¶
type BatchError struct {
// contains filtered or unexported fields
}
A BatchError is an error that can hold multiple errors.
func (*BatchError) Add ¶
func (be *BatchError) Add(errs ...error)
Add adds errs to be, nil errors are ignored.
func (*BatchError) Err ¶
func (be *BatchError) Err() error
Err returns an error that represents all errors.
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
A ResourceManager is a manager that used to manage resources.
func NewResourceManager ¶
func NewResourceManager() *ResourceManager
NewResourceManager returns a ResourceManager.
func (*ResourceManager) Close ¶
func (manager *ResourceManager) Close() error
Close closes the manager. Don't use the ResourceManager after Close() called.
func (*ResourceManager) GetResource ¶
func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (io.Closer, error)
GetResource returns the resource associated with given key.
type SingleFlight ¶
type SingleFlight interface { Do(key string, fn func() (any, error)) (any, error) DoEx(key string, fn func() (any, error)) (any, bool, error) }
SingleFlight lets the concurrent calls with the same key to share the call result. For example, A called F, before it's done, B called F. Then B would not execute F, and shared the result returned by F which called by A. The calls with the same key are dependent, concurrent calls share the returned values. A ------->calls F with key<------------------->returns val B --------------------->calls F with key------>returns val