Skip to content

Commit 229618a

Browse files
committed
Renamed ReceiveDeadline -> HeartbeatTimeout
1 parent bf96c03 commit 229618a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

config.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type Config struct {
3636
Name string
3737
PollDuration *time.Duration
3838
MinPollInterval *time.Duration
39-
ReceiveDeadline *time.Duration
39+
HeartbeatTimeout *time.Duration
4040
}
4141

4242
// Validate the Config, returning an error if invalid.
@@ -52,7 +52,7 @@ func (c Config) Validate() error {
5252
validation.Field(&c.Name, validation.Required, validation.Match(regexp.MustCompile("^[^%]*$"))),
5353
validation.Field(&c.PollDuration, validation.Required, validation.Min(1*time.Millisecond)),
5454
validation.Field(&c.MinPollInterval, validation.Required, validation.Min(1*time.Millisecond)),
55-
validation.Field(&c.ReceiveDeadline, validation.Required, validation.Min(1*time.Millisecond)),
55+
validation.Field(&c.HeartbeatTimeout, validation.Required, validation.Min(1*time.Millisecond)),
5656
)
5757
}
5858

@@ -68,7 +68,7 @@ func (c Config) String() string {
6868
", Name=", c.Name,
6969
", PollDuration=", c.PollDuration,
7070
", MinPollInterval=", c.MinPollInterval,
71-
", ReceiveDeadline=", c.ReceiveDeadline, "]")
71+
", HeartbeatTimeout=", c.HeartbeatTimeout, "]")
7272
}
7373

7474
const (
@@ -78,8 +78,8 @@ const (
7878
// DefaultMinPollInterval is the default value of Config.MinPollInterval
7979
DefaultMinPollInterval = 100 * time.Millisecond
8080

81-
// DefaultReceiveDeadline is the default value of Config.ReceiveDeadline
82-
DefaultReceiveDeadline = 5 * time.Second
81+
// DefaultHeartbeatTimeout is the default value of Config.HeartbeatTimeout
82+
DefaultHeartbeatTimeout = 5 * time.Second
8383
)
8484

8585
// SetDefaults assigns the default values to optional fields.
@@ -111,7 +111,7 @@ func (c *Config) SetDefaults() {
111111

112112
defaultDuration(&c.PollDuration, DefaultPollDuration)
113113
defaultDuration(&c.MinPollInterval, DefaultMinPollInterval)
114-
defaultDuration(&c.ReceiveDeadline, DefaultReceiveDeadline)
114+
defaultDuration(&c.HeartbeatTimeout, DefaultHeartbeatTimeout)
115115
}
116116

117117
const validKafkaNameChars = "a-zA-Z0-9\\._\\-"

neli.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ func New(config Config, barrier ...Barrier) (Neli, error) {
8989
err := setKafkaConfigs(consumerConfigs, KafkaConfigMap{
9090
"group.id": n.config.LeaderGroupID,
9191
"enable.auto.commit": false,
92-
"session.timeout.ms": int(config.ReceiveDeadline.Milliseconds()) * 3,
92+
"session.timeout.ms": int(config.HeartbeatTimeout.Milliseconds()) * 3,
9393
})
9494
if err != nil {
9595
return nil, err
9696
}
9797

9898
producerConfigs := copyKafkaConfig(n.config.KafkaConfig)
9999
err = setKafkaConfigs(producerConfigs, KafkaConfigMap{
100-
"delivery.timeout.ms": int(config.ReceiveDeadline.Milliseconds()),
100+
"delivery.timeout.ms": int(config.HeartbeatTimeout.Milliseconds()),
101101
"linger.ms": 0,
102102
})
103103
if err != nil {
@@ -288,7 +288,7 @@ func (n *neli) tryPulse() (bool, error) {
288288
// If we were previously the leeder, need to make sure that we are still receiving heartbeats.
289289
// This enables us to detect network partitions and broker failures.
290290
lastReceived := time.Unix(0, n.lastReceived.Get())
291-
if elapsed := time.Now().Sub(lastReceived); elapsed > *n.config.ReceiveDeadline {
291+
if elapsed := time.Now().Sub(lastReceived); elapsed > *n.config.HeartbeatTimeout {
292292
n.logger().I()("Fenced leader (heartbeat timed out)")
293293
n.isLeader.Set(0)
294294
n.barrier(LeaderFenced{})

neli_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (fixtureOpts fixtures) create() (scribe.MockScribe, *consMock, *prodMock, C
3535
LeaderTopic: "test.topic",
3636
MinPollInterval: Duration(1 * time.Millisecond),
3737
PollDuration: Duration(1 * time.Millisecond),
38-
ReceiveDeadline: Duration(10 * time.Second),
38+
HeartbeatTimeout: Duration(10 * time.Second),
3939
}
4040
config.Scribe.SetEnabled(scribe.All)
4141

@@ -328,7 +328,7 @@ func TestLeaderElectionAndRevocation_nopBarrier(t *testing.T) {
328328

329329
func TestLeaderElectionAndRevocation_timeoutAndReconnect(t *testing.T) {
330330
m, cons, _, config, b := fixtures{}.create()
331-
config.ReceiveDeadline = Duration(1 * time.Millisecond)
331+
config.HeartbeatTimeout = Duration(1 * time.Millisecond)
332332

333333
n, err := New(config, b.barrier())
334334
require.Nil(t, err)

0 commit comments

Comments
 (0)