tokenmanager

package
v1.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewIBMClient client constructor
	NewIBMClient = newIBMClient

	// DefaultIBMClient client constructor with default values
	DefaultIBMClient = defaultIBMClient
)
View Source
var (

	// DefaultAdvisoryTimeoutFunc set the advisory  timeout to 25% of remaining time - usually 15 minutes on 1 hour expiry
	DefaultAdvisoryTimeoutFunc = func(ttl time.Duration) time.Duration {
		return time.Duration(float64(ttl.Nanoseconds())*0.25) * time.Nanosecond
	}

	// DefaultMandatoryTimeoutFunc set the mandatory timeout to 17% of remaining time - usually 10 minutes on 1 hour expiry
	DefaultMandatoryTimeoutFunc = func(ttl time.Duration) time.Duration {
		return time.Duration(float64(ttl.Nanoseconds())*0.17) * time.Nanosecond
	}

	// ErrFetchingIAMTokenFn returns the error fetching token for Token Manager
	ErrFetchingIAMTokenFn = func(err error) awserr.Error {
		return awserr.New("ErrFetchingIAMToken", "error fetching token", err)
	}
)
View Source
var (
	// NewTokenManager token manager constructor using a custom initial function to retrieve first token
	NewTokenManager = func(config *aws.Config, initFunc func() (*token.Token, error), authEndPoint string,
		advisoryRefreshTimeout, mandatoryRefreshTimeout func(time.Duration) time.Duration, timeFunc func() time.Time,
		client IBMClientDo) API {
		return newTokenManager(config, initFunc, authEndPoint, advisoryRefreshTimeout, mandatoryRefreshTimeout,
			timeFunc, client)

	}

	// NewTokenManagerFromAPIKey token manager constructor using api key to retrieve first token
	NewTokenManagerFromAPIKey = func(config *aws.Config, apiKey, authEndPoint string, advisoryRefreshTimeout,
		mandatoryRefreshTimeout func(time.Duration) time.Duration, timeFunc func() time.Time,
		client IBMClientDo) API {
		return newTokenManagerFromAPIKey(config, apiKey, authEndPoint, advisoryRefreshTimeout,
			mandatoryRefreshTimeout, timeFunc, client)
	}
)

default implementations wrap implementation in the interface

Functions

This section is empty.

Types

type API

type API interface {

	// Token Management Get Function
	Get() (*token.Token, error)

	// Token Management Retries Function
	Refresh() error

	// Token Management Stop Background Refresh
	StopBackgroundRefresh()

	// Token Management Start Background Refresh
	StartBackgroundRefresh()
}

API Token Manager interface

type IBMClientDo

type IBMClientDo interface {

	// HTTP Client Do op
	Do(req *http.Request) (*http.Response, error)
}

IBMClientDo wrapper type to the Do operation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL