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

Fix init #1

Merged
merged 1 commit into from
Mar 28, 2024
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
47 changes: 47 additions & 0 deletions .github/release_drafter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name-template: '$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
## Changes
$CHANGES
## Contributors
$CONTRIBUTORS

exclude-labels:
- 'scope/infrastructure'
- 'scope/QA'
- 'scope/AQA'
- 'type/dependencies'
- 'type/chore'
- 'type/documentation'
- 'type/refactoring'

categories:
- title: '⚙️Features'
labels:
- 'type/feature'
- title: '🪛Enhancements'
labels:
- 'type/enhancement'
- title: '🔨Bug Fixes'
labels:
- 'type/bug'
- title: 'Security'
labels:
- 'type/security'
- title: '⎈ Helm/K8S Changes'
labels:
- 'scope/k8s'

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'

version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
28 changes: 28 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Pull Request Build

on:

pull_request:
types: [ "opened", "reopened", "synchronize", ]

jobs:
release:
runs-on: ubuntu-latest
outputs:
version: ${{steps.build.outputs.version}}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
cache: 'maven'

- name: Build with Maven
id: build
run: |
mvn -B -V -ntp clean package
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
uses: svenstaro/upload-release-action@2.3.0
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/kafka-ui-smile-serde-${{ steps.build.outputs.version }}-jar-with-dependencies.jar
file: target/serde-smile-${{ steps.build.outputs.version }}-jar-with-dependencies.jar
tag: ${{ github.event.release.tag_name }}

- name: Archive JAR
uses: actions/upload-artifact@v3
with:
name: kafka-ui-smile-serde-${{ steps.build.outputs.version }}
path: target/kafka-ui-smile-serde-${{ steps.build.outputs.version }}-jar-with-dependencies.jar
name: serde-smile-${{ steps.build.outputs.version }}.jar
path: target/serde-smile-${{ steps.build.outputs.version }}-jar-with-dependencies.jar
19 changes: 19 additions & 0 deletions .github/workflows/release_drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
workflow_dispatch:

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release_drafter.yaml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 42 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/

### VS Code ###
.vscode/
/kafka-ui-api/app/node

.DS_Store
*.code-workspace


*.tar.gz
*.tgz

/docker/*.override.yaml
=======
# Compiled class file
*.class

Expand All @@ -20,4 +61,4 @@
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
hs_err_pid*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Smile serde plugin for kafka-ui

This is sample pluggable serde implementation for [kafka-ui](https://github.com/provectus/kafka-ui/).
This is sample pluggable serde implementation for [kafka-ui](https://github.com/kafbat/kafka-ui/).

This serde uses [Jackson library](https://github.com/FasterXML/jackson-dataformats-binary) as a [Smile](https://github.com/FasterXML/smile-format-specification) format parser/generator implementation.

Expand Down
8 changes: 4 additions & 4 deletions docker-compose/setup-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:

kafka-ui:
container_name: kafka-ui
image: provectuslabs/kafka-ui:latest
image: ghcr.io/kafbat/kafka-ui:latest
ports:
- 8080:8080
depends_on:
Expand All @@ -16,19 +16,19 @@ services:

kafka.clusters.0.serde.0.name: Smile (Default)
kafka.clusters.0.serde.0.filePath: /smile-serde/kafka-ui-smile-serde-0.0.1-SNAPSHOT-jar-with-dependencies.jar
kafka.clusters.0.serde.0.className: com.provectus.kafka.ui.serdes.smile.SmileSerde
kafka.clusters.0.serde.0.className: io.kafbat.serde.smile.SmileSerde

kafka.clusters.0.serde.1.name: Smile (Without header)
kafka.clusters.0.serde.1.filePath: /smile-serde/kafka-ui-smile-serde-0.0.1-SNAPSHOT-jar-with-dependencies.jar
kafka.clusters.0.serde.1.className: com.provectus.kafka.ui.serdes.smile.SmileSerde
kafka.clusters.0.serde.1.className: io.kafbat.serde.smile.SmileSerde
# you can enable/disable parsers's and generator's features:
kafka.clusters.0.serde.1.properties.generator.WRITE_HEADER: "false"
kafka.clusters.0.serde.1.properties.parser.REQUIRE_HEADER: "false"

# you can also use upper-cased variables like that:
# KAFKA_CLUSTERS_0_SERDE_1_NAME: Smile
# KAFKA_CLUSTERS_0_SERDE_1_FILE_PATH: /smile-serde
# KAFKA_CLUSTERS_0_SERDE_1_CLASS_NAME: com.provectus.kafka.ui.serdes.smile.SmileSerde
# KAFKA_CLUSTERS_0_SERDE_1_CLASS_NAME: io.kafbat.serde.smile.SmileSerde
# KAFKA_CLUSTERS_0_SERDE_1_PROPERTIES_PARSER_REQUIRE_HEADER: "false"
# KAFKA_CLUSTERS_0_SERDE_1_PROPERTIES_GENERATOR_WRITE_HEADER: "false"
volumes:
Expand Down
16 changes: 10 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<groupId>com.provectus</groupId>
<version>0.0.1-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<artifactId>kafka-ui-smile-serde</artifactId>

<groupId>io.kafbat.ui.serde</groupId>
<artifactId>serde-smile</artifactId>
<name>kafbat-ui-serde-glue</name>

<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand All @@ -17,11 +20,12 @@

<dependencies>
<dependency>
<groupId>com.provectus</groupId>
<artifactId>kafka-ui-serde-api</artifactId>
<version>1.1.0</version>
<groupId>io.kafbat.ui</groupId>
<artifactId>serde-api</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-smile</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.provectus.kafka.ui.serdes.smile;
package io.kafbat.serde.smile;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
Expand All @@ -7,11 +7,10 @@
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
import com.fasterxml.jackson.dataformat.smile.SmileParser;
import com.fasterxml.jackson.dataformat.smile.databind.SmileMapper;
import com.provectus.kafka.ui.serde.api.DeserializeResult;
import com.provectus.kafka.ui.serde.api.PropertyResolver;
import com.provectus.kafka.ui.serde.api.RecordHeaders;
import com.provectus.kafka.ui.serde.api.SchemaDescription;
import com.provectus.kafka.ui.serde.api.Serde;
import io.kafbat.ui.serde.api.DeserializeResult;
import io.kafbat.ui.serde.api.PropertyResolver;
import io.kafbat.ui.serde.api.SchemaDescription;
import io.kafbat.ui.serde.api.Serde;
import java.io.IOException;
import java.util.Collections;
import java.util.Optional;
Expand Down Expand Up @@ -59,32 +58,26 @@ public boolean canSerialize(String topic, Target target) {

@Override
public Serializer serializer(String topic, Target target) {
return new Serializer() {
@Override
public byte[] serialize(String inputString) {
try {
JsonNode jsonNode = JSON_MAPPER.readTree(inputString);
return smileMapper.writeValueAsBytes(jsonNode);
} catch (JsonProcessingException e) {
throw new RuntimeException("Serialization error", e);
}
return inputString -> {
try {
JsonNode jsonNode = JSON_MAPPER.readTree(inputString);
return smileMapper.writeValueAsBytes(jsonNode);
} catch (JsonProcessingException e) {
throw new RuntimeException("Serialization error", e);
}
};
}

@Override
public Deserializer deserializer(String topic, Target target) {
return new Deserializer() {
@Override
public DeserializeResult deserialize(RecordHeaders recordHeaders, byte[] bytes) {
try {
return new DeserializeResult(
smileMapper.readTree(bytes).toString(),
DeserializeResult.Type.JSON,
Collections.emptyMap());
} catch (IOException e) {
throw new RuntimeException("Deserialization error", e);
}
return (recordHeaders, bytes) -> {
try {
return new DeserializeResult(
smileMapper.readTree(bytes).toString(),
DeserializeResult.Type.JSON,
Collections.emptyMap());
} catch (IOException e) {
throw new RuntimeException("Deserialization error", e);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package com.provectus.kafka.ui.serdes.smile;
package io.kafbat.serde.smile;


import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
import com.fasterxml.jackson.dataformat.smile.SmileParser;
import com.provectus.kafka.ui.serde.api.DeserializeResult;
import com.provectus.kafka.ui.serde.api.PropertyResolver;
import com.provectus.kafka.ui.serde.api.Serde;
import io.kafbat.ui.serde.api.DeserializeResult;
import io.kafbat.ui.serde.api.PropertyResolver;
import io.kafbat.ui.serde.api.Serde;
import java.util.Map;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Loading