Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigProvider ¶
type Locker ¶
type Locker interface {
// Lock locks the token id for the consumer transaction txID on behalf of the given
// owner (the wallet the tokens are selected for, ownerFilter.ID()).
// owner lets a Locker implementation apply per-wallet policies such as rate limiting.
// To deny a lock for policy reasons, return an error wrapping token.SelectorRateLimited:
// the selector then aborts immediately instead of retrying.
Lock(ctx context.Context, owner string, id *token2.ID, txID string, reclaim bool) (string, error)
// UnlockIDs unlocks the passed IDs for the given owner. It returns the list of tokens
// that were not locked in the first place among those passed.
UnlockIDs(ctx context.Context, owner string, ids ...*token2.ID) []*token2.ID
UnlockByTxID(ctx context.Context, txID string)
IsLocked(id *token2.ID) bool
}
type LockerProvider ¶
type NewQueryEngineFunc ¶
type NewQueryEngineFunc func() QueryService
type QueryService ¶
type QueryService interface {
UnspentTokensIterator(ctx context.Context) (*token.UnspentTokensIterator, error)
UnspentTokensIteratorBy(ctx context.Context, id string, tokenType token2.Type) (driver.UnspentTokensIterator, error)
GetTokens(ctx context.Context, inputs ...*token2.ID) ([]*token2.Token, error)
}
type SelectorService ¶
type SelectorService struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(lockerProvider LockerProvider, c ConfigProvider, opts ...ratelimit.Option) *SelectorService
NewService returns a SelectorService for the simple driver.
By default, selection is not rate limited. Passing ratelimit options, or enabling the token.selector.rateLimit* configuration keys, meters every selection request per wallet.
func (*SelectorService) SelectorManager ¶
func (s *SelectorService) SelectorManager(tms *token.ManagementService) (token.SelectorManager, error)
func (*SelectorService) Shutdown ¶
func (s *SelectorService) Shutdown()
Shutdown stops all background goroutines for every locker created by this service.
It deliberately leaves the rate limiter alone. Shutdown also runs on routine public-parameter reloads (see token.ManagementServiceProvider.Update), after which the service keeps serving managers: resetting the wallet allowances there would let a throttled client wash out its debt by triggering a reload, and a limiter supplied through ratelimit.WithLimiter belongs to the caller in the first place. The built-in limiter runs no goroutines and prunes its own buckets, so there is nothing to leak.