Search in sources :

Example 1 with NotifyTypeEnum

use of com.dtp.common.em.NotifyTypeEnum in project dynamic-tp by dromara.

the class NotifyHelper method getNotifyItem.

public static NotifyItem getNotifyItem(DtpExecutor dtpExecutor, NotifyTypeEnum typeEnum) {
    List<NotifyItem> notifyItems = dtpExecutor.getNotifyItems();
    val notifyItemOpt = notifyItems.stream().filter(x -> typeEnum.getValue().equalsIgnoreCase(x.getType()) && x.isEnabled()).findFirst();
    if (!notifyItemOpt.isPresent()) {
        log.debug("DynamicTp notify, no such [{}] notify item configured, threadPoolName: {}", typeEnum.getValue(), dtpExecutor.getThreadPoolName());
        return null;
    }
    return notifyItemOpt.get();
}
Also used : lombok.val(lombok.val) DtpExecutor(com.dtp.core.thread.DtpExecutor) java.util(java.util) NotifyPlatform(com.dtp.common.dto.NotifyPlatform) lombok.val(lombok.val) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) StreamUtil(com.dtp.common.util.StreamUtil) CollUtil(cn.hutool.core.collection.CollUtil) NotifyItem(com.dtp.common.dto.NotifyItem) Slf4j(lombok.extern.slf4j.Slf4j) Collectors.toList(java.util.stream.Collectors.toList) Lists(com.google.common.collect.Lists) ThreadPoolProperties(com.dtp.common.config.ThreadPoolProperties) DtpProperties(com.dtp.common.config.DtpProperties) NotifyTypeEnum(com.dtp.common.em.NotifyTypeEnum) NotifyItem(com.dtp.common.dto.NotifyItem)

Aggregations

CollUtil (cn.hutool.core.collection.CollUtil)1 DtpProperties (com.dtp.common.config.DtpProperties)1 ThreadPoolProperties (com.dtp.common.config.ThreadPoolProperties)1 NotifyItem (com.dtp.common.dto.NotifyItem)1 NotifyPlatform (com.dtp.common.dto.NotifyPlatform)1 NotifyTypeEnum (com.dtp.common.em.NotifyTypeEnum)1 StreamUtil (com.dtp.common.util.StreamUtil)1 DtpExecutor (com.dtp.core.thread.DtpExecutor)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1