Esempio n. 1
0
func (r *ZkRouterPorts) getPortForAppEnv(app, env string) (string, error) {
	appEnv := types.AppEnv{App: app, Env: env}
	port := r.AppEnvMap[appEnv.String()]
	if port != "" {
		return port, nil
	}
	for i := MinRouterPort; MinRouterPort <= i && i <= MaxRouterPort; i++ {
		portStr := fmt.Sprintf("%d", i)
		if _, ok := r.PortMap[portStr]; ok {
			continue
		}
		r.PortMap[portStr] = appEnv
		r.AppEnvMap[appEnv.String()] = portStr
		return portStr, r.save()
	}
	// TODO email appsplat?
	return "", errors.New("No available ports")
}
Esempio n. 2
0
func (r *ZkRouterPorts) hasPortForAppEnv(app, env string) bool {
	appEnv := types.AppEnv{App: app, Env: env}
	port := r.AppEnvMap[appEnv.String()]
	return port != ""
}