Documentation ¶
Index ¶
- Constants
- type AuthType
- type ClientAuth
- type Extensions
- type Hierarchy
- type Metrics
- func (m Metrics) Add(name string, value int) (int, error)
- func (m Metrics) AddHierarchyToMetrics(hierarchy Hierarchy) Metrics
- func (m Metrics) DeepCopy() Metrics
- func (m Metrics) Delete(name string)
- func (m Metrics) Set(name string, value int) error
- func (m Metrics) SubtractHierarchyFromMetrics(hierarchy Hierarchy) Metrics
- type Params
- type Period
- type PeriodWindow
- type RateLimits
- type Service
- type Transaction
- type UsageReport
- func (ur UsageReport) IsForDay() bool
- func (ur UsageReport) IsForEternity() bool
- func (ur UsageReport) IsForHour() bool
- func (ur UsageReport) IsForMinute() bool
- func (ur UsageReport) IsForMonth() bool
- func (ur UsageReport) IsForWeek() bool
- func (ur UsageReport) IsForYear() bool
- func (ur UsageReport) IsSame(usageReport UsageReport) bool
- type UsageReports
Constants ¶
const ( // LimitExtension is the key to enable this extension when calling 3scale backend - set to 1 to enable LimitExtension = "limit_headers" // HierarchyExtension is the key to enabling hierarchy feature. Set its bool value to 1 to enable. // https://github.com/3scale/apisonator/issues/75 HierarchyExtension = "hierarchy" // FlatUsageExtension is the key to enabling the "flat usage" feature for reporting purposes - set to 1 to enable // Enabling this feature implies that the backend will not calculate the relationships between hierarchies and // pushes this compute responsibility back to the client. // Therefore when enabled, it is the clients responsibility to ensure that parent --> child metrics // are calculated correctly. This feature is supported in versions >= 2.8 // Use the GetVersion() function to ensure suitability or risk incurring unreported state. FlatUsageExtension = "flat_usage" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthType ¶
type AuthType string
AuthType maps to a known client authentication pattern Currently known and supported are 0=ServiceToken 1=ProviderKey
type ClientAuth ¶
ClientAuth holds the key type (ProviderKey, ServiceToken) and their respective value for authenticating the client against a given service.
type Extensions ¶
Extensions are features or behaviours that are not part of the standard API for a variety of reasons See https://github.com/3scale/apisonator/blob/v2.96.2/docs/extensions.md for context
type Metrics ¶
Metrics let you track the usage of your API in 3scale
func (Metrics) Add ¶
Add takes a provided key and value and adds them to the Metric 'm' If the metric already existed in 'm', then the value will be added (if positive) or subtracted (if negative) from the existing value. If a subtraction leads to a negative value Add returns an error and the change will be discarded. Returns the updated value (or current value in error cases) as well as the error.
func (Metrics) AddHierarchyToMetrics ¶ added in v0.0.4
AddHierarchyToMetrics takes the provided hierarchy structure, and uses it to determine how the metrics, m, are affected, incrementing parent metrics based on the value of the parents child/children metrics. Returns new Metrics, leaving metrics m in it's original state.
func (Metrics) Set ¶
Set takes a provided key and value and sets that value of the key in 'm', overwriting any value that exists previously.
func (Metrics) SubtractHierarchyFromMetrics ¶ added in v0.0.4
SubtractHierarchyFromMetrics takes the provided hierarchy structure, and uses it to determine how the metrics, m, are affected, decrementing parent metrics based on the value of the parents child/children metrics. Returns new Metrics, leaving metrics m in it's original state.
type Params ¶
type Params struct { // AppID is used in the Application Identifier and Key pairs authentication method. // It is mutually exclusive with the API Key authentication method outlined below // therefore if both are provided, the value defined in 'UserKey' will be prioritised. AppID string `json:"app_id"` // AppKey is an optional, secret key which can be used in conjunction with 'AppID' AppKey string `json:"app_key"` // Referrer is an optional value which is required only if referrer filtering is enabled. // If special value '*' (wildcard) is passed, the referrer check is bypassed. Referrer string `json:"referrer"` // UserID is an optional value for identifying an end user. // Required only when the application is rate limiting end users. UserID string `json:"user_id"` // UserKey is the identifier and shared secret of the application if the authentication pattern is API Key. // Mutually exclusive with, and prioritised over 'AppID'. UserKey string `json:"user_key"` }
Params that are embedded in each Transaction to 3scale API This structure simplifies the formatting of the transaction from the callers perspective It is used to authenticate the application
type Period ¶
type Period int
Period wraps the known rate limiting periods as defined in 3scale
Predefined, known LimitPeriods which can be used in 3scale rate limiting functionality These values represent time durations.
type PeriodWindow ¶
PeriodWindow holds information about the start and end time of the specified period Start and End are unix timestamp
func (PeriodWindow) IsEqual ¶ added in v0.5.0
func (pw PeriodWindow) IsEqual(window PeriodWindow) bool
IsEqual compares two PeriodWindows. They are equal if the period is the same and timestamps for start and end do not differ
type RateLimits ¶
RateLimits holds the values returned when using rate limiting extension
type Service ¶
type Service string
Service represents a 3scale service marked by its identifier (service_id)
type Transaction ¶
type Transaction struct { Metrics Metrics Params Params // Timestamp is a unix timestamp. // Timestamp will only be taken into account when calling the Report API Timestamp int64 }
Transaction holds the params and optional additions that will be sent to 3scale as query parameters or headers.
type UsageReport ¶
type UsageReport struct { PeriodWindow PeriodWindow MaxValue int CurrentValue int }
UsageReport for rate limiting information gathered from using extensions
func (UsageReport) IsForDay ¶ added in v0.5.0
func (ur UsageReport) IsForDay() bool
func (UsageReport) IsForEternity ¶ added in v0.5.0
func (ur UsageReport) IsForEternity() bool
func (UsageReport) IsForHour ¶ added in v0.5.0
func (ur UsageReport) IsForHour() bool
func (UsageReport) IsForMinute ¶ added in v0.5.0
func (ur UsageReport) IsForMinute() bool
func (UsageReport) IsForMonth ¶ added in v0.5.0
func (ur UsageReport) IsForMonth() bool
func (UsageReport) IsForWeek ¶ added in v0.5.0
func (ur UsageReport) IsForWeek() bool
func (UsageReport) IsForYear ¶ added in v0.5.0
func (ur UsageReport) IsForYear() bool
func (UsageReport) IsSame ¶ added in v0.5.0
func (ur UsageReport) IsSame(usageReport UsageReport) bool
IsSame does a comparison of two usage reports. They are considered the same only if their PeriodWindows are equal and the max value for the limit has not changed. Current limit values are ignored.
type UsageReports ¶
type UsageReports map[string][]UsageReport
UsageReports defines a map of metric names to a list of 'UsageReport'
func (UsageReports) OrderByAscendingGranularity ¶ added in v0.5.0
func (urs UsageReports) OrderByAscendingGranularity()
OrderByAscendingGranularity sorts each slice in the usage reports in order of ascending granularity
func (UsageReports) OrderByDescendingGranularity ¶ added in v0.5.0
func (urs UsageReports) OrderByDescendingGranularity()
OrderByDescendingGranularity sorts each slice in the usage reports in order of descending granularity