You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
498 B
29 lines
498 B
package scopes
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
)
|
|
|
|
type Context struct {
|
|
scopesRepo Repository
|
|
statsRepo StatsLister
|
|
userID string
|
|
|
|
ID int
|
|
Scope Result
|
|
|
|
scopesOnce sync.Once
|
|
scopes []Result
|
|
scopesError error
|
|
service *Service
|
|
}
|
|
|
|
// Scopes lazy-loads the scopes in the context of the first caller.
|
|
func (c *Context) Scopes(ctx context.Context) ([]Result, error) {
|
|
c.scopesOnce.Do(func() {
|
|
c.scopes, c.scopesError = c.service.List(ctx)
|
|
})
|
|
|
|
return c.scopes, c.scopesError
|
|
}
|