MCPcopy Create free account
hub / github.com/DoNewsCode/core / Close

Method Close

di/factory.go:90–106  ·  view source on GitHub ↗

Close closes every connection created by the factory. Connections are closed concurrently.

()

Source from the content-addressed store, hash-verified

88// Close closes every connection created by the factory. Connections are closed
89// concurrently.
90func (f *Factory) Close() {
91 var wg sync.WaitGroup
92 f.cache.Range(func(key, value interface{}) bool {
93 defer f.cache.Delete(key)
94
95 if value.(Pair).Closer == nil {
96 return true
97 }
98 wg.Add(1)
99 go func(value Pair) {
100 value.Closer()
101 wg.Done()
102 }(value.(Pair))
103 return true
104 })
105 wg.Wait()
106}
107
108// CloseConn closes a specific connection in the factory.
109func (f *Factory) CloseConn(name string) {

Callers 15

TestFactoryFunction · 0.95
TestFactory_nilCloserFunction · 0.95
httpServeMethod · 0.80
grpcServeMethod · 0.80
Example_minimalFunction · 0.80
TestC_DefaultFunction · 0.80
ProvideOpentracingFunction · 0.80
provideRedisFactoryFunction · 0.80
NewCleanupCommandFunction · 0.80
provideFactoryFunction · 0.80

Calls 3

DeleteMethod · 0.80
DoneMethod · 0.80
AddMethod · 0.45

Tested by 15

TestFactoryFunction · 0.76
TestFactory_nilCloserFunction · 0.76
Example_minimalFunction · 0.64
TestC_DefaultFunction · 0.64
setupTopicFunction · 0.64
ExampleFunction · 0.64
TestClient_DoFunction · 0.64
TestClient_OptionFunction · 0.64
TestClient_raceFunction · 0.64