// Copyright 2019 getensh.com. All rights reserved. // Use of this source code is governed by getensh.com. package utils import ( "fmt" "github.com/tidwall/gjson" ) func getKey(content string,keys []string) string{ key := "" if keys == nil { return key } for _,v := range keys{ key = key+gjson.Get(content, v).String() } return key } // 获取主键 func GetPrimaryKey(content string,outputSource string ,keys []string ) (string,string) { key := getKey(content,keys) if key == ""{ return "","" } lockKey := fmt.Sprintf("ads-lock-%s-%s",outputSource,key) taskKey := fmt.Sprintf("ads-task-%s-%s",outputSource,key) return lockKey,taskKey } // 获取任务主键 func GetTaskKey(content string ,keys []string) string { key := "" for _,v := range keys{ key = key+gjson.Get(content, v).String() } if key == ""{ return key } key = fmt.Sprintf("task-%s",key) return key }