Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
undo put cap of 1 second to NewPeerClient connect
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari committed Feb 26, 2024
1 parent f132176 commit f6102d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions gubernator.go
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ func (s *V1Instance) SetPeers(peerInfo []PeerInfo) {
Info: info,
})
if err != nil {
s.log.Error("error connecting to peer: %s", err)
s.log.Errorf("error connecting to peer %s: %s", info.GRPCAddress, err)
return
}
}
Expand All @@ -628,7 +628,7 @@ func (s *V1Instance) SetPeers(peerInfo []PeerInfo) {
Info: info,
})
if err != nil {
s.log.Error("error connecting to peer: %s", err)
s.log.Errorf("error connecting to peer %s: %s", info.GRPCAddress, err)
return
}
}
Expand Down
10 changes: 3 additions & 7 deletions peer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"fmt"
"sync"
"sync/atomic"
"time"

"github.com/mailgun/holster/v4/clock"
"github.com/mailgun/holster/v4/collections"
Expand Down Expand Up @@ -80,15 +79,15 @@ type PeerConfig struct {
TraceGRPC bool
}

// NewPeerClient tries to establish a connection to a peer in a blocking fashion with a 1 second timeout.
// NewPeerClient tries to establish a connection to a peer in a non-blocking fashion.
// If batching is enabled, it also starts a goroutine where batches will be processed.
func NewPeerClient(conf PeerConfig) (*PeerClient, error) {
peerClient := &PeerClient{
queue: make(chan *request, 1000),
conf: conf,
lastErrs: collections.NewLRUCache(100),
}
opts := []grpc.DialOption{grpc.WithBlock()}
var opts []grpc.DialOption

if conf.TraceGRPC {
opts = []grpc.DialOption{
Expand All @@ -102,11 +101,8 @@ func NewPeerClient(conf PeerConfig) (*PeerClient, error) {
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
}

ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

var err error
peerClient.conn, err = grpc.DialContext(ctx, conf.Info.GRPCAddress, opts...)
peerClient.conn, err = grpc.Dial(conf.Info.GRPCAddress, opts...)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit f6102d9

Please sign in to comment.