readClockNoCheck fetch from git, read and witness the clocks of an Entity at an arbitrary git reference. Note: readClockNoCheck does not verify the integrity of the Entity and could witness incorrect or incomplete clocks if so. If data integrity check is a requirement, a flow similar to read without
(def Definition, repo repository.ClockedRepo, ref string)
| 249 | // clocks if so. If data integrity check is a requirement, a flow similar to read without actually reading/decoding |
| 250 | // operation blobs can be implemented instead. |
| 251 | func readClockNoCheck(def Definition, repo repository.ClockedRepo, ref string) error { |
| 252 | rootHash, err := repo.ResolveRef(ref) |
| 253 | if err == repository.ErrNotFound { |
| 254 | return entity.NewErrNotFound(def.Typename) |
| 255 | } |
| 256 | if err != nil { |
| 257 | return err |
| 258 | } |
| 259 | |
| 260 | commit, err := repo.ReadCommit(rootHash) |
| 261 | if err != nil { |
| 262 | return err |
| 263 | } |
| 264 | |
| 265 | createTime, editTime, err := readOperationPackClock(repo, commit) |
| 266 | if err != nil { |
| 267 | return err |
| 268 | } |
| 269 | |
| 270 | // if we have more than one commit, we need to find the root to have the create time |
| 271 | if len(commit.Parents) > 0 { |
| 272 | for len(commit.Parents) > 0 { |
| 273 | // The path to the root is irrelevant. |
| 274 | commit, err = repo.ReadCommit(commit.Parents[0]) |
| 275 | if err != nil { |
| 276 | return err |
| 277 | } |
| 278 | } |
| 279 | createTime, _, err = readOperationPackClock(repo, commit) |
| 280 | if err != nil { |
| 281 | return err |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | if createTime <= 0 { |
| 286 | return fmt.Errorf("creation lamport time not set") |
| 287 | } |
| 288 | if editTime <= 0 { |
| 289 | return fmt.Errorf("creation lamport time not set") |
| 290 | } |
| 291 | err = repo.Witness(fmt.Sprintf(creationClockPattern, def.Namespace), createTime) |
| 292 | if err != nil { |
| 293 | return err |
| 294 | } |
| 295 | err = repo.Witness(fmt.Sprintf(editClockPattern, def.Namespace), editTime) |
| 296 | if err != nil { |
| 297 | return err |
| 298 | } |
| 299 | return nil |
| 300 | } |
| 301 | |
| 302 | // ReadAll read and parse all local Entity |
| 303 | func ReadAll[EntityT entity.Interface](def Definition, wrapper func(e *Entity) EntityT, repo repository.ClockedRepo, resolvers entity.Resolvers) <-chan entity.StreamedEntity[EntityT] { |
no test coverage detected