Esempio n. 1
0
func connect(discoverAddr string) *client.Client {
	defer func() {
		if r := recover(); r != nil {
			log.Fatalf("Could not connect to circuit: %v", r)
		}
	}()
	return client.DialDiscover(discoverAddr, nil)
}
Esempio n. 2
0
// client *client.Client
func Init(discover string) {
	program = &Program{}
	if discover != "" {
		program.Client = client.DialDiscover(discover, nil)
	}

	rand.Seed(time.Now().UnixNano())

	faculty.Register(be.NewMaterializer(&Process{}), "element", "Process")
	faculty.Register(be.NewMaterializer(&Docker{}), "element", "Docker")
}
Esempio n. 3
0
func dial(x *cli.Context) *client.Client {
	switch {
	case x.IsSet("dial"):
		defer func() {
			if r := recover(); r != nil {
				fatalf("addressed server is gone or authentication failed")
			}
		}()
		return client.Dial(x.String("dial"), readkey(x))

	case x.IsSet("discover"):
		defer func() {
			if r := recover(); r != nil {
				fatalf("multicast address is unresponsive or authentication failed")
			}
		}()
		return client.DialDiscover(x.String("discover"), readkey(x))

	case os.Getenv("CIRCUIT") != "":
		buf, err := ioutil.ReadFile(os.Getenv("CIRCUIT"))
		if err != nil {
			fatalf("circuit environment file %s is not readable: %v", os.Getenv("CIRCUIT"), err)
		}
		defer func() {
			if r := recover(); r != nil {
				fatalf("addressed server is gone or authentication failed")
			}
		}()
		return client.Dial(strings.TrimSpace(string(buf)), readkey(x))

	case os.Getenv("CIRCUIT_DISCOVER") != "":
		defer func() {
			if r := recover(); r != nil {
				fatalf("multicast address is unresponsive or authentication failed")
			}
		}()
		return client.DialDiscover(os.Getenv("CIRCUIT_DISCOVER"), readkey(x))
	}
	fatalf("no dial or discovery addresses available; use -dial or -discover")
	panic(0)
}
Esempio n. 4
0
// client *client.Client
func Init(discover string) {
	program = &Program{}
	if discover != "" {
		program.Client = client.DialDiscover(discover, nil)
	}

	rand.Seed(time.Now().UnixNano())

	ns := faculty.Root.Refine("circuit")
	ns.AddTerminal("Process", Process{})
	ns.AddTerminal("Docker", Docker{})
	// ns.AddTerminal("Leaving", Leaving{})
	// ns.AddTerminal("Joining", Joining{})
	// ns.AddTerminal("Channel", Chan{})

	ns.AddTerminal("ForkSpawn", ForkSpawn{})
	ns.AddTerminal("ForkExit", ForkExit{})
	ns.AddTerminal("ForkIO", ForkIO{})
}