MCPcopy Create free account
hub / github.com/easyp-tech/server / buildGetGraphRequest

Function buildGetGraphRequest

internal/connect/api_test.go:166–188  ·  view source on GitHub ↗

buildGetGraphRequest builds a protobuf-encoded GetGraph request. GetGraphRequest { resource_refs = 1; GetGraphRequest_ResourceRef { resource_ref = 1; ResourceRef { name = 2; Name { owner=1; module=2 } } } }

(owner, module string)

Source from the content-addressed store, hash-verified

164// buildGetGraphRequest builds a protobuf-encoded GetGraph request.
165// GetGraphRequest { resource_refs = 1; GetGraphRequest_ResourceRef { resource_ref = 1; ResourceRef { name = 2; Name { owner=1; module=2 } } } }
166func buildGetGraphRequest(owner, module string) []byte {
167 var name []byte
168 name = protowire.AppendTag(name, 1, protowire.BytesType)
169 name = protowire.AppendString(name, owner)
170 name = protowire.AppendTag(name, 2, protowire.BytesType)
171 name = protowire.AppendString(name, module)
172
173 var resRef []byte
174 resRef = protowire.AppendTag(resRef, 2, protowire.BytesType)
175 resRef = append(resRef, protowire.AppendVarint(nil, uint64(len(name)))...)
176 resRef = append(resRef, name...)
177
178 var graphRef []byte
179 graphRef = protowire.AppendTag(graphRef, 1, protowire.BytesType)
180 graphRef = append(graphRef, protowire.AppendVarint(nil, uint64(len(resRef)))...)
181 graphRef = append(graphRef, resRef...)
182
183 var req []byte
184 req = protowire.AppendTag(req, 1, protowire.BytesType)
185 req = append(req, protowire.AppendVarint(nil, uint64(len(graphRef)))...)
186 req = append(req, graphRef...)
187 return req
188}
189
190// buildV1GetGraphRequest builds a v1-format GetGraph request with ResourceRef directly.
191// v1 GetGraphRequest: field 1 = repeated ResourceRef { name = 2; Name { owner=1; module=2 } }

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected