From f6b61a485501f326debe52d77ea65d87fb34b37f Mon Sep 17 00:00:00 2001
From: 田源 <tianyuan@vci-tech.com>
Date: 星期三, 05 三月 2025 17:57:09 +0800
Subject: [PATCH] 完善集成日志查询
---
Source/BladeX-Tool/blade-starter-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java | 78 +++++++++++++++++++++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/Source/BladeX-Tool/blade-starter-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java b/Source/BladeX-Tool/blade-starter-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java
new file mode 100644
index 0000000..fef0a57
--- /dev/null
+++ b/Source/BladeX-Tool/blade-starter-oss/src/main/java/org/springblade/core/oss/config/AliossConfiguration.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * Neither the name of the dreamlu.net developer nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * Author: Chill 搴勯獮 (smallchill@163.com)
+ */
+package org.springblade.core.oss.config;
+
+import com.aliyun.oss.ClientConfiguration;
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.common.auth.CredentialsProvider;
+import com.aliyun.oss.common.auth.DefaultCredentialProvider;
+import lombok.AllArgsConstructor;
+import org.springblade.core.oss.AliossTemplate;
+import org.springblade.core.oss.props.OssProperties;
+import org.springblade.core.oss.rule.OssRule;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Alioss閰嶇疆绫�
+ *
+ * @author Chill
+ */
+@AllArgsConstructor
+@AutoConfiguration(after = OssConfiguration.class)
+@EnableConfigurationProperties(OssProperties.class)
+@ConditionalOnClass({OSSClient.class})
+@ConditionalOnProperty(value = "oss.name", havingValue = "alioss")
+public class AliossConfiguration {
+
+ private final OssProperties ossProperties;
+ private final OssRule ossRule;
+
+ @Bean
+ @ConditionalOnMissingBean(OSSClient.class)
+ public OSSClient ossClient() {
+ // 鍒涘缓ClientConfiguration銆侰lientConfiguration鏄疧SSClient鐨勯厤缃被锛屽彲閰嶇疆浠g悊銆佽繛鎺ヨ秴鏃躲�佹渶澶ц繛鎺ユ暟绛夊弬鏁般��
+ ClientConfiguration conf = new ClientConfiguration();
+ // 璁剧疆OSSClient鍏佽鎵撳紑鐨勬渶澶TTP杩炴帴鏁帮紝榛樿涓�1024涓��
+ conf.setMaxConnections(1024);
+ // 璁剧疆Socket灞備紶杈撴暟鎹殑瓒呮椂鏃堕棿锛岄粯璁や负50000姣銆�
+ conf.setSocketTimeout(50000);
+ // 璁剧疆寤虹珛杩炴帴鐨勮秴鏃舵椂闂达紝榛樿涓�50000姣銆�
+ conf.setConnectionTimeout(50000);
+ // 璁剧疆浠庤繛鎺ユ睜涓幏鍙栬繛鎺ョ殑瓒呮椂鏃堕棿锛堝崟浣嶏細姣锛夛紝榛樿涓嶈秴鏃躲��
+ conf.setConnectionRequestTimeout(1000);
+ // 璁剧疆杩炴帴绌洪棽瓒呮椂鏃堕棿銆傝秴鏃跺垯鍏抽棴杩炴帴锛岄粯璁や负60000姣銆�
+ conf.setIdleConnectionTime(60000);
+ // 璁剧疆澶辫触璇锋眰閲嶈瘯娆℃暟锛岄粯璁や负3娆°��
+ conf.setMaxErrorRetry(5);
+ CredentialsProvider credentialsProvider = new DefaultCredentialProvider(ossProperties.getAccessKey(), ossProperties.getSecretKey());
+ return new OSSClient(ossProperties.getEndpoint(), credentialsProvider, conf);
+ }
+
+ @Bean
+ @ConditionalOnBean({OSSClient.class})
+ @ConditionalOnMissingBean(AliossTemplate.class)
+ public AliossTemplate aliossTemplate(OSSClient ossClient) {
+ return new AliossTemplate(ossClient, ossProperties, ossRule);
+ }
+
+}
--
Gitblit v1.9.3