Skip to content

Commit

Permalink
Merge pull request hashicorp#281 from freeekanayaka/configurable-inme…
Browse files Browse the repository at this point in the history
…m-transport-timeout

Make the InmemTransport.timeout field configurable
  • Loading branch information
mkeeler authored Aug 22, 2018
2 parents 1c794e1 + cfdcd7e commit 2bac946
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions inmem_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,29 @@ type InmemTransport struct {
timeout time.Duration
}

// NewInmemTransport is used to initialize a new transport
// and generates a random local address if none is specified
func NewInmemTransport(addr ServerAddress) (ServerAddress, *InmemTransport) {
// NewInmemTransportWithTimeout is used to initialize a new transport and
// generates a random local address if none is specified. The given timeout
// will be used to decide how long to wait for a connected peer to process the
// RPCs that we're sending it. See also Connect() and Consumer().
func NewInmemTransportWithTimeout(addr ServerAddress, timeout time.Duration) (ServerAddress, *InmemTransport) {
if string(addr) == "" {
addr = NewInmemAddr()
}
trans := &InmemTransport{
consumerCh: make(chan RPC, 16),
localAddr: addr,
peers: make(map[ServerAddress]*InmemTransport),
timeout: 50 * time.Millisecond,
timeout: timeout,
}
return addr, trans
}

// NewInmemTransport is used to initialize a new transport
// and generates a random local address if none is specified
func NewInmemTransport(addr ServerAddress) (ServerAddress, *InmemTransport) {
return NewInmemTransportWithTimeout(addr, 50*time.Millisecond)
}

// SetHeartbeatHandler is used to set optional fast-path for
// heartbeats, not supported for this transport.
func (i *InmemTransport) SetHeartbeatHandler(cb func(RPC)) {
Expand Down

0 comments on commit 2bac946

Please sign in to comment.