-
Notifications
You must be signed in to change notification settings - Fork 0
/
connection.go
38 lines (32 loc) · 904 Bytes
/
connection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package carrot
import "fmt"
type ConnectionConfig struct {
Username string
Password string
Host string
AMQPPort string
APIPort string
VHost string
}
//GetAMQPURI returns amqp url format based on config
func (conn *ConnectionConfig) GetAMQPURI() string {
return fmt.Sprintf("amqp://%s:%s@%s:%s/%s", conn.Username, conn.Password, conn.Host, conn.GetAMQPPort(), conn.VHost)
}
//GetAMQPPort returns current config of amqp port or default port
func (conn *ConnectionConfig) GetAMQPPort() string {
if conn.AMQPPort != "" {
return conn.AMQPPort
}
return "5672"
}
//GetAPIURI return uri formatted
func (conn *ConnectionConfig) GetAPIURI() string {
return fmt.Sprintf("http://%s:%s/", conn.Host, conn.GetAPIPort())
}
//GetAPIPort returns current api port or default
func (conn *ConnectionConfig) GetAPIPort() string {
if conn.APIPort != "" {
return conn.APIPort
}
return "15672"
}