From 2d0f44fb058675dc376ee904c807e2d918058275 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Sun, 30 Mar 2025 19:54:38 +0800 Subject: [PATCH] =?UTF-8?q?ilm=20=E7=AD=96=E7=95=A5=E7=94=9F=E6=88=90?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=87=BD=E6=95=B0=E6=B5=8B=E8=AF=95=E9=80=9A?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- elasticilm/ilm.go | 10 ++++++---- okx/publicApiService.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/elasticilm/ilm.go b/elasticilm/ilm.go index 81b3ab9..660802a 100644 --- a/elasticilm/ilm.go +++ b/elasticilm/ilm.go @@ -586,6 +586,7 @@ func ensureILMPolicy(client *http.Client, esConfig cfg.ElasticsearchConfig, poli fmt.Println("[ILM Policy] max_docs not set in NormalRollover, skipping max_docs in rollover") } + warmDays, coldDays, deleteDays := NonLinearCoolingModel(daysDiff, period, dataConfig.CoolingModelConfig) policy := map[string]interface{}{ "policy": map[string]interface{}{ "phases": map[string]interface{}{ @@ -598,7 +599,7 @@ func ensureILMPolicy(client *http.Client, esConfig cfg.ElasticsearchConfig, poli }, }, "warm": map[string]interface{}{ - "min_age": fmt.Sprintf("%dd", dataConfig.NormalPhases["warm"]), + "min_age": fmt.Sprintf("%dd", warmDays), // 使用冷却模型计算的 warmDays "actions": map[string]interface{}{ "allocate": map[string]interface{}{ "include": map[string]string{"_tier_preference": "data_warm"}, @@ -606,7 +607,7 @@ func ensureILMPolicy(client *http.Client, esConfig cfg.ElasticsearchConfig, poli }, }, "cold": map[string]interface{}{ - "min_age": fmt.Sprintf("%dd", dataConfig.NormalPhases["cold"]), + "min_age": fmt.Sprintf("%dd", coldDays), // 使用冷却模型计算的 coldDays "actions": map[string]interface{}{ "allocate": map[string]interface{}{ "include": map[string]string{"_tier_preference": "data_cold"}, @@ -614,7 +615,7 @@ func ensureILMPolicy(client *http.Client, esConfig cfg.ElasticsearchConfig, poli }, }, "delete": map[string]interface{}{ - "min_age": fmt.Sprintf("%dd", retentionDays), + "min_age": fmt.Sprintf("%dd", deleteDays), // 使用冷却模型计算的 deleteDays "actions": map[string]interface{}{ "delete": map[string]interface{}{}, }, @@ -649,10 +650,11 @@ func ensureILMPolicy(client *http.Client, esConfig cfg.ElasticsearchConfig, poli } // 创建或更新策略 - policyData, err := json.Marshal(policy) + policyData, err := json.MarshalIndent(policy, "", " ") if err != nil { return fmt.Errorf("failed to marshal ILM policy: %v", err) } + fmt.Printf("[ILM Policy] Printing ILM policy to console:\n%s\n", string(policyData)) req, err := http.NewRequest("PUT", policyURL, bytes.NewBuffer(policyData)) if err != nil { return fmt.Errorf("failed to create ILM policy request: %v", err) diff --git a/okx/publicApiService.go b/okx/publicApiService.go index 42cce37..d35c525 100644 --- a/okx/publicApiService.go +++ b/okx/publicApiService.go @@ -186,7 +186,7 @@ func (s *OkxPublicDataService) GetCandles(params CandlesRequest) ([]*Candle, err if err != nil { return nil, err } - fmt.Printf("Response Body: %s\n", string(body)) + //fmt.Printf("Response Body: %s\n", string(body)) // 重新设置resp.Body以便后续解码 resp.Body = io.NopCloser(bytes.NewBuffer(body))