quota

package
v0.0.0-...-dcd54df Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

A Manager tracks multiple Apigee quotas

func NewManager

func NewManager(env adapter.Env, options Options) (*Manager, error)

NewManager constructs and starts a new Manager. Call Close when done.

func (*Manager) Apply

func (m *Manager) Apply(auth *auth.Context, p *product.APIProduct, args adapter.QuotaArgs) (*Result, error)

Apply a quota request to the local quota bucket and schedule for sync

func (*Manager) Close

func (m *Manager) Close()

Close shuts down the manager.

func (*Manager) Start

func (m *Manager) Start(env adapter.Env)

Start starts the manager.

type Options

type Options struct {
	// Client is a configured HTTPClient
	Client *http.Client
	// BaseURL of the Apigee internal proxy
	BaseURL *url.URL
	// Key is provisioning key
	Key string
	// Secret is provisioning secret
	Secret string
}

Options allows us to specify options for how this auth manager will run

type Request

type Request struct {
	Identifier string `json:"identifier"`
	Weight     int64  `json:"weight"`
	Interval   int64  `json:"interval"`
	Allow      int64  `json:"allow"`
	TimeUnit   string `json:"timeUnit"`
}

A Request is sent to Apigee's quota server to allocate quota.

type Result

type Result struct {
	Allowed    int64 `json:"allowed"`
	Used       int64 `json:"used"`
	Exceeded   int64 `json:"exceeded"`
	ExpiryTime int64 `json:"expiryTime"`
	Timestamp  int64 `json:"timestamp"`
}

A Result is a response from Apigee's quota server that gives information about how much quota is available. Note that Used will never exceed Allowed, but Exceeded will be positive in that case.

type ResultCache

type ResultCache struct {
	// contains filtered or unexported fields
}

ResultCache is a structure to track Results by ID, bounded by size

func (*ResultCache) Add

func (d *ResultCache) Add(id string, result *Result)

Add a Result to the cache

func (*ResultCache) Get

func (d *ResultCache) Get(id string) *Result

Get a Result from the cache, nil if none

Jump to

Keyboard shortcuts

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