-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transducers are Coming #200
Open
creese
wants to merge
8
commits into
master
Choose a base branch
from
transducers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4dffa12
Adds helper functions for working with transducers and two examples.
08ae80f
Replace topology xf-word-count topology with classic Word Count to ru…
05cfd61
Fix test-xf-word-count
2136e1c
Remove nils from keys in examples and change simple ledger map keys
4ee5d7f
Remove xf- prefix from transducer naming, move fake-kv-store to diffe…
fe1a74b
When publishing test data, use "entry-pending"
01317c2
Use `forward` method on the processor context
9efe7b7
Rename var from entry to txn
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
log/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Simple Ledger | ||
|
||
This example creates a simple accounting ledger using transducers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
{:deps | ||
{danlentz/clj-uuid {:mvn/version "0.1.7"} | ||
fundingcircle/jackdaw {:mvn/version "0.6.4"} | ||
org.apache.kafka/kafka-streams {:mvn/version "2.1.0"} | ||
org.apache.kafka/kafka-streams-test-utils {:mvn/version "2.1.0"} | ||
org.clojure/clojure {:mvn/version "1.10.0"} | ||
org.clojure/tools.logging {:mvn/version "0.4.1"}} | ||
{:paths | ||
["src" "resources"] | ||
|
||
:mvn/repos | ||
{"confluent" {:url "https://packages.confluent.io/maven/"}} | ||
|
||
:paths | ||
["src" "test" "dev" "../dev"] | ||
:deps | ||
{fundingcircle/jackdaw {:mvn/version "0.6.9-transducers-SNAPSHOT" | ||
:exclusions [org.apache.zookeeper/zookeeper]} | ||
org.clojure/clojure {:mvn/version "1.10.1"} | ||
org.clojure/tools.logging {:mvn/version "0.4.1"} | ||
org.apache.kafka/kafka-streams {:mvn/version "2.3.0"} | ||
org.apache.kafka/kafka-streams-test-utils {:mvn/version "2.3.0"} | ||
ch.qos.logback/logback-classic {:mvn/version "1.2.3"} | ||
integrant {:mvn/version "0.7.0"}} | ||
|
||
:aliases | ||
{:test {:extra-deps {com.cognitect/test-runner | ||
{:git/url "https://github.com/cognitect-labs/test-runner.git" | ||
:sha "028a6d41ac9ac5d5c405dfc38e4da6b4cc1255d5"}} | ||
:main-opts ["-m" "cognitect.test-runner"]}}} | ||
{:dev | ||
{:extra-paths ["dev" "../../dev"] | ||
:extra-deps {integrant/repl {:mvn/version "0.3.1"} | ||
danlentz/clj-uuid {:mvn/version "0.1.7" | ||
:exclusions [primitive-math]}}} | ||
|
||
:test | ||
{:extra-paths ["test"] | ||
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git" | ||
:sha "028a6d41ac9ac5d5c405dfc38e4da6b4cc1255d5"}} | ||
:main-opts ["-m" "cognitect.test-runner"]}} | ||
|
||
:mvn/repos | ||
{"confluent" {:url "https://packages.confluent.io/maven/"}}} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
(ns user | ||
"Use this namespace for interactive development. | ||
|
||
This namespace requires libs needed to reset the app and helpers | ||
from `jackdaw.repl`. WARNING: Do no use `clj-refactor` (or | ||
equivalent) to clean this namespace since these tools cannot tell | ||
which libs are actually required." | ||
(:gen-class) | ||
(:require [clojure.string :as str] | ||
[clojure.tools.logging :refer [info]] | ||
[integrant.core :as ig] | ||
[integrant.repl :refer [clear go halt prep init reset reset-all]] | ||
[jackdaw.admin :as ja] | ||
[jackdaw.serdes :as js] | ||
[jackdaw.repl :refer :all] | ||
[jackdaw.streams :as j] | ||
[jackdaw.streams.xform :as jxf] | ||
[simple-ledger :as sl])) | ||
|
||
|
||
(def repl-config | ||
"The development config. | ||
When the 'dev' alias is active, this config will be used." | ||
{:topics {:client-config (select-keys sl/streams-config ["bootstrap.servers"]) | ||
:topic-metadata {:entry-added | ||
{:topic-name "entry-pending" | ||
:partition-count 15 | ||
:replication-factor 1 | ||
:key-serde (js/edn-serde) | ||
:value-serde (js/edn-serde)} | ||
|
||
:transaction-pending | ||
{:topic-name "transaction-pending" | ||
:partition-count 15 | ||
:replication-factor 1 | ||
:key-serde (js/edn-serde) | ||
:value-serde (js/edn-serde)} | ||
|
||
:transaction-added | ||
{:topic-name "transaction-added" | ||
:partition-count 15 | ||
:replication-factor 1 | ||
:key-serde (js/edn-serde) | ||
:value-serde (js/edn-serde)}}} | ||
|
||
:topology {:topology-builder sl/topology-builder | ||
:xforms [#'sl/split-entries #'sl/running-balances] | ||
:swap-fn jxf/kv-store-swap-fn} | ||
|
||
:app {:streams-config sl/streams-config | ||
:topology (ig/ref :topology) | ||
:topics (ig/ref :topics)}}) | ||
|
||
|
||
(integrant.repl/set-prep! (constantly repl-config)) | ||
|
||
|
||
(defmethod ig/init-key :topics [_ {:keys [client-config topic-metadata] :as opts}] | ||
(with-open [client (ja/->AdminClient client-config)] | ||
(ja/create-topics! client (vals topic-metadata))) | ||
(assoc opts :topic-metadata topic-metadata)) | ||
|
||
(defmethod ig/init-key :topology [_ {:keys [topology-builder xforms swap-fn]}] | ||
(let [xform-map (reduce-kv (fn [m k v] | ||
(let [k (keyword (str (:ns (meta v))) | ||
(str (:name (meta v))))] | ||
(assoc m k #(v % jxf/kv-store-swap-fn)))) | ||
{} | ||
xforms) | ||
streams-builder (j/streams-builder)] | ||
((topology-builder topic-metadata xform-map) streams-builder))) | ||
|
||
(defmethod ig/init-key :app [_ {:keys [streams-config topology] :as opts}] | ||
(let [streams-app (j/kafka-streams topology streams-config)] | ||
(j/start streams-app) | ||
(assoc opts :streams-app streams-app))) | ||
|
||
(defmethod ig/halt-key! :topics [_ {:keys [client-config topic-metadata]}] | ||
(let [re (re-pattern (str "(" (->> topic-metadata | ||
keys | ||
(map name) | ||
(str/join "|")) | ||
")"))] | ||
(re-delete-topics client-config re))) | ||
|
||
(defmethod ig/halt-key! :app [_ {:keys [streams-config topics streams-app]}] | ||
(j/close streams-app) | ||
(destroy-state-stores streams-config) | ||
(let [re (re-pattern (str "(" (get streams-config "application.id") ")"))] | ||
(re-delete-topics (:client-config topics) re))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../resources/logback.xml |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not* typo