-
Notifications
You must be signed in to change notification settings - Fork 7
/
config.go
41 lines (35 loc) · 1.06 KB
/
config.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
39
40
41
package amqpextra
import (
"fmt"
"time"
"github.com/lunarway/release-manager/internal/log"
)
// Config configures a worker.
type Config struct {
Connection ConnectionConfig
Exchange string
Queue string
RoutingKey string
Prefetch int
ReconnectionTimeout time.Duration
ConnectionTimeout time.Duration
InitTimeout time.Duration
Logger *log.Logger
}
// ConnectionConfig configures an AMQP connection.
type ConnectionConfig struct {
Host string
User string
Password string
VirtualHost string
Port int
}
// Raw returns a raw connection string used to dial. Notice that this will
// reveal the password if the result is logged.
func (c *ConnectionConfig) Raw() string {
return fmt.Sprintf("amqp://%s:%s@%s:%d/%s", c.User, c.Password, c.Host, c.Port, c.VirtualHost)
}
// String returns a masked connection string safe for logging.
func (c *ConnectionConfig) String() string {
return fmt.Sprintf("amqp://%s:%s@%s:%d/%s", c.User, "***", c.Host, c.Port, c.VirtualHost)
}