-
-
Save peterbourgon/ac3e5ffe0f279668a005 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conn, err := net.Dial("tcp", rabbitEndpoint) | |
if err != nil { | |
return nil, fmt.Errorf("Dial: %s", err) | |
} | |
connection, err := amqp.NewConnection( | |
conn, | |
&amqp.PlainAuth{ | |
Username: user, | |
Password: pass, | |
}, | |
"/", | |
) | |
if err != nil { | |
return nil, fmt.Errorf("Connection: %s", err) | |
} | |
Debugf("%s-%s: got Connection, getting Channel", w.Action, w.Kind) | |
channel, err := connection.Channel() | |
if err != nil { | |
return nil, fmt.Errorf("Channel: %s", err) | |
} | |
Debugf("%s-%s: got Channel, declaring Exchange", w.Action, w.Kind) | |
noArgs := amqp.Table{} | |
exchange := channel.E(w.ExchangeName) | |
if err := exchange.Declare( | |
amqp.UntilUnused, // lifetime = auto-delete | |
"direct", // type | |
false, // internal | |
false, // noWait | |
noArgs, // arguments | |
); err != nil { | |
closeChannel(w.Channel) | |
return nil, fmt.Errorf("Exchange Declare: %s", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment