Skip to content

Commit

Permalink
Update README.md per changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Reese committed Sep 20, 2019
1 parent daa2390 commit 8c9e685
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions examples/word-count/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ The project structure looks like this:
```
tree
.
├── README.md
├── deps.edn
├── dev
│   └── system.clj
├── README.md
│   └── user.clj
├── resources
│   ├── logback.xml
│   ├── logback.xml -> ../../resources/logback.xml
│   └── metamorphosis.txt
├── src
│   └── word_count.clj
Expand All @@ -35,23 +35,20 @@ tree
4 directories, 7 files
```

The `deps.edn` file describes the project's source paths and
dependencies.
The `deps.edn` file describes the source paths and dependencies.

The `system.clj` file contains functions to start and stop the
app. These are used by the `user` namespace for interactive
development.
The `user.clj` file contains functions to start and stop the
app during interactive development.

The `word_count.clj` file describes the app and the topology. The
The `word_count.clj` file contains the app and topology. The
application reads from a Kafka topic called `input` and splits the
input value into words. It puts the count on a Kafka topic called
`output` for each word seen:
value into words. It then writes to a Kafka topic called `output` for
each word seen:
```
(defn topology-builder
[topic-metadata]
(fn [builder]
(let [text-input (-> (j/kstream builder (:input (topic-metadata)))
(j/peek (fn [[k v]] (info (str {:key k :value v})))))
(let [text-input (j/kstream builder (:input topic-metadata))
counts (-> text-input
(j/flat-map-values split-lines)
Expand All @@ -60,7 +57,7 @@ input value into words. It puts the count on a Kafka topic called
(-> counts
(j/to-kstream)
(j/to (:output (topic-metadata))))
(j/to (:output topic-metadata)))
builder)))
```
Expand All @@ -70,21 +67,21 @@ The `word_count_test.clj` file contains a test

## Running the app

Let's get started! Start Confluent Platform using the Confluent CLI
`start` command.
Let's get started! Install the CLI and start the Confluent Platform:
```
<path-to-confluent>/bin/confluent start
curl -L https://cnfl.io/cli | sh -s -- -b /<path-to-directory>/bin
<path-to-confluent>/bin/confluent local start
```

Then change to the Word Count project directory and start a REPL.
Then change to the project directory and start a REPL.
```
cd <path-to-jackdaw>/examples/word-count
clj
clj -A:dev
```

You should see output like the following:
```
Clojure 1.10.0
Clojure 1.10.1
user=>
```

Expand All @@ -96,19 +93,14 @@ Enter the following at the `user=>` prompt:
If you see output like the following, congratulations, the app is
running!
```
23:01:25.939 [main] INFO system - internal state is deleted
23:01:26.093 [main] INFO word-count - word-count is up
{:app #object[org.apache.kafka.streams.KafkaStreams 0xb8b2184 "org.apache.kafka.streams.KafkaStreams@b8b2184"]}
:reloading (word-count user)
:resumed
```

Let's put a couple of records on the input topic:
Let's publish a couple of records and see the result:
```
(publish (:input (topic-metadata)) nil "all streams lead to kafka")
(publish (:input (topic-metadata)) nil "hello kafka streams")
```

We can also get the result:
```
(get-keyvals (:output (topic-metadata)))
```

Expand All @@ -124,14 +116,13 @@ You should see output like the following:
["streams" 2])
```

For more a more in depth walkthrough, see the comment block in the
`word_count.clj` file.
For an in depth walkthrough, see the comment block in the `word_count.clj` file.


## Running tests

To run tests, load the `word-count-test` namespace in your editor and
invoke a test runner, or from the command line:
invoke a test runner, or from the command-line:
```
clj -Atest
clj -A:test
```

0 comments on commit 8c9e685

Please sign in to comment.