MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / ClusterContext

Method ClusterContext

internal/rpc/rpc_client.go:130–150  ·  view source on GitHub ↗

ClusterContext 集群上下文

(clusterId string, clusterSecret string)

Source from the content-addressed store, hash-verified

128
129// ClusterContext 集群上下文
130func (this *RPCClient) ClusterContext(clusterId string, clusterSecret string) context.Context {
131 ctx := context.Background()
132 m := maps.Map{
133 "timestamp": time.Now().Unix(),
134 "type": "cluster",
135 "userId": 0,
136 }
137 method, err := encrypt.NewMethodInstance(teaconst.EncryptMethod, clusterSecret, clusterId)
138 if err != nil {
139 utils.PrintError(err)
140 return context.Background()
141 }
142 data, err := method.Encrypt(m.AsJSON())
143 if err != nil {
144 utils.PrintError(err)
145 return context.Background()
146 }
147 token := base64.StdEncoding.EncodeToString(data)
148 ctx = metadata.AppendToOutgoingContext(ctx, "nodeId", clusterId, "token", token)
149 return ctx
150}
151
152// Close 关闭连接
153func (this *RPCClient) Close() {

Callers 1

checkClusterConfigMethod · 0.95

Calls 4

NewMethodInstanceFunction · 0.92
PrintErrorFunction · 0.92
UnixMethod · 0.80
EncryptMethod · 0.65

Tested by

no test coverage detected