I will call a function to build a BOSH connection using go functionABC()
.
In the function, I will keep the status of the connection by sending ping information. So, there may be a lot of functionABC()
calls. So now, if I want to get some information from the function, can I have some way to identify the function by function ID or process ID? Does Go have function ID's or process ID's to identify a function?
If so, how can I communicate with this function? If not, does there exist any alternative way to accomplish it?
Maybe use a map
and return a unique id/connection from your function and assign it to the map, something like this:
var counter uint64
func ReturnStuff() (uint64, net.Conn) {
return atomic.AddUint64(&counter, 1), nil
}
var m = map[uint64]net.Conn{}
func main() {
for i := 0; i < 10; i++ {
id, conn := ReturnStuff()
m[id] = conn
}
fmt.Printf("%+v", m)
}