ruby-kafka 0.7.0.alpha3 → 0.7.0.alpha4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8398bc3bc71e01dde7100ad58d90e8ae3cf6594121b1b8208ee3c7d1a339d35d
4
- data.tar.gz: a6c6a4cdec82a50ba9641dbb290d4a2fa453a769c6ca566f7925f94f95b19157
3
+ metadata.gz: 93553029514a22802156abc20e70cf63263f2ddc6bfe4312e11bbb629eefd017
4
+ data.tar.gz: 14c14261e50408e8ca0b0c5f14cac94939f6756bc8c5499fd2af85280218dc80
5
5
  SHA512:
6
- metadata.gz: e92ab3660ec460f97bdd2cf9f793d23c896c0cbd7be9f7d98010bce925d9f079c92a0e58e0a1eb31d9784db676adfc2889901dbd875820545e036b96da742ebb
7
- data.tar.gz: 8f3426df16dd722daa0d138683e630254ce452a791fc0f5e59bfd652bf96f3454b4034330eb6b5fc0e595e45f5a9384e8d0ecbd62cd967c7e0b712e2a6d292b8
6
+ metadata.gz: 264f0d854be944a050f7392f43c231a3499d786b5d27bf772a6a2c7b05ed7d496f8c0855e661e4e263667abe9b2d113740d92d842310052e53797588a0375034
7
+ data.tar.gz: ea31b08620b1451ac663fd16eeab8816948a3a421218282ece5c2b94417931c926ffdcbafb0436e414a3136c9ecab0442a3b477c3787d106f3380c9e18f2fcb0
@@ -235,7 +235,7 @@ module Kafka
235
235
  mark_message_as_processed(message) if automatically_mark_as_processed
236
236
  @offset_manager.commit_offsets_if_necessary
237
237
 
238
- @heartbeat.send_if_necessary
238
+ trigger_heartbeat
239
239
 
240
240
  return if !@running
241
241
  end
@@ -330,7 +330,7 @@ module Kafka
330
330
 
331
331
  @offset_manager.commit_offsets_if_necessary
332
332
 
333
- @heartbeat.send_if_necessary
333
+ trigger_heartbeat
334
334
 
335
335
  return if !@running
336
336
  end
@@ -366,10 +366,18 @@ module Kafka
366
366
  @offset_manager.mark_as_processed(message.topic, message.partition, message.offset)
367
367
  end
368
368
 
369
- def send_heartbeat_if_necessary
370
- @heartbeat.send_if_necessary
369
+ def trigger_heartbeat
370
+ @heartbeat.trigger
371
371
  end
372
372
 
373
+ def trigger_heartbeat!
374
+ @heartbeat.trigger!
375
+ end
376
+
377
+ # Aliases for the external API compatibility
378
+ alias send_heartbeat_if_necessary trigger_heartbeat
379
+ alias send_heartbeat trigger_heartbeat!
380
+
373
381
  private
374
382
 
375
383
  def consumer_loop
@@ -492,7 +500,7 @@ module Kafka
492
500
 
493
501
  join_group unless @group.member?
494
502
 
495
- @heartbeat.send_if_necessary
503
+ trigger_heartbeat
496
504
 
497
505
  resume_paused_partitions!
498
506
 
@@ -505,7 +513,9 @@ module Kafka
505
513
 
506
514
  case tag
507
515
  when :batches
508
- message
516
+ # make sure any old batches, fetched prior to the completion of a consumer group sync,
517
+ # are only processed if the batches are from brokers for which this broker is still responsible.
518
+ message.select { |batch| @group.assigned_to?(batch.topic, batch.partition) }
509
519
  when :exception
510
520
  raise message
511
521
  end
@@ -31,6 +31,10 @@ module Kafka
31
31
  @assigned_partitions.select { |topic, _| @topics.include?(topic) }
32
32
  end
33
33
 
34
+ def assigned_to?(topic, partition)
35
+ subscribed_partitions.fetch(topic, []).include?(partition)
36
+ end
37
+
34
38
  def member?
35
39
  !@generation_id.nil?
36
40
  end
@@ -8,11 +8,13 @@ module Kafka
8
8
  @last_heartbeat = Time.now
9
9
  end
10
10
 
11
- def send_if_necessary
12
- if Time.now > @last_heartbeat + @interval
13
- @group.heartbeat
14
- @last_heartbeat = Time.now
15
- end
11
+ def trigger!
12
+ @group.heartbeat
13
+ @last_heartbeat = Time.now
14
+ end
15
+
16
+ def trigger
17
+ trigger! if Time.now > @last_heartbeat + @interval
16
18
  end
17
19
  end
18
20
  end
data/lib/kafka/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kafka
4
- VERSION = "0.7.0.alpha3"
4
+ VERSION = "0.7.0.alpha4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-kafka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.alpha3
4
+ version: 0.7.0.alpha4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-29 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: digest-crc