func CreateAgent(port string) { tcpAddr, err := net.ResolveTCPAddr("tcp4", port) checkError(err) listener, err := net.ListenTCP("tcp", tcpAddr) checkError(err) // Create an AMQP Connection queueConn, err := queue.Connect() checkError(err) defer queueConn.Close() s := &session{ queue: queueConn, } for { conn, err := listener.Accept() if err != nil { continue } go handleMessage(conn, s) } }
func init() { conn, err := queue.Connect() if err != nil { fmt.Printf("Fatal error: %s", err.Error()) } workerConn = &workers{queue: conn} }
// Helper for creating an AMQP Connection func createConnection() *amqp.Connection { conn, err := queue.Connect() if err != nil { fmt.Errorf("Error Connecting: %s", err) } return conn }
func init() { // Create an AMQP Connection queueConn, err := queue.Connect() checkError(err) s = &session{ queue: queueConn, } }