-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding serde for config change event key and value (#104)
- Loading branch information
1 parent
9b32001
commit 0191004
Showing
10 changed files
with
104 additions
and
5 deletions.
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 |
---|---|---|
|
@@ -23,4 +23,5 @@ sourceSets { | |
|
||
dependencies { | ||
api(libs.protobuf.java) | ||
api(libs.kafka.clients) | ||
} |
14 changes: 14 additions & 0 deletions
14
...src/main/java/org/hypertrace/config/change/event/v1/ConfigChangeEventKeyDeserializer.java
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,14 @@ | ||
package org.hypertrace.config.change.event.v1; | ||
|
||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import org.apache.kafka.common.serialization.Deserializer; | ||
|
||
public class ConfigChangeEventKeyDeserializer implements Deserializer<ConfigChangeEventKey> { | ||
public ConfigChangeEventKey deserialize(String topic, byte[] data) { | ||
try { | ||
return ConfigChangeEventKey.parseFrom(data); | ||
} catch (InvalidProtocolBufferException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...nt-api/src/main/java/org/hypertrace/config/change/event/v1/ConfigChangeEventKeySerde.java
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,24 @@ | ||
package org.hypertrace.config.change.event.v1; | ||
|
||
import java.util.Map; | ||
import org.apache.kafka.common.serialization.Deserializer; | ||
import org.apache.kafka.common.serialization.Serde; | ||
import org.apache.kafka.common.serialization.Serializer; | ||
|
||
public class ConfigChangeEventKeySerde implements Serde<ConfigChangeEventKey> { | ||
@Override | ||
public void configure(Map<String, ?> configs, boolean isKey) {} | ||
|
||
@Override | ||
public void close() {} | ||
|
||
@Override | ||
public Serializer<ConfigChangeEventKey> serializer() { | ||
return new ConfigChangeEventKeySerializer(); | ||
} | ||
|
||
@Override | ||
public Deserializer<ConfigChangeEventKey> deserializer() { | ||
return new ConfigChangeEventKeyDeserializer(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...i/src/main/java/org/hypertrace/config/change/event/v1/ConfigChangeEventKeySerializer.java
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,10 @@ | ||
package org.hypertrace.config.change.event.v1; | ||
|
||
import org.apache.kafka.common.serialization.Serializer; | ||
|
||
public class ConfigChangeEventKeySerializer implements Serializer<ConfigChangeEventKey> { | ||
@Override | ||
public byte[] serialize(String topic, ConfigChangeEventKey data) { | ||
return data.toByteArray(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...c/main/java/org/hypertrace/config/change/event/v1/ConfigChangeEventValueDeserializer.java
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,16 @@ | ||
package org.hypertrace.config.change.event.v1; | ||
|
||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import org.apache.kafka.common.serialization.Deserializer; | ||
|
||
public class ConfigChangeEventValueDeserializer implements Deserializer<ConfigChangeEventValue> { | ||
|
||
@Override | ||
public ConfigChangeEventValue deserialize(String topic, byte[] data) { | ||
try { | ||
return ConfigChangeEventValue.parseFrom(data); | ||
} catch (InvalidProtocolBufferException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...-api/src/main/java/org/hypertrace/config/change/event/v1/ConfigChangeEventValueSerde.java
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,24 @@ | ||
package org.hypertrace.config.change.event.v1; | ||
|
||
import java.util.Map; | ||
import org.apache.kafka.common.serialization.Deserializer; | ||
import org.apache.kafka.common.serialization.Serde; | ||
import org.apache.kafka.common.serialization.Serializer; | ||
|
||
public class ConfigChangeEventValueSerde implements Serde<ConfigChangeEventValue> { | ||
@Override | ||
public void configure(Map<String, ?> configs, boolean isKey) {} | ||
|
||
@Override | ||
public void close() {} | ||
|
||
@Override | ||
public Serializer<ConfigChangeEventValue> serializer() { | ||
return new ConfigChangeEventValueSerializer(); | ||
} | ||
|
||
@Override | ||
public Deserializer<ConfigChangeEventValue> deserializer() { | ||
return new ConfigChangeEventValueDeserializer(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...src/main/java/org/hypertrace/config/change/event/v1/ConfigChangeEventValueSerializer.java
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,11 @@ | ||
package org.hypertrace.config.change.event.v1; | ||
|
||
import org.apache.kafka.common.serialization.Serializer; | ||
|
||
public class ConfigChangeEventValueSerializer implements Serializer<ConfigChangeEventValue> { | ||
|
||
@Override | ||
public byte[] serialize(String topic, ConfigChangeEventValue data) { | ||
return data.toByteArray(); | ||
} | ||
} |
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
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
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