コード例 #1
0
ファイル: agent.go プロジェクト: prydeep/tegu
/*
	Send the message to the designated 'long running' agent (lra); the
	agent that has been designated to handle all long running tasks
	that are not time sensitive (such as intermediate queue setup/checking).
*/
func (ad *agent_data) send2lra(smgr *connman.Cmgr, msg string) {
	l := len(ad.agents)
	if l <= 0 {
		return
	}

	smgr.Write(ad.agent_list[0].id, []byte(msg))
}
コード例 #2
0
ファイル: agent.go プロジェクト: prydeep/tegu
/*
	Send the message to the designated 'long running' agent (lra); the
	agent that has been designated to handle all long running tasks
	that are not time sensitive (such as intermediate queue setup/checking).
*/
func (ad *agent_data) sendbytes2lra(smgr *connman.Cmgr, msg []byte) {
	l := len(ad.agents)
	if l <= 0 {
		return
	}

	smgr.Write(ad.agent_list[0].id, msg)
}
コード例 #3
0
ファイル: agent.go プロジェクト: prydeep/tegu
/*
	Send the message to one agent. The agent is selected using the current
	index in the agent_data so that it effectively does a round robin.
*/
func (ad *agent_data) sendbytes2one(smgr *connman.Cmgr, msg []byte) {
	l := len(ad.agents)
	if l <= 0 {
		return
	}

	smgr.Write(ad.agent_list[ad.aidx].id, msg)
	ad.aidx++
	if ad.aidx >= l {
		if l > 1 {
			ad.aidx = 1 // skip the long running agent if more than one agent connected
		} else {
			ad.aidx = 0
		}
	}
}
コード例 #4
0
ファイル: tegu_agent.go プロジェクト: robert-eby/tegu
/*
	Establishes a connection with tegu. This blocks until a connection is established
	and tries every few seconds until successful.
*/
func connect2tegu(smgr *connman.Cmgr, host_port *string, data_chan chan *connman.Sess_data) {

	burble := 0 // limit our complaining to once a minute or so

	for {
		err := smgr.Connect(*host_port, "c0", data_chan)
		if err == nil {
			sheep.Baa(1, "connection with tegu established: %s", *host_port)
			return
		}

		if burble <= 0 {
			sheep.Baa(0, "unable to establish a connection with tegu: %s: %s", *host_port, err)
			burble = 12
		}

		time.Sleep(5 * time.Duration(time.Second))
		burble--
	}
}
コード例 #5
0
ファイル: agent.go プロジェクト: prydeep/tegu
/*
	Send the message to all agents.
*/
func (ad *agent_data) send2all(smgr *connman.Cmgr, msg string) {
	am_sheep.Baa(2, "sending %d bytes", len(msg))
	for id := range ad.agents {
		smgr.Write(id, []byte(msg))
	}
}