Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 5 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
# Compiled class file
*.class
.idea

# Log file
*.log
# Ignore Gradle project-specific cache directory
.gradle

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# Ignore Gradle build output directory
build
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: java

git:
depth: 3

jdk:
- openjdk8
- openjdk11

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Aiven Kafka Connect Transformations

[![Build Status](https://travis-ci.org/aiven/aiven-kafka-connect-transforms.svg?branch=master)](https://travis-ci.org/aiven/aiven-kafka-connect-transforms)

This is a set of [Kafka Connect transformations](https://kafka.apache.org/documentation/#connect_transforms).

## Transformations

### `ExtractTopic`

This transformation extracts a string value from the message and use it as the topic name.

The transformation can use either the whole key or value (in this case, it must have `STRING` type) or a field in them (in this case, it must have `STRUCT` type and the field's value must be `STRING`).

Exists in two variants:
- `io.aiven.kafka.connect.transforms.ExtractTopic$Key` - works on keys;
- `io.aiven.kafka.connect.transforms.ExtractTopic$Value` - works on values.

The transformation defines the following configurations:

- `field.name` - The name of the field which should be used as the topic name. If `null` or empty, the entire key or value is used (and assumed to be a string). By default is `null`.
- `skip.missing.or.null` - In case the source of the new topic name is `null` or missing, should a record be silently passed without transformation. By default is `false`.

Here's an example of this transformation configuration:

```properties
transforms=ExtractTopicFromValueField
transforms.ExtractTopicFromValueField.field.name=inner_field_name
```

See [the Kafka documentation](https://kafka.apache.org/documentation/#connect_transforms) for more details about configuring transformations.

## License

This project is licensed under the [Apache License, Version 2.0](LICENSE).
81 changes: 81 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2019 Aiven Oy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
// https://docs.gradle.org/current/userguide/java_library_plugin.html
id 'java-library'

// https://docs.gradle.org/current/userguide/distribution_plugin.html
id 'distribution'

// https://docs.gradle.org/current/userguide/checkstyle_plugin.html
id 'checkstyle'
}

repositories {
jcenter()
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

ext {
kafkaVersion = "2.0.1"
}

distributions {
main {
contents {
from jar
from configurations.runtimeClasspath
}
}
}

dependencies {
compileOnly "org.apache.kafka:connect-api:$kafkaVersion"

implementation "org.slf4j:slf4j-api:1.7.25"

testImplementation "org.junit.jupiter:junit-jupiter:5.5.1"
testImplementation "org.hamcrest:hamcrest:2.1"
testImplementation "org.apache.kafka:connect-api:$kafkaVersion"
testRuntime "org.apache.logging.log4j:log4j-slf4j-impl:2.12.1"
}

checkstyle {
toolVersion "8.21"
}

test {
useJUnitPlatform {
includeEngines 'junit-jupiter'
}
}

processResources {
filesMatching('aiven-kafka-connect-transforms-version.properties') {
expand(version: version)
}
}

jar {
manifest {
attributes(
'Version': "${getArchiveVersion()}"
)
}
}
Loading