Skip to content
This repository has been archived by the owner on Dec 14, 2020. It is now read-only.

Commit

Permalink
add connection properties
Browse files Browse the repository at this point in the history
  • Loading branch information
devigned authored and vcabbage committed Feb 14, 2018
1 parent e2cb6f5 commit ccafaa7
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ func ConnMaxSessions(n int) ConnOption {
}
}

// ConnProperty sets an entry in the connection properties map sent to the server.
//
// This option can be used multiple times.
func ConnProperty(key, value string) ConnOption {
return func(c *conn) error {
if key == "" {
return errorNew("connection property key must not be empty")
}
if c.properties == nil {
c.properties = make(map[symbol]interface{})
}
c.properties[symbol(key)] = value
return nil
}
}

// conn is an AMQP connection.
type conn struct {
net net.Conn // underlying connection
Expand All @@ -148,10 +164,11 @@ type conn struct {
saslComplete bool // SASL negotiation complete

// local settings
maxFrameSize uint32 // max frame size to accept
channelMax uint16 // maximum number of channels to allow
hostname string // hostname of remote server (set explicitly or parsed from URL)
idleTimeout time.Duration // maximum period between receiving frames
maxFrameSize uint32 // max frame size to accept
channelMax uint16 // maximum number of channels to allow
hostname string // hostname of remote server (set explicitly or parsed from URL)
idleTimeout time.Duration // maximum period between receiving frames
properties map[symbol]interface{} // additional properties sent upon connection open

// peer settings
peerIdleTimeout time.Duration // maximum period between sending frames
Expand Down Expand Up @@ -745,6 +762,7 @@ func (c *conn) openAMQP() stateFunc {
MaxFrameSize: c.maxFrameSize,
ChannelMax: c.channelMax,
IdleTimeout: c.idleTimeout,
Properties: c.properties,
},
channel: 0,
})
Expand Down

0 comments on commit ccafaa7

Please sign in to comment.