github.com/Jeffail/benthos/v3@v3.65.0/internal/interop/plugins/package.go (about) 1 // Package plugins provides a way to have the new components for plugins-v2 able 2 // to access and "pull" the old style plugins without introducing cyclic 3 // dependencies. This is pretty gross. 4 // 5 // TODO: V4 Remove this 6 package plugins 7 8 import ( 9 "sync" 10 ) 11 12 var mut sync.Mutex 13 14 // Documentation is only concerned with the name and component type of old 15 // plugins 16 var nameTypes [][2]string 17 18 // FlushNameTypes walks each registered plugin name and type and removes them. 19 func FlushNameTypes(fn func(nt [2]string)) { 20 mut.Lock() 21 defer mut.Unlock() 22 for _, nt := range nameTypes { 23 fn(nt) 24 } 25 nameTypes = nil 26 } 27 28 // Add an old style plugin to docs. 29 func Add(name, ctype string) { 30 mut.Lock() 31 defer mut.Unlock() 32 nameTypes = append(nameTypes, [2]string{name, ctype}) 33 }