Calling a function whose name is contained in a variable

I am working a design for a microservices app with a twist. The app can potentially handle upto 600 microservices and they need to be handled dynamically. By dynamically, I mean the consumer of the service calls with the name of the function they want to consume, not a transaction code. for example the consumer of the service passes to server a single parameter containing the string “a.go”. “a.go” is the name of the function to call. How does one call a function using a variable as the function name. How would the libraries have to be built, and is there a penalty in response time.

Any help / ideas appreciated.

Build a map[string]func() where you fill in the missing bits of the function signature. Lookup the function using the client’s string and call it. This is basic web service routing.

Various router packages work to optimize this.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.