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

Method Context

internal/rpc/rpc_client.go:106–127  ·  view source on GitHub ↗

Context 节点上下文信息

()

Source from the content-addressed store, hash-verified

104
105// Context 节点上下文信息
106func (this *RPCClient) Context() context.Context {
107 var m = maps.Map{
108 "timestamp": time.Now().Unix(),
109 "type": "node",
110 "userId": 0,
111 }
112 method, err := encrypt.NewMethodInstance(teaconst.EncryptMethod, this.apiConfig.Secret, this.apiConfig.NodeId)
113 if err != nil {
114 utils.PrintError(err)
115 return context.Background()
116 }
117 data, err := method.Encrypt(m.AsJSON())
118 if err != nil {
119 utils.PrintError(err)
120 return context.Background()
121 }
122 var token = base64.StdEncoding.EncodeToString(data)
123
124 var ctx = context.Background()
125 ctx = metadata.AppendToOutgoingContext(ctx, "nodeId", this.apiConfig.NodeId, "token", token)
126 return ctx
127}
128
129// ClusterContext 集群上下文
130func (this *RPCClient) ClusterContext(clusterId string, clusterSecret string) context.Context {

Callers 15

TestEndpointsMethod · 0.95
uploadLogsFunction · 0.80
ProcessMethod · 0.80
LoopMethod · 0.80
UploadMethod · 0.80
uploadServerStatsMethod · 0.80
fetchMethod · 0.80
doEndMethod · 0.80
configureWebMethod · 0.80
FormatMethod · 0.80
CloseMethod · 0.80
isConnClosedMethod · 0.80

Calls 4

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

Tested by 5

TestValueQueue_RPCFunction · 0.64
TestRPCConcurrentCallFunction · 0.64
TestRPC_RetryFunction · 0.64