func (f *Factory) Make(name string) (interface{}, error) {
	var err error
	conn, err, _ := f.group.Do(name, func() (interface{}, error) {
		if slot, ok := f.cache.Load(name); ok {
			return slot.(Pair).Conn, nil
		}
		slot, err := f.constructor(name)
		if err != nil {
			return nil, err
		}
		f.cache.Store(name, slot)
		return slot.Conn, nil
	})
	if err != nil {
		return nil, err
	}
	return conn, nil
}
Make creates an instance under the provided name. It an instance is already
created and it is not nil, that instance is returned to the caller.
package di
import (
	"context"
	"reflect"
	"runtime"
	"sync"
	"golang.org/x/sync/singleflight"
	"github.com/DoNewsCode/core/contract"
	"github.com/DoNewsCode/core/events"
)
type Pair struct {
	Conn   interface{}
	Closer func()
}
type Factory struct {
	group       singleflight.Group
	cache       sync.Map
	constructor func(name string) (Pair, error)
	reloadOnce  sync.Once
}
func NewFactory(constructor func(name string) (Pair, error)) *Factory {
	return &Factory{
		constructor: constructor,
	}
}