2011shenlin commented on code in PR #11:
URL:
https://github.com/apache/rocketmq-eventbridge/pull/11#discussion_r874627344
##########
domain/src/main/java/org/apache/rocketmq/eventbridge/domain/model/apidestination/ApiDestinationService.java:
##########
@@ -0,0 +1,113 @@
+package org.apache.rocketmq.eventbridge.domain.model.apidestination;
+
+import lombok.extern.slf4j.Slf4j;
+import
org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode;
+import org.apache.rocketmq.eventbridge.domain.model.AbstractResourceService;
+import org.apache.rocketmq.eventbridge.domain.model.PaginationResult;
+import
org.apache.rocketmq.eventbridge.domain.repository.ApiDestinationRepository;
+import org.apache.rocketmq.eventbridge.domain.repository.EventSourceRepository;
+import org.apache.rocketmq.eventbridge.exception.EventBridgeException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+import static
org.apache.rocketmq.eventbridge.domain.common.exception.EventBridgeErrorCode.ApiDestinationCountExceedLimit;
+
+@Slf4j
+@Service
+public class ApiDestinationService extends AbstractResourceService {
+
+ private final ApiDestinationRepository apiDestinationRepository;
+ private final EventSourceRepository eventSourceRepository;
+
+ public ApiDestinationService(ApiDestinationRepository
apiDestinationRepository, EventSourceRepository eventSourceRepository) {
+ this.apiDestinationRepository = apiDestinationRepository;
+ this.eventSourceRepository = eventSourceRepository;
+ }
+
+ @Value("${api.destination.limit}")
+ private String apiDestinationLimit;
+
+ @Transactional(rollbackFor = Exception.class, propagation =
Propagation.REQUIRED)
+ public String createApiDestination(EventApiDestination
eventApiDestination) {
+ try {
+ if (checkApiDestination(eventApiDestination.getAccountId(),
eventApiDestination.getName()) != null) {
+ throw new
EventBridgeException(EventBridgeErrorCode.ApiDestinationAlreadyExist,
eventApiDestination.getName());
+ }
+
super.checkQuota(this.getApiDestinationCount(eventApiDestination.getAccountId(),
eventApiDestination.getName()), Integer.parseInt(apiDestinationLimit),
Review Comment:
Use the value in config directly, so that can change it dynamicly.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]