Documentation
¶
Index ¶
- type Fetcher
- type FileFetcher
- type FileFetcherOption
- func WithAllowInitialFailure(allow bool) FileFetcherOption
- func WithCreateDirIfNotExist(create bool) FileFetcherOption
- func WithForceFileRefreshInterval(fileRefreshInterval time.Duration) FileFetcherOption
- func WithMaxFileSize(msize int64) FileFetcherOption
- func WithOnFileUpdateListener(f func(context.Context, io.Reader)) FileFetcherOption
- type KeyFileFetcher
- type KeyFileFetcherOption
- func WithKeyFileFetcherOptions(opts ...FileFetcherOption) KeyFileFetcherOption
- func WithOnKeyFileUpdateListener(f func(context.Context, io.Reader)) KeyFileFetcherOption
- func WithSecretKey(secretKey string) KeyFileFetcherOption
- func WithSecretKeyEnvVar(secretKeyEnvVar string) KeyFileFetcherOption
- func WithSecretKeyFile(secretKeyFile string) KeyFileFetcherOption
- type TokenFetcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fetcher ¶
type Fetcher interface {
// FetchData returns cached file data if valid,
// otherwise it tries to fetch new data and update cache first.
FetchData(ctx context.Context) (string, error)
}
Fetcher represents a struct that can fetch file data for clients
type FileFetcher ¶
type FileFetcher struct {
// contains filtered or unexported fields
}
func NewFileFetcher ¶
func NewFileFetcher(ctx context.Context, filePath string, opts ...FileFetcherOption) (*FileFetcher, error)
type FileFetcherOption ¶
type FileFetcherOption func(*FileFetcher)
func WithAllowInitialFailure ¶
func WithAllowInitialFailure(allow bool) FileFetcherOption
WithAllowInitialFailure allows for ignoring errors from the initial fetchAndStoreFileContents() call. Disabled by default.
func WithCreateDirIfNotExist ¶
func WithCreateDirIfNotExist(create bool) FileFetcherOption
WithCreateDirIfNotExist attempts to create the directory for the file path provided in order to watch the dir when the file doesn't exist. The dir is created with 0755 permissions. Disabled by default.
func WithForceFileRefreshInterval ¶
func WithForceFileRefreshInterval(fileRefreshInterval time.Duration) FileFetcherOption
WithForceFileRefreshInterval enables a ticker to force refresh the file at a particular cadence
func WithMaxFileSize ¶
func WithMaxFileSize(msize int64) FileFetcherOption
func WithOnFileUpdateListener ¶
func WithOnFileUpdateListener(f func(context.Context, io.Reader)) FileFetcherOption
WithOnFileUpdateListener sets a callback function to be called when the file is updated
type KeyFileFetcher ¶
type KeyFileFetcher struct {
// contains filtered or unexported fields
}
func NewKeyFileFetcher ¶
func NewKeyFileFetcher(ctx context.Context, opts ...KeyFileFetcherOption) (*KeyFileFetcher, error)
func (*KeyFileFetcher) FetchSecretKey ¶
func (fetcher *KeyFileFetcher) FetchSecretKey(ctx context.Context) (string, error)
FetchSecretKey fetches the token stored in the fetcher struct
func (*KeyFileFetcher) FetchToken ¶
func (fetcher *KeyFileFetcher) FetchToken(ctx context.Context) (string, error)
FetchToken is an adapter for downstream consumers to use this directly
type KeyFileFetcherOption ¶
type KeyFileFetcherOption func(*KeyFileFetcher)
func WithKeyFileFetcherOptions ¶
func WithKeyFileFetcherOptions(opts ...FileFetcherOption) KeyFileFetcherOption
WithKeyFileFetcherOptions forwards FileFetcher options when key file mode is used.
func WithOnKeyFileUpdateListener ¶
func WithOnKeyFileUpdateListener(f func(context.Context, io.Reader)) KeyFileFetcherOption
WithOnKeyFileUpdateListener sets a callback function to be called when the key file is updated
func WithSecretKey ¶
func WithSecretKey(secretKey string) KeyFileFetcherOption
WithSecretKey provides a default secret key to use if the file is not specified
func WithSecretKeyEnvVar ¶
func WithSecretKeyEnvVar(secretKeyEnvVar string) KeyFileFetcherOption
WithSecretKeyEnvVar specifies the environment variable the secret key file may be found in for error messages
func WithSecretKeyFile ¶
func WithSecretKeyFile(secretKeyFile string) KeyFileFetcherOption
WithSecretKeyFile specifies the secret key file to read from
type TokenFetcher ¶
type TokenFetcher interface {
// FetchToken returns the token in the cache if it think the token is
// valid, otherwise, it tries to fetch a new token and update cache
// first.
FetchToken(ctx context.Context) (string, error)
}
TokenFetcher represents a struct that can fetch tokens for clients