From a1af6f76c10c368575892177f17dde7b6dfa5617 Mon Sep 17 00:00:00 2001 From: lixinyang-cyril Date: Mon, 3 Jun 2024 16:44:23 +0800 Subject: [PATCH] feature(user_group): support cdp cohort handler and user group experiment --- cohort/cdp_client.go | 6 ++++++ meta/manager/dynamic_meta_manager.go | 1 + 2 files changed, 7 insertions(+) diff --git a/cohort/cdp_client.go b/cohort/cdp_client.go index dc265cb..cf59dab 100644 --- a/cohort/cdp_client.go +++ b/cohort/cdp_client.go @@ -29,7 +29,13 @@ func (c *CdpClient) UseCohort(decisionId string, cohortIds []string) []string { // gen req var cohortIdStrBuilder strings.Builder cohortIdStrBuilder.WriteString(cohortIds[0]) + cohortIdMap := make(map[string]bool) + cohortIdMap[cohortIds[0]] = true for _, id := range cohortIds[1:] { + if cohortIdMap[id] { // 去重 + continue + } + cohortIdMap[id] = true cohortIdStrBuilder.WriteString(",") cohortIdStrBuilder.WriteString(id) } diff --git a/meta/manager/dynamic_meta_manager.go b/meta/manager/dynamic_meta_manager.go index 5ff0905..c3b6432 100644 --- a/meta/manager/dynamic_meta_manager.go +++ b/meta/manager/dynamic_meta_manager.go @@ -90,6 +90,7 @@ func NewDynamicMetaManager(token string, options ...MetaOptionFunc) *DynamicMeta } if err := d.fetchMeta(); err != nil { log.WithFields(log.Fields{"url": d.fetchUrl, "err": err}).Error("fetch meta err") + return &d } d.startFetcher() return &d