Reorganization of grpc code

This commit is contained in:
Oleg Zhurakousky
2021-10-18 17:55:33 +02:00
parent 56980271b9
commit 4965baab55
26 changed files with 55 additions and 73 deletions

View File

@@ -166,7 +166,6 @@
<module>spring-cloud-function-deployer</module> <module>spring-cloud-function-deployer</module>
<module>spring-cloud-function-adapters</module> <module>spring-cloud-function-adapters</module>
<module>spring-cloud-function-rsocket</module> <module>spring-cloud-function-rsocket</module>
<module>spring-cloud-function-grpc</module>
<module>spring-cloud-function-kotlin</module> <module>spring-cloud-function-kotlin</module>
<module>docs</module> <module>docs</module>
</modules> </modules>

View File

@@ -19,6 +19,7 @@
<module>spring-cloud-function-adapter-aws</module> <module>spring-cloud-function-adapter-aws</module>
<module>spring-cloud-function-adapter-azure</module> <module>spring-cloud-function-adapter-azure</module>
<module>spring-cloud-function-adapter-gcp</module> <module>spring-cloud-function-adapter-gcp</module>
<module>spring-cloud-function-grpc</module>
<module>spring-cloud-function-grpc-cloudevent-ext</module> <module>spring-cloud-function-grpc-cloudevent-ext</module>
</modules> </modules>

View File

@@ -3,16 +3,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-cloud-function-adapter-parent</artifactId>
<version>2.6.0-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-grpc-cloudevent-ext</artifactId> <artifactId>spring-cloud-function-grpc-cloudevent-ext</artifactId>
<version>3.2.0-SNAPSHOT</version> <name>spring-cloud-function-grpc-cloudevent-ext</name>
<name> </name> <description>CloudEvent extension for spring-cloud-function-grpc</description>
<description>CloudEvent extansion for spring-cloud-function-grpc</description>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
</properties> </properties>

View File

@@ -16,15 +16,14 @@
package org.springframework.cloud.function.grpc.ce; package org.springframework.cloud.function.grpc.ce;
import io.grpc.BindableService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.function.grpc.MessageHandlingHelper; import org.springframework.cloud.function.grpc.MessageHandlingHelper;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import io.grpc.BindableService;
/** /**
* *
* @author Oleg Zhurakousky * @author Oleg Zhurakousky
@@ -34,6 +33,7 @@ import io.grpc.BindableService;
@ConditionalOnProperty(name = "spring.cloud.function.grpc.server", havingValue = "true", matchIfMissing = true) @ConditionalOnProperty(name = "spring.cloud.function.grpc.server", havingValue = "true", matchIfMissing = true)
public class CloudEventGrpcAutoConfiguration { public class CloudEventGrpcAutoConfiguration {
@SuppressWarnings("rawtypes")
@Bean @Bean
public BindableService cloudEventMessageHandler(MessageHandlingHelper helper) { public BindableService cloudEventMessageHandler(MessageHandlingHelper helper) {
return new CloudEventHandler(helper); return new CloudEventHandler(helper);

View File

@@ -14,47 +14,15 @@
* limitations under the License. * limitations under the License.
*/ */
/*
* Copyright 2021-2021 the original author or authors.
*
* 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
*
* https://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.
*/
/*
* Copyright 2021-2021 the original author or authors.
*
* 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
*
* https://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.
*/
package org.springframework.cloud.function.grpc.ce; package org.springframework.cloud.function.grpc.ce;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.function.grpc.MessageHandlingHelper;
import io.cloudevents.v1.CloudEventServiceGrpc.CloudEventServiceImplBase; import io.cloudevents.v1.CloudEventServiceGrpc.CloudEventServiceImplBase;
import io.cloudevents.v1.proto.CloudEvent; import io.cloudevents.v1.proto.CloudEvent;
import io.grpc.stub.StreamObserver; import io.grpc.stub.StreamObserver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.cloud.function.grpc.MessageHandlingHelper;
/** /**
* *
@@ -67,13 +35,11 @@ class CloudEventHandler extends CloudEventServiceImplBase {
private Log logger = LogFactory.getLog(CloudEventHandler.class); private Log logger = LogFactory.getLog(CloudEventHandler.class);
private final MessageHandlingHelper helper; private final MessageHandlingHelper helper;
public CloudEventHandler(MessageHandlingHelper helper) { CloudEventHandler(MessageHandlingHelper helper) {
this.helper = helper; this.helper = helper;
} }

View File

@@ -18,19 +18,18 @@ package org.springframework.cloud.function.grpc.ce;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.springframework.cloud.function.cloudevent.CloudEventMessageUtils;
import org.springframework.cloud.function.grpc.AbstractGrpcMessageConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import com.google.protobuf.GeneratedMessageV3; import com.google.protobuf.GeneratedMessageV3;
import io.cloudevents.v1.proto.CloudEvent; import io.cloudevents.v1.proto.CloudEvent;
import io.cloudevents.v1.proto.CloudEvent.Builder; import io.cloudevents.v1.proto.CloudEvent.Builder;
import io.cloudevents.v1.proto.CloudEvent.CloudEventAttributeValue; import io.cloudevents.v1.proto.CloudEvent.CloudEventAttributeValue;
import io.cloudevents.v1.proto.CloudEvent.CloudEventAttributeValue.AttrCase; import io.cloudevents.v1.proto.CloudEvent.CloudEventAttributeValue.AttrCase;
import org.springframework.cloud.function.cloudevent.CloudEventMessageUtils;
import org.springframework.cloud.function.grpc.AbstractGrpcMessageConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
/** /**
* *
* @author Oleg Zhurakousky * @author Oleg Zhurakousky

View File

@@ -1,6 +1,21 @@
/*
* Copyright 2021-2021 the original author or authors.
*
* 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
*
* https://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.
*/
package org.springframework.cloud.grpc.ce; package org.springframework.cloud.grpc.ce;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest @SpringBootTest

View File

@@ -6,18 +6,18 @@
<artifactId>spring-cloud-function-grpc</artifactId> <artifactId>spring-cloud-function-grpc</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Spring Cloud Function gRPC Support</name> <name>spring-cloud-function-grpc</name>
<description>Spring Cloud Function gRPC Support</description> <description>Spring Cloud Function gRPC Support</description>
<parent> <parent>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-parent</artifactId> <artifactId>spring-cloud-function-adapter-parent</artifactId>
<version>3.2.0-SNAPSHOT</version> <version>3.2.0-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>
<grpc.version>1.16.1</grpc.version> <grpc.version>1.16.1</grpc.version>
<disable.checks>true</disable.checks> <disable.checks>true</disable.checks>
</properties> </properties>
<dependencies> <dependencies>
@@ -93,10 +93,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- <plugin> -->
<!-- <groupId>org.springframework.boot</groupId> -->
<!-- <artifactId>spring-boot-maven-plugin</artifactId> -->
<!-- </plugin> -->
</plugins> </plugins>
</build> </build>

View File

@@ -18,6 +18,8 @@ package org.springframework.cloud.function.grpc;
import java.util.List; import java.util.List;
import io.grpc.BindableService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.function.context.FunctionCatalog; import org.springframework.cloud.function.context.FunctionCatalog;
@@ -27,10 +29,6 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.google.protobuf.GeneratedMessageV3;
import io.grpc.BindableService;
/** /**
* *
* @author Oleg Zhurakousky * @author Oleg Zhurakousky

View File

@@ -76,6 +76,16 @@
<artifactId>spring-cloud-function-rsocket</artifactId> <artifactId>spring-cloud-function-rsocket</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-grpc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-grpc-cloudevent-ext</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<profiles> <profiles>

View File

@@ -2,11 +2,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.0-SNAPSHOT</version> <version>2.6.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/>
</parent> </parent>
<groupId>com.example.grpc</groupId> <groupId>com.example.grpc</groupId>
<artifactId>function-sample-grpc-cloudevent</artifactId> <artifactId>function-sample-grpc-cloudevent</artifactId>
@@ -25,10 +27,9 @@
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-grpc-cloudevent-ext</artifactId> <artifactId>spring-cloud-function-grpc-cloudevent-ext</artifactId>
<version>3.2.0-SNAPSHOT</version> <!-- <version>3.2.0-SNAPSHOT</version> -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.grpc</groupId> <groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId> <artifactId>grpc-netty</artifactId>

View File

@@ -31,7 +31,7 @@
<module>function-sample-cloudevent-stream</module> <module>function-sample-cloudevent-stream</module>
<module>function-sample-cloudevent-rsocket</module> <module>function-sample-cloudevent-rsocket</module>
<module>function-sample-kotlin-web</module> <module>function-sample-kotlin-web</module>
<!-- <module>function-sample-grpc-cloudevent</module> --> <module>function-sample-grpc-cloudevent</module>
</modules> </modules>
<build> <build>