mirror of
https://github.com/openziti/zrok.git
synced 2025-06-25 04:02:15 +02:00
detail cache (#270)
This commit is contained in:
parent
8b99d13f40
commit
20bd5bbb09
33
controller/metrics2/cache.go
Normal file
33
controller/metrics2/cache.go
Normal file
@ -0,0 +1,33 @@
|
||||
package metrics2
|
||||
|
||||
import "github.com/openziti/zrok/controller/store"
|
||||
|
||||
type cache struct {
|
||||
str *store.Store
|
||||
}
|
||||
|
||||
func newShareCache(str *store.Store) *cache {
|
||||
return &cache{str}
|
||||
}
|
||||
|
||||
func (c *cache) addZrokDetail(u *Usage) error {
|
||||
tx, err := c.str.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
shr, err := c.str.FindShareWithZIdAndDeleted(u.ZitiServiceId, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.ShareToken = shr.Token
|
||||
env, err := c.str.GetEnvironment(shr.EnvironmentId, tx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
u.EnvironmentId = int64(env.Id)
|
||||
u.AccountId = int64(*env.AccountId)
|
||||
|
||||
return nil
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user