Skip to content

Commit

Permalink
[FAB-1367] Rebase Kafka on common components
Browse files Browse the repository at this point in the history
https://jira.hyperledger.org/browse/FAB-1367

This is the changeset that ties together all the previous changesets in
this series: it rebases the Kafka consenter on the components that are
meant to be common across all consensus implementations. The major
addition here is the new logic which resides in "main.go" in the kafka
package.

On top of the existing unit tests for the Kafka consenter's
sub-components (producer, consumer, broker), this changeset introduces
some basic unit tests for the new logic, identical to the ones for the
solo package. More tests are needed however, and we are in the process of
writing BDD feature files for that purpose - see
https://jira.hyperledger.org/browse/FAB-1335 for more.

This changeset also adds the following:

1. A "disk" (a channel for passing messages) to the mock Consumer. The
mock Consumer will use that "disk" to fetch the replies that it returns
during the Recv() call. This is required for the units tests we
introduced, where we want the (mock) consumer to respond with the
messages that the (mock) producer posted. The two mock constructs use
this disk channel to communicate, simulating a consumer that reads the
messages that a producer posted to a partition.
2. A timeout to the mock consumer's Recv() method to prevent blocking in
for/select loops.

Finally, this changeset makes the following refactoring-related changes:

1. It establishes a common path for both solo and the kafka consenters in
the orderer package's "main.go" - the previous version of this file was
whipped up together quickly and was essentially a giant if-else
construct. As we get closer to a release, some refactoring was in order.
2. It makes all dependencies in the kafka package explicit. In the
previous version, we would pass around the entire config object to
functions and let them pick what they needed from it. While this made for
symmetric and simple-looking function signatures, it allowed for
ambiguous and implicit dependencies, and would increase confusion and
maintenance burden. This specific edit affects almost all files in the
kafka package and makes for a bigger diff than necessary. I had
unfortunately began working on this before beginning the 'rebasing on
common components' work, and proceeded with both tasks in parallel. (In
hindsight, I should have scheduled this a bit better.)

Change-Id: I46392b8079ec02e273b16f51a7e8ed514c64748f
Signed-off-by: Kostas Christidis <kostas@christidis.io>
  • Loading branch information
kchristidis committed Dec 15, 2016
1 parent 9082238 commit 675d094
Show file tree
Hide file tree
Showing 28 changed files with 791 additions and 1,750 deletions.
159 changes: 0 additions & 159 deletions orderer/kafka/broadcast.go

This file was deleted.

64 changes: 0 additions & 64 deletions orderer/kafka/broadcast_mock_test.go

This file was deleted.

0 comments on commit 675d094

Please sign in to comment.