Documentation
¶
Overview ¶
Package api defines the types used by the Turbine Labs public API.
Index ¶
- Constants
- Variables
- func CircuitBreakersPtrEquals(cb1, cb2 *CircuitBreakers) bool
- func CohortSeedPtrEquals(cp1, cp2 *CohortSeed) bool
- func GetKey(i interface{}) (string, bool)
- func OutlierDetectionPtrEquals(od1, od2 *OutlierDetection) bool
- func ParseRangeBoundaries(s string) (int, int, error)
- func RetryPolicyEquals(a, b *RetryPolicy) bool
- func WalkConstraints(ccf ClusterConstraints, rule *Rule, visit ConstraintVisitor)
- func WalkConstraintsFromAllConstraints(ac AllConstraints, rule *Rule, visit ConstraintVisitor)
- func WalkConstraintsFromRules(rs Rules, visit ConstraintVisitor)
- func WalkConstraintsFromSharedRules(sr SharedRules, visit ConstraintVisitor)
- type APIAuthKey
- type AccessToken
- type AccessTokenKey
- type AccessTokens
- type AllConstraints
- type CertKeyPathPair
- type ChangeDescription
- type ChangeEntry
- type ChangeMeta
- type Checksum
- type CircuitBreakers
- type Cluster
- type ClusterByClusterKey
- type ClusterByName
- type ClusterConstraint
- type ClusterConstraints
- func (ccs ClusterConstraints) AsMap() map[ConstraintKey]ClusterConstraint
- func (ccs ClusterConstraints) Equals(o ClusterConstraints) bool
- func (ccs ClusterConstraints) IndexOf(pred func(ClusterConstraint) (bool, error)) (int, error)
- func (ccs ClusterConstraints) IsValid(container string) *ValidationError
- type ClusterKey
- type Clusters
- type CohortSeed
- type CohortSeedType
- type ConstraintKey
- type ConstraintVisitor
- type CookieDatum
- type CorsConfig
- type Domain
- type DomainAlias
- type DomainAliases
- type DomainKey
- type Domains
- type ErrorCase
- type HTTPHealthCheck
- type HasChecksum
- type HasKey
- type HasOrg
- type HasZone
- type HeaderConstraint
- type HeaderConstraints
- type HeaderDatum
- type HealthCheck
- type HealthChecker
- type HealthChecks
- type HealthChecksByType
- type Instance
- type Instances
- type InstancesByHostPort
- type Listener
- type ListenerKey
- type ListenerProtocol
- type Listeners
- type Match
- type MatchBehavior
- type MatchKind
- type Matches
- type Metadata
- type MetadataByKey
- type MetadataCheck
- type Metadatum
- type Org
- type OrgKey
- type Orgs
- type OutlierDetection
- type Proxies
- type Proxy
- type ProxyKey
- type Redirect
- type RedirectType
- type Redirects
- type ResponseData
- type ResponseDatum
- type RetryPolicy
- type Route
- type RouteKey
- type Routes
- type Rule
- type RuleKey
- type Rules
- type SSLConfig
- type SSLProtocol
- type SameSiteType
- type SharedRules
- type SharedRulesKey
- type SharedRulesSlice
- type TCPHealthCheck
- type TracingConfig
- type User
- type UserKey
- type Users
- type ValidationError
- func ConstraintMetadataValid(m Metadata) *ValidationError
- func ConstraintPropertiesValid(m Metadata) *ValidationError
- func InstanceMetadataIsValid(md Metadata) *ValidationError
- func MetadataValid(container string, md Metadata, checks ...MetadataCheck) *ValidationError
- func SharedRulesPropertiesValid(m Metadata) *ValidationError
- func UserPropertiesValid(props Metadata) *ValidationError
- type ValidationErrorsByAttribute
- type Zone
- type ZoneKey
- type Zones
Constants ¶
const ( // AllowedIndexPatternStr is a regexp pattern describing the acceptable // contents of something that may be used as an index in a changelog // path. AllowedIndexPatternStr = `^[^\[\]]+$` // KeyPatternStr is the regexp pattern one of our keys is expected to meet KeyPatternStr = `^[0-9a-zA-Z]+(-[0-9a-zA-Z]+)*$` // AllowedIndexPatternMatchFailure is a message describing failure to match // the pattern for what may be used as an index entry. AllowedIndexPatternMatchFailure = "may not contain [ or ] characters" // KeyPatternMatchFailure is a message returned when some key did not match // the pattern required. KeyPatternMatchFailure = "must match pattern: " + KeyPatternStr // HeaderNamePatternStr specifies what can be used when a header name is // required. HeaderNamePatternStr = "^[0-9A-Za-z-]+$" // CookieNamePatternStr specifies what can be used when a cookie name is // required. CookieNamePatternStr = "^[0-9A-Za-z_.-]+$" // RangePatternStr specifies the format expected for range matches. RangeMatchPatternStr = `^\s*\[\s*([-+]?\d+),\s*([-+]?\d+)\s*\)\s*$` )
const ( // DomainCharSet is a description of the format which must be used for the // core (non wildcard portion) of a domain alais. DomainOnlyPattern = "[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)*" // AliasPatternFailure is the message returned if a domain alias does not // meet DomainAliasPattern. AliasPatternFailure = "aliases may start with '*.' or end with '.*'. They " + "must be composed of characters matching [a-zA-Z_.-]" )
const ( // HostPatternString represents the pattern that an Instance hostanme must // match. HostPatternString = "^[a-zA-Z0-9_.-]+$" // HostPatternMatchFailure is the error message returned when in invalid name // is provided. HostPatternMatchFailure = "host must match " + HostPatternString )
const ( // CookiMatchKind matches against a request's cookies CookieMatchKind MatchKind = "cookie" // HeaderMatchKind matches against a request's headers HeaderMatchKind MatchKind = "header" // QueryMatchKind matches against a requests's query parameters QueryMatchKind MatchKind = "query" // ExactMatchBehavior matches a request attribute with an exact comparison. ExactMatchBehavior MatchBehavior = "exact" // RegexMatchBehavior matches a request attribute as a regex. RegexMatchBehavior MatchBehavior = "regex" // RangeBehaviuorKind matches a request attribute as a numeric range. RangeMatchBehavior MatchBehavior = "range" // PrefixBehaviorkind matches a request attribute as a prefix. PrefixMatchBehavior MatchBehavior = "prefix" // SuffixBehaviorkind matches a request attribute as a suffix. SuffixMatchBehavior MatchBehavior = "suffix" )
const DescriptionLen = 255
const TbnPublicVersion = "0.19.0"
TbnPublicVersion is the currently released version of open-sourced Turbine Labs projects
Variables ¶
var ( // AllowedIndexPattern is the set of characters which are allowed in a // value that will be used as an index component of a changelog path. AllowedIndexPattern = regexp.MustCompile(AllowedIndexPatternStr) // KeyPattern is the pattern that a key must match. This is a more strict // form of AllowedIndexPattern. KeyPattern = regexp.MustCompile(KeyPatternStr) // HeaderNamePattern is the pattern that a string which will be used an a // HTTP header. HeaderNamePattern = regexp.MustCompile(HeaderNamePatternStr) // CookieNamePattern is the pattern that a string must match if it going to // be used as a cookie name. CookieNamePattern = regexp.MustCompile(CookieNamePatternStr) // RangeMatchPattern is the pattern that a range match From.Value should have. RangeMatchPattern = regexp.MustCompile(RangeMatchPatternStr) )
var ( // MetadataCheckNonEmptyKeys produces an error if the Metadatum has an empty // Key MetadataCheckNonEmptyKeys = MetadataCheck(func(kv Metadatum) *ValidationError { if kv.Key == "" { return &ValidationError{ []ErrorCase{{"key", "must not be empty"}}, } } return nil }) // MetadataCheckNonEmptyValues produces an error if the Metadatum has an empty // Value MetadataCheckNonEmptyValues = MetadataCheck(func(kv Metadatum) *ValidationError { if kv.Value == "" { return &ValidationError{ []ErrorCase{{"value", "must not be empty"}}, } } return nil }) )
var DefaultProtocols = []SSLProtocol{TLS1, TLS1_1, TLS1_2}
DefaultProtocols indicates which protocols will be supported if none are specified in the SSLConfig object for a domain.
var DomainAliasPattern = regexp.MustCompile(fmt.Sprintf( "^("+ `(\*\.%s)|`+ `(%s\.\*)|`+ "(%s)"+ ")$", DomainOnlyPattern, DomainOnlyPattern, DomainOnlyPattern))
DomainAliasPattern is a regexp that will be used to match against proposed domain aliases.
Functions ¶
func CircuitBreakersPtrEquals ¶
func CircuitBreakersPtrEquals(cb1, cb2 *CircuitBreakers) bool
CircuitBreakersPtrEquals provides a way to compare two CircuitBreakers pointers
func CohortSeedPtrEquals ¶
func CohortSeedPtrEquals(cp1, cp2 *CohortSeed) bool
func OutlierDetectionPtrEquals ¶
func OutlierDetectionPtrEquals(od1, od2 *OutlierDetection) bool
OutlierDetectionPtrEquals provides a way to compare two OutlierDetection pointers
func ParseRangeBoundaries ¶
ParseRangeBoundaries splits out the boundaries contained in a range string. Returns any errors along the way.
func RetryPolicyEquals ¶
func RetryPolicyEquals(a, b *RetryPolicy) bool
Convenience function for calling Equals when you have pointers to two retry policies.
func WalkConstraints ¶
func WalkConstraints(ccf ClusterConstraints, rule *Rule, visit ConstraintVisitor)
WalkConstraints applies the vistior function to all the elements referenced by the given ClusterConstraints, and the given rule pointer.
func WalkConstraintsFromAllConstraints ¶
func WalkConstraintsFromAllConstraints(ac AllConstraints, rule *Rule, visit ConstraintVisitor)
WalkConstraintsFromAllConstraints applies the vistior function to all the constraints referenced by the given ClusterConstraints, and the given rule pointer.
func WalkConstraintsFromRules ¶
func WalkConstraintsFromRules(rs Rules, visit ConstraintVisitor)
WalkConstraintsFromRules applies the vistior function to all the ClusterConstraints, along with the enclosing rule, referenced by the given Rules.
func WalkConstraintsFromSharedRules ¶
func WalkConstraintsFromSharedRules(sr SharedRules, visit ConstraintVisitor)
WalkConstraintsFromSharedRules applies the vistior function to all the ClusterConstraints referenced by the given SharedRules
Types ¶
type APIAuthKey ¶
type APIAuthKey string
type AccessToken ¶
type AccessToken struct {
// AccessTokenKey is the lookup key for this token.
AccessTokenKey AccessTokenKey `json:"access_token_key"`
// Description is a summary of how this token will be used. It may not be
// empty and must be less than 255 characters.
Description string `json:"description"`
// SignedToken is a field that is set only once when the token is created and
// may be passed by a request to authorize it. This may be revoked and should
// be treated as carefully as a password.
SignedToken string `json:"signed_token,omitempty"`
UserKey UserKey `json:"user_key"`
OrgKey OrgKey `json:"-"`
CreatedAt *time.Time `json:"created_at"`
Checksum
}
AccessTokens are personal access tokens owned by users, further specialized by org
func (AccessToken) Equals ¶
func (t AccessToken) Equals(o AccessToken) bool
func (AccessToken) GetChecksum ¶
func (t AccessToken) GetChecksum() Checksum
func (AccessToken) GetOrgKey ¶
func (t AccessToken) GetOrgKey() OrgKey
func (AccessToken) GetUserKey ¶
func (t AccessToken) GetUserKey() UserKey
func (AccessToken) IsNil ¶
func (t AccessToken) IsNil() bool
func (AccessToken) IsValid ¶
func (t AccessToken) IsValid() *ValidationError
func (AccessToken) Key ¶
func (t AccessToken) Key() string
type AccessTokenKey ¶
type AccessTokenKey string
type AccessTokens ¶
type AccessTokens []AccessToken
type AllConstraints ¶
type AllConstraints struct {
Light ClusterConstraints `json:"light"`
Dark ClusterConstraints `json:"dark"`
Tap ClusterConstraints `json:"tap"`
}
AllConstraints define three different ClusterConstraint slices. The Light ClusterConstraint slice is used to determine the Instance to which the live request will be sent and from which the response will be sent to the caller. The Dark ClusterConstraint slice is used to determine an Instance to send a send-and-forget copy of the request to. The Tap ClusterConstraint slice is used to determine an Instance to send a copy of the request to, comparing the response to the Light response.
The Dark and Tap ClusterConstraint slices may be empty. The Light ClusterConstraint slice must always contain at least one entry.
TODO: do we need to identify/declare which requests are idempotent? If Routes are structured properly, this isn't necessary, since you can only add Dark/Tap ClusterConstraints for Routes that are safe to call more than once for the same input.
func (AllConstraints) Equals ¶
func (cc AllConstraints) Equals(o AllConstraints) bool
Check equality between two AllConstraints objects. The objects are equal if each component (Light, Dark, and Tap) is equal.
func (AllConstraints) IsValid ¶
func (cc AllConstraints) IsValid(container string) *ValidationError
Check validity of an AllConstraints struct. A valid AllConstraints must have at lesat one Light constraint and valid Light, Dark, and Tap constraints.
type CertKeyPathPair ¶
type CertKeyPathPair struct {
CertificatePath string `json:"certificate_path"`
KeyPath string `json:"key_path"`
}
CertKeyPathPair is a container that binds a certificate path to a key path. Both of these must be specified.
type ChangeDescription ¶
type ChangeDescription struct {
ChangeMeta
// Diffs is an itemized slice of attributes that were changed. Each modified
// field on a modified object should correspond to one ChangeEntry.
Diffs []ChangeEntry `json:"diffs"`
}
ChangeDescription combines the metadata about a change and the specific object fields and value.
type ChangeEntry ¶
type ChangeEntry struct {
// ObjectType is the kind of object that was modified.
objecttype.ObjectType
// ObjectKey is the key of the object that was changed.
ObjectKey string `json:"object_key"`
// ZoneKey is the zone containing ChangeEntry references an object in this
// zone. If the object changed is not bound to a specific zone the value
// will be ZoneKey("").
ZoneKey ZoneKey `json:"zone_key"`
// ChangeType is the kind of change (i.e. was data added or removed) that is
// being recorded. Each modification will have two changes recorded: a removal
// of the old content and addition of the new content.
changetype.ChangeType
// Path is the path to the data that is changed.
Path string `json:"path"`
// Value is the value that was updated as indicated by ChangeType.
Value string `json:"value"`
}
ChangeEntry records a single change made on a specific object.
type ChangeMeta ¶
type ChangeMeta struct {
// AtMs indicates when the change was made in milliseconds since the Unix
// epoch.
AtMs int64 `json:"at"`
// Txn is an id that can be used to tie multiple object changes to a single
// logical action.
Txn string `json:"txn"`
// OrgKey is the owning organization of the object(s) changed.
OrgKey OrgKey `json:"-"`
// ActorKey is the user key of the person making the recorded change.
ActorKey UserKey `json:"actor_key"`
// Comment records any information provided as part of this change.
Comment string `json:"comment"`
}
ChangeMeta is a collection of data about a change.
func (ChangeMeta) At ¶
func (cm ChangeMeta) At() time.Time
At returns the time that the Change was recorded at.
func (*ChangeMeta) SetAt ¶
func (cm *ChangeMeta) SetAt(t time.Time)
type Checksum ¶
type Checksum struct {
Checksum string `json:"checksum"` // may be overwritten
}
A type commonly embedded in other domain objects to ensure modifications are being on an underlying object in the expected state.
func GetChecksum ¶
type CircuitBreakers ¶
type CircuitBreakers struct {
// MaxConnections is the maximum number of connections that will be
// established to all instances in a cluster within a proxy.
// If set to 0, no new connections will be created. If not specified,
// defaults to 1024.
MaxConnections *int `json:"max_connections"`
// MaxPendingRequests is the maximum number of requests that will be
// queued while waiting on a connection pool to a cluster within a proxy.
// If set to 0, no requests will be queued. If not specified,
// defaults to 1024.
MaxPendingRequests *int `json:"max_pending_requests"`
// MaxRetries is the maximum number of retries that can be outstanding
// to all instances in a cluster within a proxy. If set to 0, requests
// will not be retried. If not specified, defaults to 3.
MaxRetries *int `json:"max_retries"`
// MaxRequests is the maximum number of requests that can be outstanding
// to all instances in a cluster within a proxy. Only applicable to
// HTTP/2 traffic since HTTP/1.1 clusters are governed by the maximum
// connections circuit breaker. If set to 0, no requests will be made.
// If not specified, defaults to 1024.
MaxRequests *int `json:"max_requests"`
}
CircuitBreakers provides limits on various parameters to protect clusters against sudden surges in traffic.
func (CircuitBreakers) Equals ¶
func (cb CircuitBreakers) Equals(o CircuitBreakers) bool
Equals compares two CircuitBreakers for equality
func (CircuitBreakers) IsValid ¶
func (cb CircuitBreakers) IsValid() *ValidationError
IsValid checks for the validity of contained fields.
type Cluster ¶
type Cluster struct {
ClusterKey ClusterKey `json:"cluster_key"` // overwritten on create
ZoneKey ZoneKey `json:"zone_key"`
Name string `json:"name"`
RequireTLS bool `json:"require_tls,omitempty"`
Instances Instances `json:"instances"`
OrgKey OrgKey `json:"-"`
CircuitBreakers *CircuitBreakers `json:"circuit_breakers"`
OutlierDetection *OutlierDetection `json:"outlier_detection"`
HealthChecks HealthChecks `json:"health_checks"`
Checksum
}
A Cluster is a named list of Instances within a zone
func (Cluster) GetChecksum ¶
func (Cluster) GetZoneKey ¶
func (*Cluster) IsValid ¶
func (c *Cluster) IsValid() *ValidationError
Checks the data set on a Cluster and returns whether or not sufficient information is available.
type ClusterByClusterKey ¶
type ClusterByClusterKey []Cluster
Sort a slice of Clusters by ClusterKey. Eg: sort.Sort(ClusterByClusterKey(clusters))
func (ClusterByClusterKey) Len ¶
func (b ClusterByClusterKey) Len() int
func (ClusterByClusterKey) Less ¶
func (b ClusterByClusterKey) Less(i, j int) bool
func (ClusterByClusterKey) Swap ¶
func (b ClusterByClusterKey) Swap(i, j int)
type ClusterByName ¶
type ClusterByName []Cluster
Sort a slice of Clusters by Name. Eg: sort.Sort(ClusterByName(clusters))
func (ClusterByName) Len ¶
func (b ClusterByName) Len() int
func (ClusterByName) Less ¶
func (b ClusterByName) Less(i, j int) bool
func (ClusterByName) Swap ¶
func (b ClusterByName) Swap(i, j int)
type ClusterConstraint ¶
type ClusterConstraint struct {
ConstraintKey ConstraintKey `json:"constraint_key"`
ClusterKey ClusterKey `json:"cluster_key"`
Metadata Metadata `json:"metadata"`
Properties Metadata `json:"properties"`
ResponseData ResponseData `json:"response_data"`
Weight uint32 `json:"weight"`
}
A ClusterConstraint describes a filtering of the Instances in a Cluster based on their Metadata. Instances in the keyed cluster with a superset of the specified Metadata will be included. The Weight of the ClusterConstraint is used to inform selection of one ClusterConstraint over another.
func (ClusterConstraint) Equals ¶
func (cc ClusterConstraint) Equals(o ClusterConstraint) bool
Check equality between two ClusterConstraint objects. For these to be considered equal they must share the same ConstraintKey, ClusterKey, Weight, and Metadata.
func (ClusterConstraint) IsValid ¶
func (cc ClusterConstraint) IsValid() *ValidationError
Checks a ClusterConstraint for validity. A valid constraint will have a non empty ConstraintKey and ClusterKey (always), a Weight greater than 0, and valid metadata.
type ClusterConstraints ¶
type ClusterConstraints []ClusterConstraint
func (ClusterConstraints) AsMap ¶
func (ccs ClusterConstraints) AsMap() map[ConstraintKey]ClusterConstraint
func (ClusterConstraints) Equals ¶
func (ccs ClusterConstraints) Equals(o ClusterConstraints) bool
Check the Equality of two ClusterConstraint slices. Order agnostic.
func (ClusterConstraints) IndexOf ¶
func (ccs ClusterConstraints) IndexOf(pred func(ClusterConstraint) (bool, error)) (int, error)
IndexOf returns the index of the first instance of a ClusterConstraint that returns true for pred. If pred returns an error when checking a constraint IndexOf stops walking ClusterConstraints and returns -1, <the error>
func (ClusterConstraints) IsValid ¶
func (ccs ClusterConstraints) IsValid(container string) *ValidationError
Checks validity of a slice of cluster constraints. This means that each item in the slice must be valid and no constraint key may be duplicated.
type ClusterKey ¶
type ClusterKey string
type CohortSeed ¶
type CohortSeed struct {
Type CohortSeedType `json:"type"` // Type indicates what kind of attribute Name references.
Name string `json:"name"` // Name specifies the source of cohort seed data.
// UseZeroValueSeed controls whether or not missing / unset data is included
// in a stable cohort.
//
// If false (default value): when a request contains no seed value, it will be
// processed normally and handled by a randomly selected backend.
//
// If true: when a request is processed that has no value for the seed then we
// will derive a seed from the empty string. This means that all requests
// without a seed value will be serviced by the same backend. There are
// problematic edge cases here (misspelling the seed source and having all
// traffic land on a backend intended to take 1%, etc) so use with caution.
UseZeroValueSeed bool `json:"use_zero_value_seed"`
}
CohortSeed identifies a request attribute that will be used to group a request into cohort. When a cohort member is mapped to a subset of backend instances it will be consistently sent to the same subset each time.
func (CohortSeed) Equals ¶
func (cs CohortSeed) Equals(o CohortSeed) bool
func (CohortSeed) IsValid ¶
func (c CohortSeed) IsValid() *ValidationError
type CohortSeedType ¶
type CohortSeedType string
CohortSeedType indicates how a CohortSeed sources its data.
const ( // CohortSeedHeader specifies that seed data will be drawn from a request header. CohortSeedHeader CohortSeedType = "header" // CohortSeedCookie specifies that seed data will be taken from a request cookie. CohortSeedCookie CohortSeedType = "cookie" // CohortSeedQuery specifies that seed data will be taken from a path query parameter. CohortSeedQuery CohortSeedType = "query" )
type ConstraintKey ¶
type ConstraintKey string
type ConstraintVisitor ¶
type ConstraintVisitor func(ClusterConstraint, *Rule)
ConstraintVisitor is a function that operates on a ClusterConstraint, and the enclosing Rule, if any.
type CookieDatum ¶
type CookieDatum struct {
ResponseDatum
// ExpiresInSec indicates how long a cookie will be valid (in seconds) or
// indicates that a cookie should be expired if set to 0. Specifically for
// values > 0 this becomes a 'Max-Age' cookie annotation and for 0 'Expires'
// is set to the unix epoch, UTC.
ExpiresInSec *uint `json:"expires_in_sec"`
// Domain specifies hosts to which the cookie will be sent.
Domain string `json:"domain"`
// Path indicates a URL path that must be met in a requset for the cookie to
// be sent to the server.
Path string `json:"path"`
// Secure will only be sent to a server when a request is made via HTTPS.
Secure bool `json:"secure"`
// HttpOnly cookies are not available via javascript throught Document.cookie.
HttpOnly bool `json:"http_only"`
// SameSiteType specifies how a cookie should be treated when a request is being
// made across site boundaries (e.g. from another domain, used to help protect
// against CSRF).
SameSite SameSiteType `json:"same_site"`
}
CookieDatum represents a cookie that should be attached to the response to some requset served by the object containing a ResponseData config. A CookieDatum's Name is case sensitive.
func (CookieDatum) Annotation ¶
func (c CookieDatum) Annotation() string
Annotation returns a string that is attached to the cookie returned to specify how it should be treated by the browser based on its configuration.
func (CookieDatum) Equals ¶
func (cd CookieDatum) Equals(o CookieDatum) bool
Equals returns true if all CookieDatum attributes are the same.
func (CookieDatum) IsValid ¶
func (cd CookieDatum) IsValid() *ValidationError
IsValid ensures reasonable values for CookieDatum attributes:
- Name may not be empty and must be a valid cookie name
- SameSite must be one of the defined SameSite values
type CorsConfig ¶
type CorsConfig struct {
AllowedOrigins []string `json:"allowed_origins"`
AllowCredentials bool `json:"allow_credentials"`
ExposedHeaders []string `json:"exposed_headers"`
MaxAge int `json:"max_age"`
AllowedMethods []string `json:"allowed_methods"`
AllowedHeaders []string `json:"allowed_headers"`
}
CorsConfig describes how the domain should respond to OPTIONS requests. For a detailed discussion of what each attribute means see https://developer.mozilla.org/docs/Web/HTTP/Access_control_CORS. For an even simpler flowchart of how things work see https://www.html5rocks.com/static/images/cors_server_flowchart.png
func (CorsConfig) AllowHeadersString ¶
func (cc CorsConfig) AllowHeadersString() string
AllowHeadersString produces a comma-separated string for the AllowedHeaders slice.
func (CorsConfig) Equals ¶
func (cc CorsConfig) Equals(o CorsConfig) bool
Equals compares two CorsConfig objects returning true if they are the same. AllowedOrigins, ExposedHeaders, AllowedMethods, and AllowedHeaders are compared without regard for ordering of their content.
func (CorsConfig) ExposedHeadersString ¶
func (cc CorsConfig) ExposedHeadersString() string
ExposedHeadersString produces a comma-separated string for the ExposedHeaders slice.
func (CorsConfig) IsValid ¶
func (cc CorsConfig) IsValid() *ValidationError
IsValid checks a CorsConfig object for validity.
func (CorsConfig) MethodString ¶
func (cc CorsConfig) MethodString() string
MethodString produces a comma-separated string for the AllowedMethods slice.
type Domain ¶
type Domain struct {
DomainKey DomainKey `json:"domain_key"` // overwritten for create
ZoneKey ZoneKey `json:"zone_key"`
Name string `json:"name"`
Port int `json:"port"`
SSLConfig *SSLConfig `json:"ssl_config,omitempty"`
Redirects Redirects `json:"redirects"`
GzipEnabled bool `json:"gzip_enabled"`
CorsConfig *CorsConfig `json:"cors_config"`
Aliases DomainAliases `json:"aliases"`
OrgKey OrgKey `json:"-"`
ForceHTTPS bool `json:"force_https"`
Checksum
}
A Domain represents the TLD or subdomain under which which a set of Routes is served.
func (Domain) Equals ¶
Check if all fields of this domain are exactly equal to fields of another domain.
func (Domain) GetChecksum ¶
func (Domain) GetZoneKey ¶
func (Domain) IsValid ¶
func (d Domain) IsValid() *ValidationError
Checks for validity of a domain. A domain is considered valid if it has a:
- DomainKey OR is being checked in before creation
- non-empty ZoneKey
- non-empty Name
- non-zero Port
type DomainAlias ¶
type DomainAlias string
func (DomainAlias) Equals ¶
func (da DomainAlias) Equals(o DomainAlias) bool
func (DomainAlias) IsValid ¶
func (da DomainAlias) IsValid() *ValidationError
type DomainAliases ¶
type DomainAliases []DomainAlias
func (DomainAliases) Equals ¶
func (da DomainAliases) Equals(o DomainAliases) bool
func (DomainAliases) IsValid ¶
func (das DomainAliases) IsValid() *ValidationError
func (DomainAliases) Strings ¶
func (d DomainAliases) Strings() []string
type Domains ¶
type Domains []Domain
func (Domains) Equals ¶
Checks for exact contents parity between two Domains. This requires that each Domain with the same Key be Equal to each other.
func (Domains) IsValid ¶
func (ds Domains) IsValid() *ValidationError
Checks validity of a domain slice. Requise that each domain is valid and that there are no domains with duplicate keys.
type ErrorCase ¶
ErrorCase represents an error in an API object. It contains both the attribute indicated as, approximately, a dot-separated path to the field and a description of the error.
type HTTPHealthCheck ¶
type HTTPHealthCheck struct {
// Host defines the value of the host header in the HTTP health check
// request. If left empty (default value), the name of the cluster being
// health checked will be used.
Host string `json:"host"`
// Path specifies the HTTP path that will be requested during health
// checking.
Path string `json:"path"`
// ServiceName is an optional service name parameter which is used to
// validate the identity of the health checked cluster. This is done by
// comparing the `X-Envoy-Upstream-Healthchecked-Cluster` header to
// this value.
ServiceName string `json:"service_name"`
// RequestHeadersToAdd specifies a list of HTTP headers that should be
// added to each request that is sent to the health checked cluster.
RequestHeadersToAdd Metadata `json:"request_headers_to_add,omitempty"`
}
HTTPHealthCheck configures the http health check endpoint for a cluster.
func (*HTTPHealthCheck) Equals ¶
func (hhc *HTTPHealthCheck) Equals(ohc *HTTPHealthCheck) bool
Equals checks for equality between two HTTPHealthCheck pointers
type HasChecksum ¶
type HeaderConstraint ¶
type HeaderConstraint struct {
Name string `json:"name"`
Value string `json:"value"`
CaseSensitive bool `json:"case_sensitive"`
Invert bool `json:"invert"`
}
HeaderConstraint specifies requirements of request header for a redirect directive. Name must match the HeaderNamePattern regex and Value must be a valid regex.
CaseSensitive means that the header's value will be compared to Value without taking case into account; header name is always compared to Name without case sensitivity.
func (HeaderConstraint) Equals ¶
func (hc HeaderConstraint) Equals(o HeaderConstraint) bool
func (HeaderConstraint) IsValid ¶
func (hc HeaderConstraint) IsValid() *ValidationError
type HeaderConstraints ¶
type HeaderConstraints []HeaderConstraint
func (HeaderConstraints) Equals ¶
func (hcs HeaderConstraints) Equals(o HeaderConstraints) bool
func (HeaderConstraints) IsValid ¶
func (hcs HeaderConstraints) IsValid() *ValidationError
type HeaderDatum ¶
type HeaderDatum struct {
ResponseDatum
}
HeaderDatum represents a header that should be attached to a response to some requset served by the object containing a ResponseData config. Some points to note are that HeaderDatum are not case sensitive with respect to their Name value which impacts equality checks.
func (HeaderDatum) CanonicalName ¶
func (hd HeaderDatum) CanonicalName() string
CanonicalName returns a canonical name for the header, suitable for comparison across HeaderDatum.
func (HeaderDatum) Equals ¶
func (hd HeaderDatum) Equals(o HeaderDatum) bool
Equals compares two HeaderDatum objects. A HeaderDatum is determined to be equal if the name (case insensitive check), value, and ValueIsLiteral attributes are equal.
func (HeaderDatum) IsValid ¶
func (hd HeaderDatum) IsValid() *ValidationError
IsValid ensures that HeaderDatum attributes have reasonable values:
- Name must not be empty
- Name must be a valid header
- Value may not be empty
type HealthCheck ¶
type HealthCheck struct {
// TimeoutMsec is the time to wait for a health check response. If the
// timeout is reached without a response, the health check attempt will
// be considered a failure. This is a required field and must be greater
// than 0.
TimeoutMsec int `json:"timeout_msec"`
// IntervalMsec is the interval between health checks. Note that the
// first round of health checks will occur during startup before any
// traffic is routed to a cluster. This means that the
// `NoTrafficIntervalMsec` value will be used as the first interval of
// health checks.
IntervalMsec int `json:"interval_msec"`
// IntervalJitterMsec is an optional jitter amount that is added to each
// interval value calculated by the proxy. If not specified, defaults
// to 0.
IntervalJitterMsec *int `json:"interval_jitter_msec,omitempty"`
// UnhealthyThreshold is the number of unhealthy health checks required
// before a host is marked unhealthy. Note that for *http* health
// checking if a host responds with 503 this threshold is ignored and
// the host is considered unhealthy immediately.
UnhealthyThreshold int `json:"unhealthy_threshold"`
// HealthyThreshold is the number of healthy health checks required
// before a host is marked healthy. Note that during startup, only a
// single successful health check is required to mark a host healthy.
HealthyThreshold int `json:"healthy_threshold"`
// ReuseConnection determines whether to reuse a health check connection
// between health checks. Default is true.
ReuseConnection *bool `json:"reuse_connection,omitempty"`
// NoTrafficIntervalMsec is a special health check interval that is
// used when a cluster has never had traffic routed to it. This lower
// interval allows cluster information to be kept up to date, without
// sending a potentially large amount of active health checking traffic
// for no reason. Once a cluster has been used for traffic routing,
// The proxy will shift back to using the standard health check interval
// that is defined. Note that this interval takes precedence over any
// other. Defaults to 60s.
NoTrafficIntervalMsec *int `json:"no_traffic_interval_msec,omitempty"`
// UnhealthyIntervalMsec is a health check interval that is used for
// hosts that are marked as unhealthy. As soon as the host is marked as
// healthy, the proxy will shift back to using the standard health check
// interval that is defined. This defaults to the same value as
// IntervalMsec if not specified.
UnhealthyIntervalMsec *int `json:"unhealthy_interval_msec,omitempty"`
// UnhealthyEdgeIntervalMsec is a special health check interval that
// is used for the first health check right after a host is marked as
// unhealthy. For subsequent health checks the proxy will shift back to
// using either "unhealthy interval" if present or the standard
// health check interval that is defined. Defaults to the same value as
// UnhealthIntervalMsec if not specified.
UnhealthyEdgeIntervalMsec *int `json:"unhealthy_edge_interval_msec,omitempty"`
// HealthyEdgeIntervalMsec is a special health check interval that is
// used for the first health check right after a host is marked as
// healthy. For subsequent health checks the proxy will shift back to
// using the standard health check interval that is defined. Defaults
// to the same value as IntervalMsec if not specified
HealthyEdgeIntervalMsec *int `json:"healthy_edge_interval_msec,omitempty"`
// HealthChecker defines the type of health checking to use.
HealthChecker HealthChecker `json:"health_checker"`
}
HealthCheck configures the parameters to do health checking against instances in a cluster.
func (HealthCheck) Equals ¶
func (hc HealthCheck) Equals(o HealthCheck) bool
Equals compares two HealthChecks for equality
func (HealthCheck) IsValid ¶
func (hc HealthCheck) IsValid() *ValidationError
IsValid checks that a HealthCheck object is valid.
type HealthChecker ¶
type HealthChecker struct {
// HTTPHealthCheck defines the parameters for http health checking.
HTTPHealthCheck *HTTPHealthCheck `json:"http_health_check,omitempty"`
// TCPHealthCheck defines the parameters for tcp health checking.
TCPHealthCheck *TCPHealthCheck `json:"tcp_health_check,omitempty"`
}
HealthChecker is a union type where only a single field can be defined.
func (HealthChecker) Equals ¶
func (hc HealthChecker) Equals(ohc HealthChecker) bool
Equals checks two HealthChecker objects for equality
func (HealthChecker) IsValid ¶
func (hc HealthChecker) IsValid() *ValidationError
IsValid checks a HealthChecker object for validity.
type HealthChecks ¶
type HealthChecks []HealthCheck
HealthChecks is a slice of HealthCheck objects. Currently, the proxy only supports a single health check per cluster
func (HealthChecks) Equals ¶
func (hcs HealthChecks) Equals(hcs2 HealthChecks) bool
Equals checks two HealthChecks for equality.
func (HealthChecks) IsValid ¶
func (hcs HealthChecks) IsValid() *ValidationError
IsValid confirms a HealthChecks instance is valid.
type HealthChecksByType ¶
type HealthChecksByType HealthChecks
HealthChecksByType implements sort.Interface to allow sorting by health check type
func (HealthChecksByType) Len ¶
func (h HealthChecksByType) Len() int
func (HealthChecksByType) Less ¶
func (h HealthChecksByType) Less(i, j int) bool
func (HealthChecksByType) Swap ¶
func (h HealthChecksByType) Swap(i, j int)
type Instance ¶
type Instance struct {
Host string `json:"host"`
Port int `json:"port"`
Metadata Metadata `json:"metadata"`
}
An Instance is a hostname/port pair with Metadata
func (Instance) Equals ¶
Equals checks for exact object equality. This requires that Instance host and port are equal as well as its metadata.
func (Instance) IsValid ¶
func (i Instance) IsValid() *ValidationError
IsValid checks for host and port data as both are required for an instance to be well defined
func (Instance) MatchesMetadata ¶
MatchesMetadata returns true if this instance contains all key value pairs in the provided Metadata. The Instance may have more metadata than md and will still be considered to successfully match md.
type Instances ¶
type Instances []Instance
Instances is a slice of Instance
func (Instances) IsValid ¶
func (i Instances) IsValid() *ValidationError
IsValid checks a collection of instances to ensure all are valid
type InstancesByHostPort ¶
type InstancesByHostPort Instances
InstancesByHostPort sorts Instances by Host and Port. Eg: sort.Sort(InstancesByHostPort(instances))
func (InstancesByHostPort) Len ¶
func (b InstancesByHostPort) Len() int
func (InstancesByHostPort) Less ¶
func (b InstancesByHostPort) Less(i, j int) bool
func (InstancesByHostPort) Swap ¶
func (b InstancesByHostPort) Swap(i, j int)
type Listener ¶
type Listener struct {
ListenerKey ListenerKey `json:"listener_key"` // overwritten for create
ZoneKey ZoneKey `json:"zone_key"`
Name string `json:"name"`
IP string `json:"ip"`
Port int `json:"port"`
Protocol ListenerProtocol `json:"protocol"`
DomainKeys []DomainKey `json:"domain_keys"`
TracingConfig *TracingConfig `json:"tracing_config"`
OrgKey OrgKey `json:"-"`
Checksum
}
A Listener represents a port Envoy will listen on
func (Listener) Equals ¶
Check if all fields of this listener are exactly equal to fields of another listener.
func (Listener) GetChecksum ¶
func (Listener) GetZoneKey ¶
func (Listener) IsValid ¶
func (l Listener) IsValid() *ValidationError
Checks for validity of a listener. A listener is considered valid if it has a:
- ListenerKey OR is being checked before creation
- non-empty ZoneKey
- non-empty Name
- an IP equal to 0..0.0.0 (tobe expanded as we add full listener support)
- non-zero Port
- a protocol equal to http_auto (to be expanded as we add full listener support)
type ListenerKey ¶
type ListenerKey string
type ListenerProtocol ¶
type ListenerProtocol string
const ( HttpListenerProtocol ListenerProtocol = "http" Http2ListenerProtocol ListenerProtocol = "http2" HttpAutoListenerProtocol ListenerProtocol = "http_auto" TCPListenerProtocol ListenerProtocol = "tcp" )
func ListenerProtocolFromString ¶
func ListenerProtocolFromString(s string) (ListenerProtocol, error)
func (ListenerProtocol) IsValid ¶
func (lp ListenerProtocol) IsValid() bool
right now we only support the http_auto protocol. This will be expanded as we fully convert to the proxy -> listener -> domain model.
type Match ¶
type Match struct {
Kind MatchKind `json:"kind"`
Behavior MatchBehavior `json:"behavior"`
From Metadatum `json:"from"`
To Metadatum `json:"to"`
}
A Match represents a mapping of a Metadatum from a MatchKind-typed request parameter to another Metadatum, with the MatchBehavior dictating how the values of the request parameter should be matched.
Example:
Match{
HeaderMatchKind,
ExactMatchBehavior,
Metadatum{"X-SwVersion", "1.0"},
Metadatum{"sunset", "true"},
}
would define a match which looks for a specific value of "1.0" for the X-SwVersion header in a request, and if present, adds a specific key/value constraint of sunset=true.
Values can be omitted to map any value for the specified key.
Example:
Match{
HeaderMatchKind,
ExactMatchBehavior,
Metadatum{Key:"X-GitSha"},
Metadatum{Key:"git-sha"},
}
would define a match which looks for the X-GitSha header in a request, and if present, adds the value of that header as the value for a "git-sha" metadata constraint on Instances in the Cluster defined by the Route.
func (Match) Equals ¶
Checks for equality between two match objects. For two Match objects to be considered equal they must share a Kind, From, and To.
func (Match) IsValid ¶
func (m Match) IsValid() *ValidationError
Check this Match for validity. A valid match requires a valid matchkind, a From datum with Key set, and either an empty To datum or one with both Key and Value set.
func (*Match) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler method for Match. It defaults an empty Behavior field to `ExactBehaviorkind`.
type MatchBehavior ¶
type MatchBehavior string
MatchBehavior is an Enumeration of possible ways to match a request attribute.
type MatchKind ¶
type MatchKind string
MatchKind is an Enumeration of the attributes by which a request can be matched.
type Matches ¶
type Matches []Match
Matches is a slice of Match objects
func (Matches) Equals ¶
Checks a slice of Match objects for equality against another. This comparison is order agnostic.
func (Matches) IsValid ¶
func (m Matches) IsValid() *ValidationError
Checks validity of a slice of Match objects. For the slice to be valid each entry must be valid.
type Metadata ¶
type Metadata []Metadatum
Metadata is a vector of Metadatums.
func MetadataFromMap ¶
MetadataFromMap converts a map[string]string into a Metadata
func (Metadata) Compare ¶
Compare compares the receiver to another Metadata. It returns a value > 0 if the receiver is greater, < 0 if the receiver is lesser, and 0 if they are equal. Both receiver and target are sorted by key as a side effect.
type MetadataByKey ¶
type MetadataByKey Metadata
MetadataByKey implements sort.Interface to allow sorting of Metadata by Metadatum Key. Eg: sort.Sort(MetadataByKey(metadata))
func (MetadataByKey) Len ¶
func (b MetadataByKey) Len() int
func (MetadataByKey) Less ¶
func (b MetadataByKey) Less(i, j int) bool
func (MetadataByKey) Swap ¶
func (b MetadataByKey) Swap(i, j int)
type MetadataCheck ¶
type MetadataCheck func(Metadatum) *ValidationError
func MetadataCheckKeysMatchPattern ¶
func MetadataCheckKeysMatchPattern(pattern *regexp.Regexp, errStr string) MetadataCheck
MetadataCheckKeysMatchPattern produces an error with the given error string, if the Metadatum fails to match the given pattern.
type Org ¶
type Org struct {
OrgKey OrgKey `json:"org_key"`
Name string `json:"name"`
ContactEmail string `json:"contact_email"`
Checksum
}
An Org is a Turbine customer. It is composed of users and is ultimately the entity that owns all other objects in our system: Clusters, Routes, etc.
func (Org) GetChecksum ¶
func (Org) IsValid ¶
func (o Org) IsValid() *ValidationError
type OutlierDetection ¶
type OutlierDetection struct {
// The time interval between ejection analysis sweeps. This can result in
// both new ejections due to success rate outlier detection as well as
// hosts being returned to service. Defaults to 10s and must be greater
// than 0.
IntervalMsec *int `json:"interval_msec"`
// The base time that a host is ejected for. The real time is equal to
// the base time multiplied by the number of times the host has been
// ejected. Defaults to 30s. Setting this to 0 means that no host will be
// ejected for longer than `interval_msec`.
BaseEjectionTimeMsec *int `json:"base_ejection_time_msec"`
// The maximum % of an upstream cluster that can be ejected due to
// outlier detection. Defaults to 10% but will always eject at least one
// host.
MaxEjectionPercent *int `json:"max_ejection_percent"`
// The number of consecutive 5xx responses before a consecutive 5xx ejection
// occurs. Defaults to 5. Setting this to 0 effectively turns off the
// consecutive 5xx detector.
Consecutive5xx *int `json:"consecutive_5xx"`
// The % chance that a host will be actually ejected when an outlier status
// is detected through consecutive 5xx. This setting can be used to disable
// ejection or to ramp it up slowly. Defaults to 100.
EnforcingConsecutive5xx *int `json:"enforcing_consecutive_5xx"`
// The % chance that a host will be actually ejected when an outlier status
// is detected through success rate statistics. This setting can be used to
// disable ejection or to ramp it up slowly. Defaults to 100.
EnforcingSuccessRate *int `json:"enforcing_success_rate"`
// The number of hosts in a cluster that must have enough request volume to
// detect success rate outliers. If the number of hosts is less than this
// setting, outlier detection via success rate statistics is not performed
// for any host in the cluster. Defaults to 5. Setting this to 0 effectively
// triggers the success rate detector regardless of the number of valid hosts
// during an interval (as determined by `success_rate_request_volume`).
SuccessRateMinimumHosts *int `json:"success_rate_minimum_hosts"`
// The minimum number of total requests that must be collected in one
// interval (as defined by the interval duration) to include this host
// in success rate based outlier detection. If the volume is lower than this
// setting, outlier detection via success rate statistics is not performed
// for that host. Defaults to 100.
SuccessRateRequestVolume *int `json:"success_rate_request_volume"`
// This factor is used to determine the ejection threshold for success rate
// outlier ejection. The ejection threshold is the difference between the
// mean success rate, and the product of this factor and the standard
// deviation of the mean success rate: mean - (stdev *
// success_rate_stdev_factor). This factor is divided by a thousand to get a
// double. That is, if the desired factor is 1.9, the runtime value should
// be 1900. Defaults to 1900. Setting this to 0 effectively turns off the
// success rate detector.
SuccessRateStdevFactor *int `json:"success_rate_stdev_factor"`
// The number of consecutive gateway failures (502, 503, 504 status or
// connection errors that are mapped to one of those status codes) before a
// consecutive gateway failure ejection occurs. Defaults to 5.
ConsecutiveGatewayFailure *int `json:"consecutive_gateway_failure"`
// The % chance that a host will be actually ejected when an outlier status
// is detected through consecutive gateway failures. This setting can be
// used to disable ejection or to ramp it up slowly. Defaults to 0.
EnforcingConsecutiveGatewayFailure *int `json:"enforcing_consecutive_gateway_failure"`
}
OutlierDetection is a form of passive health checking that dynamically determines whether instances in a cluster are performing unlike others and preemptively removes them from a load balancing set.
func (OutlierDetection) Equals ¶
func (od OutlierDetection) Equals(o OutlierDetection) bool
Equals compares two OutlierDetections for equality
func (OutlierDetection) IsValid ¶
func (od OutlierDetection) IsValid() *ValidationError
IsValid checks for the validity of contained fields.
type Proxy ¶
type Proxy struct {
ProxyKey ProxyKey `json:"proxy_key"` // overwritten on create
ZoneKey ZoneKey `json:"zone_key"`
Name string `json:"name"`
DomainKeys []DomainKey `json:"domain_keys"`
ListenerKeys []ListenerKey `json:"listener_keys"`
Listeners []Listener `json:"listeners"`
OrgKey OrgKey `json:"-"`
Checksum
}
A Proxy is a named Instance, responsible for serving one or more Listeners.
Current behavior: For backwards compatibility, when the DomainKeys field is populated it indicates that the specified Domains should be attached to Listeners with matching ports. If no such Listener exists the consumer should create a default one to support the Domain. Note that because Listeners allow specification of an address to bind to, and Domains do not, is possible to create a confusing configuration where multiple Listeners are configured for a Proxy port, and we can't determine which of the Listeners a Domain should be attached to. In this case consumers should attach the Domain to _every_ Listener configured for the given port. Note that Domains cannot be mapped to Listeners that are configured for non-http protocols.
Future behavior: In the future we will remove the DomainKeys field from the Proxy. Proxies will create the Listeners indicated in ListenerKeys, which in turn will have mapped Domains.
func (Proxy) Equals ¶
Check if one Proxy exactly equals another. This checks all fields (including derived fields).
func (Proxy) GetChecksum ¶
func (Proxy) GetZoneKey ¶
func (Proxy) IsValid ¶
func (p Proxy) IsValid() *ValidationError
Check validity of a new or existing proxy. A Valid proxy requires a ProxyKey (unless new), a ZoneKey, and valid sub objects (Instance, Listeners & Domains).
type Redirect ¶
type Redirect struct {
Name string `json:"name"`
From string `json:"from"`
To string `json:"to"`
RedirectType RedirectType `json:"redirect_type"`
HeaderConstraints HeaderConstraints `json:"header_constraints"`
}
Redirect specifies how URLs within this domain may need to be rewritten. Each Redirect has a name, a regex that matches the requested URL, a to indicating how the url should be rewritten, and a flag to indicate how the redirect will be handled by the proxying layer.
From may include capture groups which may be referenced by "$<group number>".
Example:
Redirect{
Name: "force-https",
From: "(.*)",
To: "https://$host$1",
RedirectType: PermanentRedirect,
HeaderConstraints: HeaderConstraints{
HeaderConstraint{
Name: "X-Forwarded-Proto",
Value: "https",
Invert: true,
},
},
}
func (Redirect) IsValid ¶
func (r Redirect) IsValid() *ValidationError
IsValid checks the validity of a Redirect; we currently verify that a redirect:
- has a non-empty name matching HeaderNamePattern
- contains a valid regex in From
- contains a non-empty to
- has a valid redirect type
It is worth noting that no attempt is made to verify the capture group mapping into the 'To' field or ensure that the 'To' field is even a valid URL after mapping is done.
type RedirectType ¶
type RedirectType string
const ( // PermanentRedirect will be handled by returned a HTTP response code 301 // with the new URL that should be retrieved. PermanentRedirect RedirectType = "permanent" // TemporaryRedirect will be handled by returned a HTTP response code 302 // with the new URL that should be retrieved. TemporaryRedirect RedirectType = "temporary" )
type Redirects ¶
type Redirects []Redirect
Redirects is a collection of Domain redirect definitions
func (Redirects) AsMap ¶
AsMap converts an ordered slice of Redirects into a map where each redirect is indexed by its name.
func (Redirects) Equals ¶
Equals checks that rs and o are the same redirect slices. Because redirect application depends on order we verify that the slices have the same order.
func (Redirects) IsValid ¶
func (rs Redirects) IsValid() *ValidationError
IsValid verifies that no two Redirect entries have the same name and that each Redirect definition contained is valid.
type ResponseData ¶
type ResponseData struct {
// Headers are HTTP headers that will be attached to a response.
Headers []HeaderDatum `json:"headers,omitempty"`
// Cookies are attached via 'Set-Cookie' header.
Cookies []CookieDatum `json:"cookies,omitempty"`
}
ResponseData is a collection of annotations that should be applied to responses when handling a request.
func (ResponseData) Equals ¶
func (rd ResponseData) Equals(o ResponseData) bool
Equals checks if two ResponseData objects are semantically equivalent. They are considered equal iff they contain the same set of Headers and Cookies. A change in slice order is not considered a difference in ResponseData objects.
A HeaderDatum is identified by its Name attribute via case-insensitive comparison. This means if ResponseData 1 has Header "x-foo" and ResponseData 2 has header "X-Foo" that are otherwise equal then are considered the same. CookieDatum is identified by its name attribute via case sensitive comparison.
func (ResponseData) IsValid ¶
func (rd ResponseData) IsValid() *ValidationError
IsValid verifies that each header and each cookie is unique within the ResponseData. Header names are not case sensitive. Cookie names are case sensitive.
func (ResponseData) Len ¶
func (rd ResponseData) Len() int
Len returns the total number of ResponseData headers and cookies.
func (ResponseData) MergeFrom ¶
func (rd ResponseData) MergeFrom(overrides ResponseData) ResponseData
MergeFrom combines two ResponseData objects into a single, new ResponseData. The headers and cookies in the given ResponseData override (by name) those in the receiver ResponseData, keeping the original ResponseData's ordering. Additional ResponseData from the overrides are appended, also maintaining their order. Both source ResponseData objects are assumed to be valid.
type ResponseDatum ¶
type ResponseDatum struct {
// Name of the data being sent back to the requesting client.
Name string `json:"name"`
// Value is either a literal value or a reference to metadatum on the server
// that handles a request.
Value string `json:"value"`
// ValueIsLiteral, if set, means that Value will be treated as a literal
// instead of a reference to be resolved as the key of a metadatum set on
// the server handling a request.
ValueIsLiteral bool `json:"value_is_literal,omitempty"`
}
ResponseDatum represents the set of information necessary to determine how to name and produce the value that should be attached to a response and under what conditions the data should be sent back.
type RetryPolicy ¶
type RetryPolicy struct {
// Number of times to retry an upstream request. Note that the initial
// connection attempt is not included in this number, hence 0 means initial
// attempt and no retries, and 1 means initial attempt plus one retry.
NumRetries int `json:"num_retries"`
// Time limit in milliseconds for a single attempt.
PerTryTimeoutMsec int `json:"per_try_timeout_msec"`
// Total time limit in milliseconds for all attempts (including the initial
// attempt).
TimeoutMsec int `json:"timeout_msec"`
}
RetryPolicy specifies the number of times to retry a request and how long to wait before timing out.
func (RetryPolicy) Equals ¶
func (p RetryPolicy) Equals(o RetryPolicy) bool
Checks for exact equality between this retry policy and another. Exact equality means each field must be equal (== or Equal, as appropriate) to the corresponding field in the parameter.
func (RetryPolicy) IsValid ¶
func (p RetryPolicy) IsValid() *ValidationError
Checks validity of a retry policy. For a retry policy to be valid it must have non-negative NumRetries, PerTryTimeoutMsec, and TimeoutMsec.
type Route ¶
type Route struct {
RouteKey RouteKey `json:"route_key"` // overwritten for create
DomainKey DomainKey `json:"domain_key"`
ZoneKey ZoneKey `json:"zone_key"`
Path string `json:"path"`
Rules Rules `json:"rules"`
ResponseData ResponseData `json:"response_data"`
CohortSeed *CohortSeed `json:"cohort_seed"`
RetryPolicy *RetryPolicy `json:"retry_policy"`
OrgKey OrgKey `json:"-"`
Checksum
}
A Route defines a mapping from a request to a pool of Instances. The left side of the mapping is defined by a Zone, a Domain, a Path, and a vector of Rules.
If none of the Rules applies to a given request, the Default AllConstraints are used; these define a default weighted set of Constraints. The weights determine the likelihood that one Constraint will be used over another.
If one or more Rules applies, the order of the rules informs which is tried first. If a Rule fails to produce an Instance, the next applicable Rule is tried.
It is possible to set a cohort seed on a SharedRules, Route, or Rule object. Only one of these will apply to any given request. Route is a subset of SharedRules and not as specific as a Rule so a seed specified by the Route will override one inherited from a SharedRules but not one specified in a Rule (regardless of the Rule source).
See CohortSeed docs for additional details of what a cohort seed does.
func (Route) Equals ¶
Checks for exact equality between this route and another. Exactly equality means each field must be equal (== or Equal, as appropriate) to the corresponding field in the parameter.
func (Route) GetChecksum ¶
func (Route) GetZoneKey ¶
func (Route) IsValid ¶
func (r Route) IsValid() *ValidationError
Checks validity of a Route. For a route to be valid it must have a non-empty RouteKey (or be precreation), have a DomainKey, a ZoneKey, a Path, and valid Default + Rules.
type Rule ¶
type Rule struct {
RuleKey RuleKey `json:"rule_key"`
Methods []string `json:"methods"`
Matches Matches `json:"matches"`
Constraints AllConstraints `json:"constraints"`
CohortSeed *CohortSeed `json:"cohort_seed"`
}
A Rule defines a mapping from a list of Methods and Matches to an AllConstraints struct. A Rule applies to a request if one of the Methods and all of the Matches apply.
If a Rule applies, the constraints inferred from the Matches should be merged with each of the ClusterConstraints, which are then used to find a live Instance. The ClusterConstraints are randomly shuffled using their weights to affect the distribution. Each ClusterConstraint is examined to find a matching Instance, until one is found.
It is possible to set a cohort seed on a SharedRules, Route, or Rule object. Only one of these will apply to any given request. A rule is the most specific way we have to direct a request to some backend so any request that matches a rule will use a cohort seed if set. This is true regardless of the rule source (SharedRules or Route).
See CohortSeed docs for additional details of what a cohort seed does.
func (Rule) Equals ¶
Checks for equality between two Rules. Rules are equal if the rule key, methods, constraints, and matches are all equal.
func (Rule) IsValid ¶
func (r Rule) IsValid() *ValidationError
Checks this rule for validity. A rule is considered valid if it has a RuleKey, at least one valid HTTP method (GET, PUT, POST, DELETE), the defined matches are valid, and the Constraints are valid.
type Rules ¶
type Rules []Rule
func (Rules) Equals ¶
Checks for equality with another Rule slice. Slices will be equal if each element i is Equal to ith element of the other slice and the slices are of the same length.
func (Rules) IsValid ¶
func (r Rules) IsValid() *ValidationError
Check for validity of a slice of Rule objects. A valid rule is one that is composed only of valid Rule structs.
type SSLConfig ¶
type SSLConfig struct {
CipherFilter string `json:"cipher_filter"`
Protocols []SSLProtocol `json:"protocols"`
CertKeyPairs []CertKeyPathPair `json:"cert_key_pairs"`
}
SSLConfig handles configuring support for SSL termination on a domain.
CertKeyPairs is represented as an array but we currently support only one certificate being specified.
At present I'm unsure how much flexibility will be needed so I'm supporting a basic set of knobs. Not yet exposed are things like DH params, EC selection, etc.)
func (SSLConfig) IsValid ¶
func (s SSLConfig) IsValid() *ValidationError
type SSLProtocol ¶
type SSLProtocol string
SSLProtocol is a name of a SSL protocol that may be used by a domain.
const ( SSL2 SSLProtocol = "SSLv2" SSL3 SSLProtocol = "SSLv3" TLS1 SSLProtocol = "TLSv1" TLS1_1 SSLProtocol = "TLSv1.1" TLS1_2 SSLProtocol = "TLSv1.2" // DefaultCipherFilter chooses the default set of ciphers that may be used for // communicating with a domain. DefaultCipherFilter = "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH" )
type SameSiteType ¶
type SameSiteType string
SameSiteType allows specification for the 'SameSite' annotation on a cookie response. This allows some control over when the cookie is sent to a server see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie for details.
const ( // SameSiteUnset represents the default value and will not impact the cookie // annotation set. SameSiteUnset SameSiteType = "" // SameSiteStrict causes 'SameSite=Strict' to be passed back with a cookie. SameSiteStrict SameSiteType = "Strict" // SameSiteLax causes 'SameSite=Lax' to be passed back with a cookie. SameSiteLax SameSiteType = "Lax" )
type SharedRules ¶
type SharedRules struct {
}
SharedRules define mappings from a request to a pool of Instances, shared by a number of Routes. The left side of the mappings are defined by a vector of Rules.
If none of the Rules applies to a given request, the Default AllConstraints are used; these define a default weighted set of Constraints. The weights determine the likelihood that one Constraint will be used over another.
If one or more Rules applies, the order of the rules informs which is tried first. If a Rule fails to produce an Instance, the next applicable Rule is tried.
It is possible to set a cohort seed on a SharedRules, Route, or Rule object. Only one of these will apply to any given request. SharedRules is the most generic of these objects and a seed set on either a Route or Rule will take precedence.
See CohortSeed docs for additional details of what a cohort seed does.
func (SharedRules) Equals ¶
func (r SharedRules) Equals(o SharedRules) bool
Checks for exact equality between this SharedRules and another. Exact equality means each field must be equal (== or Equal, as appropriate) to the corresponding field in the parameter.
func (SharedRules) GetChecksum ¶
func (o SharedRules) GetChecksum() Checksum
func (SharedRules) GetOrgKey ¶
func (o SharedRules) GetOrgKey() OrgKey
func (SharedRules) GetZoneKey ¶
func (o SharedRules) GetZoneKey() ZoneKey
func (SharedRules) IsNil ¶
func (r SharedRules) IsNil() bool
func (SharedRules) IsValid ¶
func (r SharedRules) IsValid() *ValidationError
Checks validity of a SharedRules. For a route to be valid it must have a non-empty SharedRulesKey (or be precreation), have a ZoneKey, a Path, and valid Default + Rules.
func (SharedRules) Key ¶
func (o SharedRules) Key() string
type SharedRulesKey ¶
type SharedRulesKey string
type SharedRulesSlice ¶
type SharedRulesSlice []SharedRules
type TCPHealthCheck ¶
type TCPHealthCheck struct {
// Send is a base64 encoded string representing an array of bytes to be
// sent in health check requests. Leaving this field empty implies a
// connect-only health check.
Send string `json:"send"`
// Receive is an array of base64 encoded strings, each representing
// array of bytes that is expected in health check responses. When
// checking the response, "fuzzy" matching is performed such that each
// binary block must be found, and in the order specified, but not
// necessarily contiguously.
Receive []string `json:"receive,omitempty"`
}
TCPHealthCheck configures the tcp health checker for each instance in a cluster.
func (*TCPHealthCheck) Equals ¶
func (thc *TCPHealthCheck) Equals(othc *TCPHealthCheck) bool
Equals checks for equality between two TCPHealthCheck pointers
type TracingConfig ¶
type TracingConfig struct {
// Ingress, when true, specifies that this listener is handling requests from a downstream.
// When false it indicates that it is handling requests bound to an upstream.
Ingress bool `json:"ingress"`
// Each listed header will be added to generated spans as an annotation
RequestHeadersForTags []string `json:"request_headers_for_tags"`
}
TracingConfig describes how tracing operations should be applied to the given Listener.
func (TracingConfig) Equals ¶
func (tc TracingConfig) Equals(o TracingConfig) bool
Equals compares two TraceConfig objects returning true if they are the same. RequestHeadersForTags is compared without regard for ordering of its content.
func (TracingConfig) IsValid ¶
func (tc TracingConfig) IsValid() *ValidationError
type User ¶
type User struct {
UserKey UserKey `json:"user_key"`
LoginEmail string `json:"login_email"`
Properties Metadata `json:"properties"`
APIAuthKey APIAuthKey `json:"api_auth_key,omitempty"`
OrgKey OrgKey `json:"org_key"`
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Checksum
}
A User is an actor of an Org. An API key is set if they're allowed to make API calls.
func (User) GetChecksum ¶
func (User) IsValid ¶
func (u User) IsValid() *ValidationError
type ValidationError ¶
type ValidationError struct {
Errors []ErrorCase `json:"errors"`
}
ValidationError contains any errors that were found while trying to validate an API object.
func ConstraintMetadataValid ¶
func ConstraintMetadataValid(m Metadata) *ValidationError
ConstraintMetadataValid ensures that the metadata has no duplicate keys or or empty keys or values.
func ConstraintPropertiesValid ¶
func ConstraintPropertiesValid(m Metadata) *ValidationError
ConstraintPropertiesValid ensures that the metadata has no duplicate or empty keys.
func InstanceMetadataIsValid ¶
func InstanceMetadataIsValid(md Metadata) *ValidationError
InstanceMetadataIsValid produces an error if any key fails to match AllowedIndexPattern
func MetadataValid ¶
func MetadataValid( container string, md Metadata, checks ...MetadataCheck, ) *ValidationError
MetadataValid provides a way to check for validity of all Metadatum contained within a Metadata, for various definitions of validity. It returns an aggregated list of errors from all checks, or nil if none were found.
func SharedRulesPropertiesValid ¶
func SharedRulesPropertiesValid(m Metadata) *ValidationError
SharedRulesPropertiesValid ensures that the metadata has no duplicate or empty keys.
func UserPropertiesValid ¶
func UserPropertiesValid(props Metadata) *ValidationError
func (*ValidationError) AddNew ¶
func (ve *ValidationError) AddNew(c ErrorCase)
AddNew appends a new ErrorCase to the set of errors seen by this ValidationError
func (*ValidationError) Error ¶
func (ve *ValidationError) Error() string
func (*ValidationError) Merge ¶
func (ve *ValidationError) Merge(o *ValidationError)
Merge adds the errors collected in o to the errors in this ValidationError.
func (*ValidationError) MergePrefixed ¶
func (ve *ValidationError) MergePrefixed(children *ValidationError, under string)
MergePrefixed takes the Errors found in in children and appends them to this ValidationError. In the process it attaches the under prefix to the Attribute of the error case. The original children error is not modified.
func (*ValidationError) OrNil ¶
func (ve *ValidationError) OrNil() *ValidationError
OrNil will return a pointer to the ValidationError if any errors have been collected. If no errors have been collected it will return nil.
type ValidationErrorsByAttribute ¶
type ValidationErrorsByAttribute struct {
// contains filtered or unexported fields
}
ValidationErrorsByAttribute implements sort.Interface
func (ValidationErrorsByAttribute) Len ¶
func (eca ValidationErrorsByAttribute) Len() int
func (ValidationErrorsByAttribute) Less ¶
func (eca ValidationErrorsByAttribute) Less(i, j int) bool
func (ValidationErrorsByAttribute) Swap ¶
func (eca ValidationErrorsByAttribute) Swap(i, j int)
type Zone ¶
type Zone struct {
ZoneKey ZoneKey `json:"zone_key"`
Name string `json:"name"`
OrgKey OrgKey `json:"-"`
Checksum
}
A Zone is a logical grouping that various other objects can be associated with. A single zone will often map to some geographic region.
func (Zone) GetChecksum ¶
func (Zone) GetZoneKey ¶
func (Zone) IsValid ¶
func (z Zone) IsValid() *ValidationError
Source Files
¶
- access_token.go
- api.go
- change_description.go
- checksum.go
- circuit_breakers.go
- cluster.go
- cluster_constraint.go
- cohort_seed.go
- comparison.go
- domain.go
- domain_ssl.go
- health_check.go
- instance.go
- listener.go
- match.go
- metadata.go
- org.go
- outlier_detection.go
- proxy.go
- redirect.go
- response_data.go
- retry_policy.go
- route.go
- rule.go
- shared_rules.go
- tracing_config.go
- user.go
- walk_constraints.go
- zone.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package changetype defines the pseudo-enum ChangeType, which describes the type of changes that can be made to data within a struct.
|
Package changetype defines the pseudo-enum ChangeType, which describes the type of changes that can be made to data within a struct. |
|
Package client implements the Turbine service interface by constructing an HTTP client to a specified backend api server.
|
Package client implements the Turbine service interface by constructing an HTTP client to a specified backend api server. |
|
Package fixture provides a set of fixtures for use in testing that requires a fairly sane universe of api objects.
|
Package fixture provides a set of fixtures for use in testing that requires a fairly sane universe of api objects. |
|
The http package provides common HTTP client building blocks.
|
The http package provides common HTTP client building blocks. |
|
envelope
Package envelope contains the Response envelope used by the Turbine Labs public API to encapsulate server behavior.
|
Package envelope contains the Response envelope used by the Turbine Labs public API to encapsulate server behavior. |
|
error
Package error contains an error definition intended to be serialized and sent over the wire between the api-server and clients.
|
Package error contains an error definition intended to be serialized and sent over the wire between the api-server and clients. |
|
header
Package header defines constants for HTTP headers used by the Turbine Labs API
|
Package header defines constants for HTTP headers used by the Turbine Labs API |
|
Package objecttype defines the pseudo-enum ObjectType, which can be passed along with an untyped object to recover the type without reflection.
|
Package objecttype defines the pseudo-enum ObjectType, which can be passed along with an untyped object to recover the type without reflection. |
|
Package queryargs is a collection of all query arguments that might be passed to the Turbine Labs API.
|
Package queryargs is a collection of all query arguments that might be passed to the Turbine Labs API. |
|
Package service defines interfaces representing the Turbine Labs public API
|
Package service defines interfaces representing the Turbine Labs public API |
|
changelog
Package changelog includes the filter definition necessary to make adhoc queries against the object audit history that we track.
|
Package changelog includes the filter definition necessary to make adhoc queries against the object audit history that we track. |
|
stats/v1/querytype
Package querytype defines the QueryType enumeration.
|
Package querytype defines the QueryType enumeration. |
|
stats/v1/timegranularity
Package timegranularity defines the TimeGranularity enumeration.
|
Package timegranularity defines the TimeGranularity enumeration. |
|
stats/v2
Package v2 defines the interfaces representing the portion of the Turbine Labs public API prefixed by /v2.0/stats.
|
Package v2 defines the interfaces representing the portion of the Turbine Labs public API prefixed by /v2.0/stats. |
|
stats/v2/querytype
Package querytype defines the QueryType enumeration.
|
Package querytype defines the QueryType enumeration. |
|
stats/v2/timegranularity
Package timegranularity defines the TimeGranularity enumeration.
|
Package timegranularity defines the TimeGranularity enumeration. |