github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/store/etcdv3/mercury.go (about) 1 package etcdv3 2 3 import ( 4 "testing" 5 6 "github.com/panjf2000/ants/v2" 7 "github.com/projecteru2/core/store/etcdv3/meta" 8 "github.com/projecteru2/core/types" 9 "github.com/projecteru2/core/utils" 10 ) 11 12 const ( 13 podInfoKey = "/pod/info/%s" // /pod/info/{podname} 14 serviceStatusKey = "/services/%s" // /service/{ipv4:port} 15 16 nodeInfoKey = "/node/%s" // /node/{nodename} 17 nodePodKey = "/node/%s:pod/%s" // /node/{podname}:pod/{nodename} 18 nodeCaKey = "/node/%s:ca" // /node/{nodename}:ca 19 nodeCertKey = "/node/%s:cert" // /node/{nodename}:cert 20 nodeKeyKey = "/node/%s:key" // /node/{nodename}:key 21 nodeStatusPrefix = "/status:node/" // /status:node/{nodename} -> node status key 22 nodeWorkloadsKey = "/node/%s:workloads/%s" // /node/{nodename}:workloads/{workloadID} 23 24 workloadInfoKey = "/workloads/%s" // /workloads/{workloadID} 25 workloadDeployPrefix = "/deploy" // /deploy/{appname}/{entrypoint}/{nodename}/{workloadID} 26 workloadStatusPrefix = "/status" // /status/{appname}/{entrypoint}/{nodename}/{workloadID} value -> something by agent 27 workloadProcessingPrefix = "/processing" // /processing/{appname}/{entrypoint}/{nodename}/{opsIdent} value -> count 28 ) 29 30 // Mercury means store with etcdv3 31 type Mercury struct { 32 meta.KV 33 config types.Config 34 pool *ants.PoolWithFunc 35 } 36 37 // New for create a Mercury instance 38 func New(config types.Config, t *testing.T) (m *Mercury, err error) { 39 pool, err := utils.NewPool(config.MaxConcurrency) 40 if err != nil { 41 return nil, err 42 } 43 m = &Mercury{config: config, pool: pool} 44 m.KV, err = meta.NewETCD(config.Etcd, t) 45 return 46 }