apimutex

package
v0.0.0-...-be84041 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIMutex

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

APIMutex synchronizes keeping account of current known rate limit values from Okta management endpoints. See: https://developer.okta.com/docs/reference/rl-global-mgmt/

The Okta Terraform Provider can not account for other clients consumption of API limits but it can account for its own usage and attempt to preemptively react appropriately.

func NewAPIMutex

func NewAPIMutex(capacity int) (*APIMutex, error)

NewAPIMutex returns a new api mutex object that represents untilized capacity under the specified capacity percentage.

func (*APIMutex) Bucket

func (m *APIMutex) Bucket(method, endPoint string) string

Bucket Returns the rate limit bucket the api endpoint falls into.

func (*APIMutex) Class

func (m *APIMutex) Class(method, endPoint string) string

Class Returns the api endpoint class.

func (*APIMutex) HasCapacity

func (m *APIMutex) HasCapacity(method, endPoint string) bool

HasCapacity approximates if there is capacity below the api mutex's maximum capacity threshold.

func (*APIMutex) Status

func (m *APIMutex) Status(method, endPoint string) *APIStatus

Status Returns the APIStatus for the given method + endpoint combination.

func (*APIMutex) Update

func (m *APIMutex) Update(method, endPoint string, limit, remaining int, reset int64)

Update updates the known status for the given API endpoint. It is synchronous and intelligently accounts for new values regardless of parallelism.

type APIStatus

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

APIStatus is used to hold rate limit information from Okta's API, see: https://developer.okta.com/docs/reference/rl-best-practices/

func (*APIStatus) Limit

func (s *APIStatus) Limit() int

Limit returns the current limit value of the api status object.

func (*APIStatus) Remaining

func (s *APIStatus) Remaining() int

Remaining returns the current remaining value of the api status object.

func (*APIStatus) Reset

func (s *APIStatus) Reset() int64

Reset returns the current reset value of the api status object.

Jump to

Keyboard shortcuts

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