Documentation ¶
Index ¶
- Constants
- type TokenCacheKeyringProvider
- func (t *TokenCacheKeyringProvider) CondBroadcast()
- func (t *TokenCacheKeyringProvider) CondWait()
- func (t *TokenCacheKeyringProvider) GetToken() (*oauth2.Token, error)
- func (t *TokenCacheKeyringProvider) Lock()
- func (t *TokenCacheKeyringProvider) PurgeIfEquals(existing *oauth2.Token) (bool, error)
- func (t *TokenCacheKeyringProvider) SaveToken(token *oauth2.Token) error
- func (t *TokenCacheKeyringProvider) TryLock() bool
- func (t *TokenCacheKeyringProvider) Unlock()
Constants ¶
const ( KeyRingServiceUser = "flytectl-user" KeyRingServiceName = "flytectl" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TokenCacheKeyringProvider ¶
type TokenCacheKeyringProvider struct { ServiceName string ServiceUser string // contains filtered or unexported fields }
TokenCacheKeyringProvider wraps the logic to save and retrieve tokens from the OS's keyring implementation.
func NewTokenCacheKeyringProvider ¶ added in v0.8.21
func NewTokenCacheKeyringProvider(serviceName, serviceUser string) *TokenCacheKeyringProvider
func (*TokenCacheKeyringProvider) CondBroadcast ¶ added in v0.8.21
func (t *TokenCacheKeyringProvider) CondBroadcast()
CondBroadcast broadcasts the condition.
func (*TokenCacheKeyringProvider) CondWait ¶ added in v0.8.21
func (t *TokenCacheKeyringProvider) CondWait()
CondWait adds the current go routine to the condition waitlist and waits for another go routine to notify using CondBroadcast The current usage is that one who was able to acquire the lock using TryLock is the one who gets a valid token and notifies all the waitlist requesters so that they can use the new valid token. It also locks the Locker in the condition variable as the semantics of Wait is that it unlocks the Locker after adding the consumer to the waitlist and before blocking on notification. We use the condLocker which is noOp locker to get added to waitlist for notifications. The underlying notifcationList doesn't need to be guarded as it implementation is atomic and is thread safe Refer https://go.dev/src/runtime/sema.go Following is the function and its comments notifyListAdd adds the caller to a notify list such that it can receive notifications. The caller must eventually call notifyListWait to wait for such a notification, passing the returned ticket number.
func notifyListAdd(l *notifyList) uint32 { // This may be called concurrently, for example, when called from // sync.Cond.Wait while holding a RWMutex in read mode. return l.wait.Add(1) - 1 }
func (*TokenCacheKeyringProvider) GetToken ¶
func (t *TokenCacheKeyringProvider) GetToken() (*oauth2.Token, error)
func (*TokenCacheKeyringProvider) Lock ¶ added in v0.8.21
func (t *TokenCacheKeyringProvider) Lock()
func (*TokenCacheKeyringProvider) PurgeIfEquals ¶ added in v0.8.21
func (t *TokenCacheKeyringProvider) PurgeIfEquals(existing *oauth2.Token) (bool, error)
func (*TokenCacheKeyringProvider) SaveToken ¶
func (t *TokenCacheKeyringProvider) SaveToken(token *oauth2.Token) error
func (*TokenCacheKeyringProvider) TryLock ¶ added in v0.8.21
func (t *TokenCacheKeyringProvider) TryLock() bool
TryLock the cache.
func (*TokenCacheKeyringProvider) Unlock ¶ added in v0.8.21
func (t *TokenCacheKeyringProvider) Unlock()