Skip to content

Commit

Permalink
feature: make couchbase initial connection configurable (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: oguzhanyildirim <oguzhan.yildirim@trendyol.com>
  • Loading branch information
oguzyildirim and oguzyildirim authored Mar 26, 2023
1 parent a399095 commit d744e55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ $ go get github.com/Trendyol/go-dcp-client
| `collectionNames` | []string | no | _default |
| `dcp.bufferSizeKb` | int | no | 16384 |
| `dcp.connectionBufferSizeKb` | uint | no | 20480 |
| `dcp.connectionTimeout` | time.Duration | no | 5s |
| `dcp.listener.bufferSize` | int | no | 1 |
| `dcp.group.membership.memberNumber` | int | no | 1 |
| `dcp.group.membership.totalMembers` | int | no | 1 |
Expand Down
2 changes: 1 addition & 1 deletion dcp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (s *client) connect(bucketName string) (*gocbcore.Agent, error) {
ch := make(chan error)

_, err = client.WaitUntilReady(
time.Now().Add(time.Second*5),
time.Now().Add(s.config.Dcp.ConnectionTimeout),
gocbcore.WaitUntilReadyOptions{
RetryStrategy: gocbcore.NewBestEffortRetryStrategy(nil),
},
Expand Down
5 changes: 5 additions & 0 deletions helpers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ConfigDCP struct {
Group ConfigDCPGroup `yaml:"group"`
BufferSizeKb int `yaml:"bufferSizeKb" default:"16384"`
ConnectionBufferSizeKb uint `yaml:"connectionBufferSizeKb" default:"20480"`
ConnectionTimeout time.Duration `yaml:"connectionTimeout"`
Listener ConfigDCPListener `yaml:"listener"`
}

Expand Down Expand Up @@ -184,6 +185,10 @@ func applyUnhandledDefaults(_config *Config) {
_config.Dcp.Group.Membership.RebalanceDelay = 20 * time.Second
}

if _config.Dcp.ConnectionTimeout == 0 {
_config.Dcp.ConnectionTimeout = 5 * time.Second
}

if _config.CollectionNames == nil {
_config.CollectionNames = []string{DefaultCollectionName}
}
Expand Down

0 comments on commit d744e55

Please sign in to comment.