mirror of
https://github.com/openziti/zrok.git
synced 2024-11-26 10:04:16 +01:00
32 lines
629 B
Go
32 lines
629 B
Go
package metrics
|
|
|
|
import (
|
|
"github.com/openziti/zrok/controller/store"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type shareCache struct {
|
|
str *store.Store
|
|
}
|
|
|
|
func newShareCache(cfg *store.Config) (*shareCache, error) {
|
|
str, err := store.Open(cfg)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "error opening store")
|
|
}
|
|
return &shareCache{str}, nil
|
|
}
|
|
|
|
func (sc *shareCache) getToken(svcZId string) (string, error) {
|
|
tx, err := sc.str.Begin()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
defer func() { _ = tx.Rollback() }()
|
|
shr, err := sc.str.FindShareWithZIdAndDeleted(svcZId, tx)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return shr.Token, nil
|
|
}
|