mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-14 14:17:56 +00:00
feat[protocol]: 支持生成protobuf协议文件,提供从pojo到proto的生成方式
This commit is contained in:
1 parent
b39fc50a21
commit
b0ba151a8c
34 files changed
+607
-77
No files matched your search
@@ -38,6 +38,7 @@ public class NetConfig {
|
||||
private boolean generateCsProtocol;
|
||||
private boolean generateLuaProtocol;
|
||||
private boolean generateGdProtocol;
|
||||
private boolean generateProtobufProtocol;
|
||||
|
||||
private RegistryConfig registry;
|
||||
private MonitorConfig monitor;
|
||||
@@ -154,6 +155,14 @@ public class NetConfig {
|
||||
this.generateGdProtocol = generateGdProtocol;
|
||||
}
|
||||
|
||||
public boolean isGenerateProtobufProtocol() {
|
||||
return generateProtobufProtocol;
|
||||
}
|
||||
|
||||
public void setGenerateProtobufProtocol(boolean generateProtobufProtocol) {
|
||||
this.generateProtobufProtocol = generateProtobufProtocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
||||
@@ -359,7 +359,7 @@ public class ZookeeperRegistry implements IRegistry {
|
||||
private void initConsumerCache() throws Exception {
|
||||
// 初始化providerCacheSet
|
||||
var remoteProviderSet = curator.getChildren().forPath(PROVIDER_ROOT_PATH).stream()
|
||||
.filter(it -> !StringUtils.isBlank(it) && !"null".equals(it))
|
||||
.filter(it -> StringUtils.isNotBlank(it) && !"null".equals(it))
|
||||
.map(it -> RegisterVO.parseString(it))
|
||||
.filter(it -> Objects.nonNull(it))
|
||||
.filter(it -> RegisterVO.providerHasConsumerModule(it, localRegisterVO))
|
||||
@@ -505,7 +505,7 @@ public class ZookeeperRegistry implements IRegistry {
|
||||
public List<String> children(String path) {
|
||||
try {
|
||||
var children = curator.getChildren().forPath(path).stream()
|
||||
.filter(it -> !StringUtils.isBlank(it) && !"null".equals(it))
|
||||
.filter(it -> StringUtils.isNotBlank(it) && !"null".equals(it))
|
||||
.collect(Collectors.toList());
|
||||
return children;
|
||||
} catch (Exception e) {
|
||||
@@ -520,7 +520,7 @@ public class ZookeeperRegistry implements IRegistry {
|
||||
public Set<RegisterVO> remoteProviderRegisterSet() {
|
||||
try {
|
||||
var remoteProviderSet = curator.getChildren().forPath(PROVIDER_ROOT_PATH).stream()
|
||||
.filter(it -> !StringUtils.isBlank(it) && !"null".equals(it))
|
||||
.filter(it -> StringUtils.isNotBlank(it) && !"null".equals(it))
|
||||
.map(it -> RegisterVO.parseString(it))
|
||||
.filter(it -> Objects.nonNull(it))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
@@ -89,6 +89,7 @@ public class PacketService implements IPacketService {
|
||||
var generateCsharpProtocol = NetContext.getConfigManager().getLocalConfig().isGenerateCsProtocol();
|
||||
var generateLuaProtocol = NetContext.getConfigManager().getLocalConfig().isGenerateLuaProtocol();
|
||||
var generateGdProtocol = NetContext.getConfigManager().getLocalConfig().isGenerateGdProtocol();
|
||||
var generateProtobufProtocol = NetContext.getConfigManager().getLocalConfig().isGenerateProtobufProtocol();
|
||||
var generateOperation = new GenerateOperation();
|
||||
generateOperation.setFoldProtocol(foldProtocol);
|
||||
generateOperation.setProtocolPath(protocolPath);
|
||||
@@ -105,6 +106,9 @@ public class PacketService implements IPacketService {
|
||||
if (generateGdProtocol) {
|
||||
generateOperation.getGenerateLanguages().add(CodeLanguage.GdScript);
|
||||
}
|
||||
if (generateProtobufProtocol) {
|
||||
generateOperation.getGenerateLanguages().add(CodeLanguage.Protobuf);
|
||||
}
|
||||
|
||||
// 设置生成协议的过滤器
|
||||
GenerateProtocolFile.generateProtocolFilter = netGenerateProtocolFilter;
|
||||
|
||||
@@ -93,6 +93,7 @@ public class NetDefinitionParser implements BeanDefinitionParser {
|
||||
resolvePlaceholder("generate-cs-protocol", "generateCsProtocol", builder, element, parserContext);
|
||||
resolvePlaceholder("generate-lua-protocol", "generateLuaProtocol", builder, element, parserContext);
|
||||
resolvePlaceholder("generate-gd-protocol", "generateGdProtocol", builder, element, parserContext);
|
||||
resolvePlaceholder("generate-protobuf-protocol", "generateProtobufProtocol", builder, element, parserContext);
|
||||
resolvePlaceholder("fold-protocol", "foldProtocol", builder, element, parserContext);
|
||||
resolvePlaceholder("protocol-path", "protocolPath", builder, element, parserContext);
|
||||
resolvePlaceholder("protocol-param", "protocolParam", builder, element, parserContext);
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
<xsd:attribute name="generate-cs-protocol" type="xsd:string" default="false"/>
|
||||
<xsd:attribute name="generate-lua-protocol" type="xsd:string" default="false"/>
|
||||
<xsd:attribute name="generate-gd-protocol" type="xsd:string" default="false"/>
|
||||
<xsd:attribute name="generate-protobuf-protocol" type="xsd:string" default="false"/>
|
||||
<xsd:attribute name="fold-protocol" type="xsd:string" default="false"/>
|
||||
<xsd:attribute name="protocol-path" type="xsd:string"/>
|
||||
<xsd:attribute name="protocol-param" type="xsd:string"/>
|
||||
|
||||
Reference in new issue
Block a user