aboutsummaryrefslogtreecommitdiffstats
path: root/bug/bug.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-08-13 12:08:48 +0200
committerMichael Muré <batolettre@gmail.com>2022-08-18 15:55:48 +0200
commit45f5f852b71a63c142bca8b05efe53eebf142594 (patch)
treecb92d9f598b13dda69fbbc652a21d0ad8dc314c2 /bug/bug.go
parentcd52872475f1b39f3fb6546606c1e78afb6c08e3 (diff)
downloadgit-bug-45f5f852b71a63c142bca8b05efe53eebf142594.tar.gz
core: generalized resolvers to resolve any entity time when unmarshalling an operation
Diffstat (limited to 'bug/bug.go')
-rw-r--r--bug/bug.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/bug/bug.go b/bug/bug.go
index dce30f76..65fb621e 100644
--- a/bug/bug.go
+++ b/bug/bug.go
@@ -42,14 +42,20 @@ func NewBug() *Bug {
}
}
+func simpleResolvers(repo repository.ClockedRepo) entity.Resolvers {
+ return entity.Resolvers{
+ &identity.Identity{}: identity.NewSimpleResolver(repo),
+ }
+}
+
// Read will read a bug from a repository
func Read(repo repository.ClockedRepo, id entity.Id) (*Bug, error) {
- return ReadWithResolver(repo, identity.NewSimpleResolver(repo), id)
+ return ReadWithResolver(repo, simpleResolvers(repo), id)
}
-// ReadWithResolver will read a bug from its Id, with a custom identity.Resolver
-func ReadWithResolver(repo repository.ClockedRepo, identityResolver identity.Resolver, id entity.Id) (*Bug, error) {
- e, err := dag.Read(def, repo, identityResolver, id)
+// ReadWithResolver will read a bug from its Id, with custom resolvers
+func ReadWithResolver(repo repository.ClockedRepo, resolvers entity.Resolvers, id entity.Id) (*Bug, error) {
+ e, err := dag.Read(def, repo, resolvers, id)
if err != nil {
return nil, err
}
@@ -63,22 +69,22 @@ type StreamedBug struct {
// ReadAll read and parse all local bugs
func ReadAll(repo repository.ClockedRepo) <-chan StreamedBug {
- return readAll(repo, identity.NewSimpleResolver(repo))
+ return readAll(repo, simpleResolvers(repo))
}
// ReadAllWithResolver read and parse all local bugs
-func ReadAllWithResolver(repo repository.ClockedRepo, identityResolver identity.Resolver) <-chan StreamedBug {
- return readAll(repo, identityResolver)
+func ReadAllWithResolver(repo repository.ClockedRepo, resolvers entity.Resolvers) <-chan StreamedBug {
+ return readAll(repo, resolvers)
}
// Read and parse all available bug with a given ref prefix
-func readAll(repo repository.ClockedRepo, identityResolver identity.Resolver) <-chan StreamedBug {
+func readAll(repo repository.ClockedRepo, resolvers entity.Resolvers) <-chan StreamedBug {
out := make(chan StreamedBug)
go func() {
defer close(out)
- for streamedEntity := range dag.ReadAll(def, repo, identityResolver) {
+ for streamedEntity := range dag.ReadAll(def, repo, resolvers) {
if streamedEntity.Err != nil {
out <- StreamedBug{
Err: streamedEntity.Err,