-
-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deserialize Protobuf messages using descriptor files
- Loading branch information
Taisiia Goltseva
committed
Oct 22, 2020
1 parent
3ebfd4b
commit 22c4787
Showing
21 changed files
with
2,763 additions
and
8 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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/org/akhq/configs/ProtobufDeserializationTopicsMapping.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.akhq.configs; | ||
|
||
import io.micronaut.context.annotation.ConfigurationProperties; | ||
import lombok.Data; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@ConfigurationProperties("akhq.topic.deserialization.protobuf") | ||
@Data | ||
public class ProtobufDeserializationTopicsMapping { | ||
private String descriptorsFolder; | ||
private List<TopicsMapping> topicsMapping = new ArrayList<>(); | ||
} |
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.akhq.configs; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class TopicsMapping { | ||
String topicRegex; | ||
String descriptorFile; | ||
String keyMessageType; | ||
String valueMessageType; | ||
} |
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
21 changes: 21 additions & 0 deletions
21
src/main/java/org/akhq/repositories/CustomDeserializerRepository.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,21 @@ | ||
package org.akhq.repositories; | ||
|
||
import org.akhq.configs.ProtobufDeserializationTopicsMapping; | ||
import org.akhq.utils.ProtobufToJsonDeserializer; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
public class CustomDeserializerRepository { | ||
@Inject | ||
private ProtobufDeserializationTopicsMapping protobufDeserializationTopicsMapping; | ||
private ProtobufToJsonDeserializer protobufToJsonDeserializer; | ||
|
||
public ProtobufToJsonDeserializer getProtobufToJsonDeserializer() { | ||
if (this.protobufToJsonDeserializer == null) { | ||
this.protobufToJsonDeserializer = new ProtobufToJsonDeserializer(protobufDeserializationTopicsMapping); | ||
} | ||
return this.protobufToJsonDeserializer; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.akhq.utils; | ||
|
||
public class ProtobufConfig { | ||
private final String descriptorFile; | ||
private final String keyMessageType; | ||
private final String valueMessageType; | ||
|
||
public ProtobufConfig(String descriptorFile, String keyMessageType, String valueMessageType) { | ||
this.descriptorFile = descriptorFile; | ||
this.keyMessageType = keyMessageType; | ||
this.valueMessageType = valueMessageType; | ||
} | ||
|
||
public String getDescriptorFile() { | ||
return descriptorFile; | ||
} | ||
|
||
public String getKeyMessageType() { | ||
return keyMessageType; | ||
} | ||
|
||
public String getValueMessageType() { | ||
return valueMessageType; | ||
} | ||
} |
Oops, something went wrong.