MCPcopy Create free account
hub / github.com/git-bug/git-bug / ReadAll

Function ReadAll

entity/dag/entity.go:303–338  ·  view source on GitHub ↗

ReadAll read and parse all local Entity

(def Definition, wrapper func(e *Entity) EntityT, repo repository.ClockedRepo, resolvers entity.Resolvers)

Source from the content-addressed store, hash-verified

301
302// ReadAll read and parse all local Entity
303func ReadAll[EntityT entity.Interface](def Definition, wrapper func(e *Entity) EntityT, repo repository.ClockedRepo, resolvers entity.Resolvers) <-chan entity.StreamedEntity[EntityT] {
304 out := make(chan entity.StreamedEntity[EntityT])
305
306 go func() {
307 defer close(out)
308
309 refPrefix := fmt.Sprintf("refs/%s/", def.Namespace)
310
311 refs, err := repo.ListRefs(refPrefix)
312 if err != nil {
313 out <- entity.StreamedEntity[EntityT]{Err: err}
314 return
315 }
316
317 total := int64(len(refs))
318 current := int64(1)
319
320 for _, ref := range refs {
321 e, err := read[EntityT](def, wrapper, repo, resolvers, ref)
322
323 if err != nil {
324 out <- entity.StreamedEntity[EntityT]{Err: err}
325 return
326 }
327
328 out <- entity.StreamedEntity[EntityT]{
329 Entity: e,
330 CurrentEntity: current,
331 TotalEntities: total,
332 }
333 current++
334 }
335 }()
336
337 return out
338}
339
340// ReadAllClocksNoCheck goes over all entities matching Definition and read/witness the corresponding clocks so that the
341// repo end up with correct clocks for the next write.

Callers 3

ReadAllFunction · 0.92
ReadAllWithResolverFunction · 0.92
TestEntityPushPullFunction · 0.70

Calls 2

closeFunction · 0.85
ListRefsMethod · 0.65

Tested by 1

TestEntityPushPullFunction · 0.56