aboutsummaryrefslogtreecommitdiffstats
path: root/identity/resolver.go
diff options
context:
space:
mode:
authorMichael Muré <michael.mure@consensys.net>2019-02-01 12:22:00 +0100
committerMichael Muré <batolettre@gmail.com>2019-03-01 22:40:22 +0100
commit56c6147eb6012252cf0b723b9eb6d1e841fc2f94 (patch)
treecce638adbf4a7d5b424fe9682cafc2fea5c64785 /identity/resolver.go
parent14b240af8fef269d2c1d5dde2fff192b656c50f3 (diff)
downloadgit-bug-56c6147eb6012252cf0b723b9eb6d1e841fc2f94.tar.gz
identity: more refactoring progress
Diffstat (limited to 'identity/resolver.go')
-rw-r--r--identity/resolver.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/identity/resolver.go b/identity/resolver.go
new file mode 100644
index 00000000..63dc994f
--- /dev/null
+++ b/identity/resolver.go
@@ -0,0 +1,22 @@
+package identity
+
+import "github.com/MichaelMure/git-bug/repository"
+
+// Resolver define the interface of an Identity resolver, able to load
+// an identity from, for example, a repo or a cache.
+type Resolver interface {
+ ResolveIdentity(id string) (Interface, error)
+}
+
+// DefaultResolver is a Resolver loading Identities directly from a Repo
+type SimpleResolver struct {
+ repo repository.Repo
+}
+
+func NewSimpleResolver(repo repository.Repo) *SimpleResolver {
+ return &SimpleResolver{repo: repo}
+}
+
+func (r *SimpleResolver) ResolveIdentity(id string) (Interface, error) {
+ return Read(r.repo, id)
+}