Skip to content
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

As-a-service, consume topic definitions and act accordingly #7

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fc2ac68
More verbose (error) logging
atamon Oct 25, 2016
0a68698
Add build-target so we can build internally
atamon Oct 25, 2016
100b0a1
Merge remote-tracking branch 'origin/extend-logging'
solsson Nov 27, 2017
6fad336
wip convert to gradle build, Dockerfile is todo
solsson Nov 27, 2017
71212db
Adds dockerfile, with quite ok caching
solsson Nov 27, 2017
e116371
Adds a couple of dependencies we'll need for the service
solsson Nov 27, 2017
21ee78f
We're going to define the topic declaration schema at start
solsson Nov 28, 2017
bf60ed3
Adapted from Schema Registry's topic setup
solsson Nov 28, 2017
b467f5a
wip
solsson Nov 28, 2017
27f8370
Let's use an integration test to experiment with topic setup
solsson Nov 28, 2017
362b6c5
Apache 2.0 license
solsson Nov 28, 2017
eb2920d
I'm using docker-compose locally, with an extra advertised.listeners
solsson Nov 28, 2017
16b2d30
Lists current schemas
solsson Nov 28, 2017
5dc918c
We'll want to get topic declaration messages as their java representa…
solsson Nov 28, 2017
5979eb4
Shows that we have the current schema source to compare with registry…
solsson Nov 28, 2017
8c6e5b4
Uploads our local schema, if it's missing
solsson Nov 28, 2017
a1a000d
Evaluating concurrency and retry alternatives
solsson Nov 30, 2017
eb63aea
Testability! for anyone who has my docker-compose.yml :)
solsson Nov 30, 2017
55439ba
Tests error handling in AdminClient
solsson Dec 1, 2017
1426314
Reuse in tests, gotcha again
solsson Dec 1, 2017
88be59c
Got some sort of structure for integrating different services now
solsson Dec 1, 2017
7903634
Wanted to start, but more importantly stop, the service from a test
solsson Dec 1, 2017
e0057a2
Shares the executor service with the retry lib
solsson Dec 1, 2017
1fb1e0b
Runs in sequence for now, until we're more than a consumer
solsson Dec 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.idea
target/
node_modules/
/bin/
/build/
.classpath
.gradle
.project
.settings
.git
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.idea
target/
node_modules/
/bin/
/build/
.classpath
.gradle
.project
.settings
1 change: 0 additions & 1 deletion Dockerfile

This file was deleted.

39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM solsson/kafka-jre@sha256:06dabfc8cacd0687c8f52c52afd650444fb6d4a8e0b85f68557e6e7a5c71667c \
as build

ENV GRADLE_VERSION=4.3.1

RUN set -ex; \
export DEBIAN_FRONTEND=noninteractive; \
runDeps='curl'; \
buildDeps='ca-certificates unzip'; \
apt-get update && apt-get install -y $runDeps $buildDeps --no-install-recommends; \
\
cd /opt; \
curl -SLs -o gradle-$GRADLE_VERSION-bin.zip https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip; \
unzip gradle-$GRADLE_VERSION-bin.zip; \
rm gradle-$GRADLE_VERSION-bin.zip; \
ln -s /opt/gradle-$GRADLE_VERSION/bin/gradle /usr/local/bin/gradle; \
gradle -v

WORKDIR /opt/src/kafka-topic-client
COPY build.gradle ./

RUN set -ex; \
mkdir -p src/main/java; \
echo "public class Dummy {}" > src/main/java/Dummy.java; \
gradle build; \
rm src/main/java/Dummy.java

COPY . .

RUN set -ex; \
gradle build

FROM solsson/kafka-jre@sha256:06dabfc8cacd0687c8f52c52afd650444fb6d4a8e0b85f68557e6e7a5c71667c

COPY --from=build /opt/src/kafka-topic-client/build/libs /usr/share/java/kafka-topic-client

ENTRYPOINT [ "java", \
"-cp", "/usr/share/java/kafka-topic-client/*:/etc/kafka-topic-client/*", \
"se.yolean.kafka.topic.client.cli.Client" ]
15 changes: 0 additions & 15 deletions Dockerfile.dev

This file was deleted.

30 changes: 0 additions & 30 deletions Dockerfile.prod

This file was deleted.

177 changes: 177 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


## The `Topic` schema

See `src/main/avro/Topic.avsc`.

IDEs can get generated Java using `gradle build`.
2 changes: 2 additions & 0 deletions build-contracts/docker-compose-create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ services:
- zookeeper
client:
build: ../
image: localhost:5000/yolean/kafka-topic-client:$PUSH_TAG
labels:
com.yolean.build-contract: ""
com.yolean.build-target: ""
links:
- zookeeper
test:
Expand Down
80 changes: 80 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

repositories {
mavenCentral()
jcenter()
maven {
url "http://packages.confluent.io/maven/"
}
}

apply plugin: 'java'
apply plugin: "idea"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "jacoco"

group 'se.yolean'

sourceCompatibility = 1.8

apply plugin: 'application'
mainClassName = 'se.yolean.kafka.topic.client.cli.Client'

configurations {
compile.exclude group: 'org.slf4j', module: 'slf4j-log4j12'
compile.exclude group: 'log4j', module: 'log4j'
}

dependencies {
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'com.google.inject', name: 'guice', version: '4.1.0'

compile group: 'org.apache.kafka', name: 'kafka-clients', version: '1.0.0'

compile group: 'org.apache.kafka', name: 'kafka_2.12', version: '1.0.0'
compile group: 'com.101tec', name: 'zkclient', version: '0.10'

compile group: 'io.confluent', name: 'kafka-schema-registry-client', version: '4.0.0'

compile group: 'com.nurkiewicz.asyncretry', name: 'asyncretry', version: '0.0.7'

runtime group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
runtime group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.25'
compile group: 'structlog4j', name: 'structlog4j-api', version: '1.0.0'
compile group: 'structlog4j', name: 'structlog4j-json', version: '1.0.0'

compile group: 'io.prometheus', name: 'simpleclient', version: '0.1.0'
compile group: 'io.prometheus', name: 'simpleclient_httpserver', version: '0.1.0'

testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.12.0'
}

task copyToLib(type: Copy) {
into "$buildDir/libs"
from configurations.runtime
}

build.dependsOn(copyToLib)

// for .editorconfig support in Eclipse
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.standardout:gradle-eclipseconfig:1.1.0'
classpath 'org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:1.4.2'
classpath 'com.commercehub.gradle.plugin:gradle-avro-plugin:0.12.0'
}
}
apply plugin: 'org.standardout.eclipseconfig'

apply plugin: 'org.unbroken-dome.test-sets'
testSets {
itest
}

apply plugin: 'com.commercehub.gradle.plugin.avro'
avro {
}
Loading