tokenmanager

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IdentifiedCallback

type IdentifiedCallback interface {
	ID() string
	Callback(token string, expireAt time.Time) error
}

type Token

type Token struct {
	Token    string `json:"token"`
	ExpireAt int64  `json:"expireAt,omitempty"`
}

type TokenGenerator

type TokenGenerator interface {
	// Generate fetch new token and return expire time as well.
	Generate(ctx context.Context) (token string, expireAt time.Time, err error)
	// Equal compares two generator
	Equal(tg TokenGenerator) bool
	// ID for identity to where the token belongs.
	ID() string
}

func NewTokenGenerator

func NewTokenGenerator(authUrl, username, password string, defaultExpire time.Duration) TokenGenerator

type TokenManager

type TokenManager interface {
	// AddToken add new token to manager
	AddToken(TokenGenerator, IdentifiedCallback)
	// RemoveToken stops maintaining process of given token and remove it from cache.
	RemoveToken(tg TokenGenerator, ic IdentifiedCallback)
	// Stop stops all token maintaining and clean the cache, don't use this manager after call Stop.
	Stop()
}

TokenManager provides cache and maintain token ability.

func NewTokenManager

func NewTokenManager() TokenManager

NewTokenManager return an implement of TokenManager.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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