Source

aquchinchay / src / aquchinchay / clients / clients.go

Full commit
package clients

import (
	"aquchinchay/config"
)

type RemoteClient interface {
	Send(message string)
	Channel() chan string
	Close()
}

func getClientFactory(factoryName string) func (config.ClientConfig) RemoteClient {
	return map[string]func (config.ClientConfig) RemoteClient{
		"echo": OpenEcho,
		"proxy": OpenProxy}[factoryName]
}

func MakeClient(clientConfig config.ClientConfig) func () RemoteClient {
	clientFactory := getClientFactory(clientConfig["Client"])
	return func () RemoteClient {
		client := clientFactory(clientConfig)
		return client
	}
}