aboutsummaryrefslogtreecommitdiffstats
path: root/entity
diff options
context:
space:
mode:
Diffstat (limited to 'entity')
-rw-r--r--entity/dag/entity.go10
-rw-r--r--entity/streamed.go7
2 files changed, 15 insertions, 2 deletions
diff --git a/entity/dag/entity.go b/entity/dag/entity.go
index 2028e1b4..f8dbd53d 100644
--- a/entity/dag/entity.go
+++ b/entity/dag/entity.go
@@ -314,6 +314,9 @@ func ReadAll[EntityT entity.Interface](def Definition, wrapper func(e *Entity) E
return
}
+ total := int64(len(refs))
+ current := int64(1)
+
for _, ref := range refs {
e, err := read[EntityT](def, wrapper, repo, resolvers, ref)
@@ -322,7 +325,12 @@ func ReadAll[EntityT entity.Interface](def Definition, wrapper func(e *Entity) E
return
}
- out <- entity.StreamedEntity[EntityT]{Entity: e}
+ out <- entity.StreamedEntity[EntityT]{
+ Entity: e,
+ CurrentEntity: current,
+ TotalEntities: total,
+ }
+ current++
}
}()
diff --git a/entity/streamed.go b/entity/streamed.go
index 789224a3..33124ef0 100644
--- a/entity/streamed.go
+++ b/entity/streamed.go
@@ -1,6 +1,11 @@
package entity
type StreamedEntity[EntityT Interface] struct {
- Entity EntityT
Err error
+ Entity EntityT
+
+ // CurrentEntity is the index of the current entity being streamed, to express progress.
+ CurrentEntity int64
+ // TotalEntities is the total count of expected entities, if known.
+ TotalEntities int64
}