You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/04/25 13:47:31 UTC

[GitHub] [rocketmq-eventbridge] supercym opened a new pull request, #9: support http source

supercym opened a new pull request, #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9

   support http source, users can post events to EventBridge through webhook.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] supercym commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
supercym commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r865581521


##########
common/src/main/java/org/apache/rocketmq/eventbridge/tools/ARNHelper.java:
##########
@@ -0,0 +1,63 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.tools;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:22 上午
+ */
+public class ARNHelper {
+    public static final String EVENTBUS_ALL = "eventbus/*";
+    public static final String EVENTBUS_PATTERN = "eventbus/%s";
+    public static final String EVENTRULE_ALL = "eventbus/%s/rule/*";

Review Comment:
   The corresponding class has been deleted, and the related configuration is placed in HttpEventAPIImpl.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] 2011shenlin commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
2011shenlin commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r858231648


##########
domain/src/main/java/org/apache/rocketmq/eventbridge/domain/cache/EventSourceCacheService.java:
##########
@@ -0,0 +1,96 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.domain.cache;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.eventbridge.domain.model.bus.EventBus;
+import org.apache.rocketmq.eventbridge.domain.model.source.EventSource;
+import org.apache.rocketmq.eventbridge.domain.repository.EventBusRepository;
+import org.apache.rocketmq.eventbridge.domain.repository.EventSourceRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+
+import static org.apache.rocketmq.eventbridge.domain.cache.CacheName.EVENT_SOURCE;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:15 上午
+ */
+@Component
+@CacheConfig(cacheNames = EVENT_SOURCE, cacheManager = "cacheManager")
+public class EventSourceCacheService {

Review Comment:
   EventSourceCacheService and EventSourceService should not be separated. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] zhouxinyu merged pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
zhouxinyu merged PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] 2011shenlin commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
2011shenlin commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r858229544


##########
domain/src/main/java/org/apache/rocketmq/eventbridge/domain/model/source/HTTPEventSourceService.java:
##########
@@ -17,18 +17,56 @@
 
 package org.apache.rocketmq.eventbridge.domain.model.source;
 
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.stream.Collectors;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.rocketmq.eventbridge.domain.common.enums.EventSourceTypeEnum;
+import org.apache.rocketmq.eventbridge.domain.model.PaginationResult;
 import org.apache.rocketmq.eventbridge.domain.model.bus.EventBusService;
 import org.apache.rocketmq.eventbridge.domain.repository.EventSourceRepository;
+import org.apache.rocketmq.eventbridge.exception.EventBridgeException;
+import org.apache.rocketmq.eventbridge.tools.NetUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.DigestUtils;
+
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.ExceedHttpSourceParametersCount;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.GenerateTokenError;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.HttpSourceParametersEmpty;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.HttpSourceParametersInvalid;
+
 @Service
 public class HTTPEventSourceService extends EventSourceService {
 
     private static final String CLASS_NAME = "HttpEvent";
 
+    private static final Integer GET_TOKEN_TIMES = 100;
+    public static final String PUBLIC_HTTP_WEBHOOK_SCHEMA = "http://%s.eventbridge.%s.aliyuncs.com/webhook/putEvents?token=%s";
+    public static final String PUBLIC_HTTPS_WEBHOOK_SCHEMA = "https://%s.eventbridge.%s.aliyuncs.com/webhook/putEvents?token=%s";

Review Comment:
   Remove the  config around aliyun, change to the config with cluster endpoint.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] supercym commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
supercym commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r865580936


##########
adapter/api/src/main/java/org/apache/rocketmq/eventbridge/adapter/api/converter/HttpEventConverter.java:
##########
@@ -0,0 +1,293 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.adapter.api.converter;
+
+import com.google.common.net.MediaType;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.v1.CloudEventBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.rocketmq.eventbridge.adapter.api.dto.data.HttpEventData;
+import org.apache.rocketmq.eventbridge.domain.cache.EventSourceCacheService;
+import org.apache.rocketmq.eventbridge.domain.model.source.EventSource;
+import org.apache.rocketmq.eventbridge.exception.EventBridgeException;
+import org.apache.rocketmq.eventbridge.tools.ARNHelper;
+import org.apache.rocketmq.eventbridge.tools.NetUtil;
+import org.apache.rocketmq.eventbridge.tools.transform.Data;
+import org.apache.rocketmq.eventbridge.tools.transform.StringData;
+import org.apache.rocketmq.eventbridge.tools.transform.Transform;
+import org.apache.rocketmq.eventbridge.tools.transform.TransformBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.time.OffsetDateTime;
+import java.time.ZonedDateTime;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.JSON_ATTRIBUTE_INVALID;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.PutEventsRequestSecurityCheckFailed;
+import static org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_IP;
+import static org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_NONE;
+import static org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_REFERER;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:28 上午
+ */
+@Service
+public class HttpEventConverter {
+    private static final Logger logger = LoggerFactory.getLogger(HttpEventConverter.class);
+
+    @Autowired
+    EventSourceCacheService eventSourceCacheService;
+
+    private static final String TYPE = "eventbridge:Events:HTTPEvent";
+    private static final String DATA_CONTENT_TYPE = "application/json";
+
+    private static final String HEADER_X_REAL_IP = "x-real-ip";
+    public static final String HEADER_EVENTBRIDGE_DATE = "x-eventbridge-date";
+
+    private static final String SECURITY_CONFIG = "SecurityConfig";
+    private static final String IP_CONFIG = "Ip";
+    private static final String METHOD_CONFIG = "Method";
+    private static final String REFERER_CONFIG = "Referer";
+
+    public static final String EXTENSION_REGIONID = "aliyunregionid";
+    public static final String EXTENSION_ACCOUNTID = "aliyunaccountid";
+    public static final String EXTENSION_PUBLISHADDR = "aliyunpublishaddr";

Review Comment:
   The use of these configurations has been moved to the impl of rpc package



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] supercym commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
supercym commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r865581650


##########
common/src/main/java/org/apache/rocketmq/eventbridge/tools/RamResource.java:
##########
@@ -0,0 +1,60 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.tools;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:22 上午
+ */
+public enum RamResource {
+    EventBusAll("acs:eventbridge:%s:%s:eventbus/*"),
+
+    /**
+     * EventBus 资源Pattern
+     */
+    EventBus("acs:eventbridge:%s:%s:eventbus/%s"),
+
+    EventRuleAll("acs:eventbridge:%s:%s:eventbus/%s/rule/*"),
+
+    /**
+     * EventRule 资源Pattern
+     */
+    EventRule("acs:eventbridge:%s:%s:eventbus/%s/rule/%s"),

Review Comment:
   The corresponding class has been deleted, and the related configuration is placed in HttpEventAPIImpl.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] 2011shenlin commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
2011shenlin commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r858230001


##########
adapter/api/src/main/java/org/apache/rocketmq/eventbridge/adapter/api/converter/HttpEventConverter.java:
##########
@@ -0,0 +1,293 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.adapter.api.converter;
+
+import com.google.common.net.MediaType;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import io.cloudevents.CloudEvent;
+import io.cloudevents.core.v1.CloudEventBuilder;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.net.util.SubnetUtils;
+import org.apache.rocketmq.eventbridge.adapter.api.dto.data.HttpEventData;
+import org.apache.rocketmq.eventbridge.domain.cache.EventSourceCacheService;
+import org.apache.rocketmq.eventbridge.domain.model.source.EventSource;
+import org.apache.rocketmq.eventbridge.exception.EventBridgeException;
+import org.apache.rocketmq.eventbridge.tools.ARNHelper;
+import org.apache.rocketmq.eventbridge.tools.NetUtil;
+import org.apache.rocketmq.eventbridge.tools.transform.Data;
+import org.apache.rocketmq.eventbridge.tools.transform.StringData;
+import org.apache.rocketmq.eventbridge.tools.transform.Transform;
+import org.apache.rocketmq.eventbridge.tools.transform.TransformBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.lang.reflect.Type;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.time.OffsetDateTime;
+import java.time.ZonedDateTime;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.JSON_ATTRIBUTE_INVALID;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.PutEventsRequestSecurityCheckFailed;
+import static org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_IP;
+import static org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_NONE;
+import static org.apache.rocketmq.eventbridge.domain.model.source.HTTPEventSourceService.SECURITY_CONFIG_REFERER;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:28 上午
+ */
+@Service
+public class HttpEventConverter {
+    private static final Logger logger = LoggerFactory.getLogger(HttpEventConverter.class);
+
+    @Autowired
+    EventSourceCacheService eventSourceCacheService;
+
+    private static final String TYPE = "eventbridge:Events:HTTPEvent";
+    private static final String DATA_CONTENT_TYPE = "application/json";
+
+    private static final String HEADER_X_REAL_IP = "x-real-ip";
+    public static final String HEADER_EVENTBRIDGE_DATE = "x-eventbridge-date";
+
+    private static final String SECURITY_CONFIG = "SecurityConfig";
+    private static final String IP_CONFIG = "Ip";
+    private static final String METHOD_CONFIG = "Method";
+    private static final String REFERER_CONFIG = "Referer";
+
+    public static final String EXTENSION_REGIONID = "aliyunregionid";
+    public static final String EXTENSION_ACCOUNTID = "aliyunaccountid";
+    public static final String EXTENSION_PUBLISHADDR = "aliyunpublishaddr";

Review Comment:
   Remove the code around aliyun, if needed , change to the SPI  and move the impl to rpc package.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] 2011shenlin commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
2011shenlin commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r858231253


##########
common/src/main/java/org/apache/rocketmq/eventbridge/tools/RamResource.java:
##########
@@ -0,0 +1,60 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.tools;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:22 上午
+ */
+public enum RamResource {
+    EventBusAll("acs:eventbridge:%s:%s:eventbus/*"),
+
+    /**
+     * EventBus 资源Pattern
+     */
+    EventBus("acs:eventbridge:%s:%s:eventbus/%s"),
+
+    EventRuleAll("acs:eventbridge:%s:%s:eventbus/%s/rule/*"),
+
+    /**
+     * EventRule 资源Pattern
+     */
+    EventRule("acs:eventbridge:%s:%s:eventbus/%s/rule/%s"),

Review Comment:
   RAM/ARN is the concept from aliyun , is inappropriate to use here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] supercym commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
supercym commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r865579946


##########
domain/src/main/java/org/apache/rocketmq/eventbridge/domain/model/source/HTTPEventSourceService.java:
##########
@@ -17,18 +17,56 @@
 
 package org.apache.rocketmq.eventbridge.domain.model.source;
 
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.stream.Collectors;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.rocketmq.eventbridge.domain.common.enums.EventSourceTypeEnum;
+import org.apache.rocketmq.eventbridge.domain.model.PaginationResult;
 import org.apache.rocketmq.eventbridge.domain.model.bus.EventBusService;
 import org.apache.rocketmq.eventbridge.domain.repository.EventSourceRepository;
+import org.apache.rocketmq.eventbridge.exception.EventBridgeException;
+import org.apache.rocketmq.eventbridge.tools.NetUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.DigestUtils;
+
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.ExceedHttpSourceParametersCount;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.GenerateTokenError;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.HttpSourceParametersEmpty;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.HttpSourceParametersInvalid;
+
 @Service
 public class HTTPEventSourceService extends EventSourceService {
 
     private static final String CLASS_NAME = "HttpEvent";
 
+    private static final Integer GET_TOKEN_TIMES = 100;
+    public static final String PUBLIC_HTTP_WEBHOOK_SCHEMA = "http://%s.eventbridge.%s.aliyuncs.com/webhook/putEvents?token=%s";
+    public static final String PUBLIC_HTTPS_WEBHOOK_SCHEMA = "https://%s.eventbridge.%s.aliyuncs.com/webhook/putEvents?token=%s";

Review Comment:
   Moved webhook schema configuration to LocalConfig



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] 2011shenlin commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
2011shenlin commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r858229544


##########
domain/src/main/java/org/apache/rocketmq/eventbridge/domain/model/source/HTTPEventSourceService.java:
##########
@@ -17,18 +17,56 @@
 
 package org.apache.rocketmq.eventbridge.domain.model.source;
 
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.stream.Collectors;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.rocketmq.eventbridge.domain.common.enums.EventSourceTypeEnum;
+import org.apache.rocketmq.eventbridge.domain.model.PaginationResult;
 import org.apache.rocketmq.eventbridge.domain.model.bus.EventBusService;
 import org.apache.rocketmq.eventbridge.domain.repository.EventSourceRepository;
+import org.apache.rocketmq.eventbridge.exception.EventBridgeException;
+import org.apache.rocketmq.eventbridge.tools.NetUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.DigestUtils;
+
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.ExceedHttpSourceParametersCount;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.GenerateTokenError;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.HttpSourceParametersEmpty;
+import static org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.HttpSourceParametersInvalid;
+
 @Service
 public class HTTPEventSourceService extends EventSourceService {
 
     private static final String CLASS_NAME = "HttpEvent";
 
+    private static final Integer GET_TOKEN_TIMES = 100;
+    public static final String PUBLIC_HTTP_WEBHOOK_SCHEMA = "http://%s.eventbridge.%s.aliyuncs.com/webhook/putEvents?token=%s";
+    public static final String PUBLIC_HTTPS_WEBHOOK_SCHEMA = "https://%s.eventbridge.%s.aliyuncs.com/webhook/putEvents?token=%s";

Review Comment:
   remove the  config around aliyun, change to the config with cluster endpoint.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] 2011shenlin commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
2011shenlin commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r858231044


##########
common/src/main/java/org/apache/rocketmq/eventbridge/tools/ARNHelper.java:
##########
@@ -0,0 +1,63 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.tools;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:22 上午
+ */
+public class ARNHelper {
+    public static final String EVENTBUS_ALL = "eventbus/*";
+    public static final String EVENTBUS_PATTERN = "eventbus/%s";
+    public static final String EVENTRULE_ALL = "eventbus/%s/rule/*";

Review Comment:
   ARN is the concept from aliyun ,  is inappropriate to use here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-eventbridge] supercym commented on a diff in pull request #9: support http source

Posted by GitBox <gi...@apache.org>.
supercym commented on code in PR #9:
URL: https://github.com/apache/rocketmq-eventbridge/pull/9#discussion_r865582533


##########
domain/src/main/java/org/apache/rocketmq/eventbridge/domain/cache/EventSourceCacheService.java:
##########
@@ -0,0 +1,96 @@
+ /*
+  * Licensed to the Apache Software Foundation (ASF) under one or more
+  * contributor license agreements.  See the NOTICE file distributed with
+  * this work for additional information regarding copyright ownership.
+  * The ASF licenses this file to You 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
+  *
+  *     http://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.apache.rocketmq.eventbridge.domain.cache;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.eventbridge.domain.model.bus.EventBus;
+import org.apache.rocketmq.eventbridge.domain.model.source.EventSource;
+import org.apache.rocketmq.eventbridge.domain.repository.EventBusRepository;
+import org.apache.rocketmq.eventbridge.domain.repository.EventSourceRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.Cache;
+import org.springframework.cache.CacheManager;
+import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.cache.annotation.Cacheable;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.util.List;
+
+import static org.apache.rocketmq.eventbridge.domain.cache.CacheName.EVENT_SOURCE;
+
+/**
+ * @Author changfeng
+ * @Date 2022/4/25 11:15 上午
+ */
+@Component
+@CacheConfig(cacheNames = EVENT_SOURCE, cacheManager = "cacheManager")
+public class EventSourceCacheService {

Review Comment:
   EventSourceCacheService has been deleted, and the related method is placed in HTTPEventSourceService.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org