From 56c6147eb6012252cf0b723b9eb6d1e841fc2f94 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Fri, 1 Feb 2019 12:22:00 +0100 Subject: identity: more refactoring progress --- identity/resolver.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 identity/resolver.go (limited to 'identity/resolver.go') 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) +} -- cgit