2019-02-01 14:22:00 +03:00
|
|
|
package identity
|
|
|
|
|
2019-08-11 15:08:03 +03:00
|
|
|
import (
|
|
|
|
"github.com/MichaelMure/git-bug/entity"
|
|
|
|
"github.com/MichaelMure/git-bug/repository"
|
|
|
|
)
|
2019-02-01 14:22:00 +03:00
|
|
|
|
|
|
|
// Resolver define the interface of an Identity resolver, able to load
|
|
|
|
// an identity from, for example, a repo or a cache.
|
|
|
|
type Resolver interface {
|
2019-08-11 15:08:03 +03:00
|
|
|
ResolveIdentity(id entity.Id) (Interface, error)
|
2019-02-01 14:22:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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}
|
|
|
|
}
|
|
|
|
|
2019-08-11 15:08:03 +03:00
|
|
|
func (r *SimpleResolver) ResolveIdentity(id entity.Id) (Interface, error) {
|
2019-02-03 21:55:35 +03:00
|
|
|
return ReadLocal(r.repo, id)
|
2019-02-01 14:22:00 +03:00
|
|
|
}
|