I am trying to evaluate the restriction of the functions that I call by placing them through a queue that I will access later. Below, I have a piece of queries that I created, and the requestHandler function processes each request at a certain speed.
I want it to accept all kinds of functions with different types of parameters, therefore, the {} type interface.
How can I pass functions through a channel and call them successfully?
type request struct { function interface{} channel chan interface{} } var requestQueue []request func pushQueue(f interface{}, ch chan interface{}) { req := request{ f, ch, }
Here is an example of what I'm trying to achieve (GetLeagueEntries (string, string) and GetSummonerName (int, int) are functions):
ch := make(chan interface{}) pushQueue(l.GetLeagueEntries, ch) pushQueue(l.GetSummonerName, ch) leagues, _ := <-ch(string1, string2) summoners, _ := <-ch(int1, int2)
source share