Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteBreaker(throttler *Throttler) func(obj interface{})
- func EndpointsAddressCount(subsets []corev1.EndpointSubset) int
- func ServicePort(protocol networking.ProtocolType) int32
- func UpdateEndpoints(throttler *Throttler) func(newObj interface{})
- type Reporter
- type RevisionID
- type StatsReporter
- type Throttler
- type ThrottlerParams
Constants ¶
const ( // Name is the name of the component. Name = "activator" // K8sServiceName is the name of the activator service K8sServiceName = "activator-service" // RevisionHeaderName is the header key for revision name RevisionHeaderName string = "knative-serving-revision" // RevisionHeaderNamespace is the header key for revision's namespace RevisionHeaderNamespace string = "knative-serving-namespace" // ServicePortHTTP1 is the port number for activating HTTP1 revisions ServicePortHTTP1 int32 = 80 // ServicePortH2C is the port number for activating H2C revisions ServicePortH2C int32 = 81 )
Variables ¶
var ErrActivatorOverload = errors.New("activator overload")
ErrActivatorOverload indicates that throttler has no free slots to buffer the request.
Functions ¶
func DeleteBreaker ¶
func DeleteBreaker(throttler *Throttler) func(obj interface{})
DeleteBreaker is a handler function to be used by the Endpoints informer. It removes the Breaker from the Throttler bookkeeping.
func EndpointsAddressCount ¶
func EndpointsAddressCount(subsets []corev1.EndpointSubset) int
EndpointsAddressCount returns the total number of addresses registered for the endpoint.
func ServicePort ¶
func ServicePort(protocol networking.ProtocolType) int32
ServicePort returns the activator service port for the given app level protocol. Default is `ServicePortHTTP1`.
func UpdateEndpoints ¶
func UpdateEndpoints(throttler *Throttler) func(newObj interface{})
UpdateEndpoints is a handler function to be used by the Endpoints informer. It updates the endpoints in the Throttler if the number of hosts changed and the revision already exists (we don't want to create/update throttlers for the endpoints that do not belong to any revision).
This function must not be called in parallel to not induce a wrong order of events.
Types ¶
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter holds cached metric objects to report autoscaler metrics
func NewStatsReporter ¶
NewStatsReporter creates a reporter that collects and reports activator metrics
type RevisionID ¶
RevisionID is the combination of namespace and service name
func (RevisionID) String ¶
func (rev RevisionID) String() string
type StatsReporter ¶
type StatsReporter interface { ReportRequestCount(ns, service, config, rev string, responseCode, numTries int, v int64) error ReportResponseTime(ns, service, config, rev string, responseCode int, d time.Duration) error }
StatsReporter defines the interface for sending activator metrics
type Throttler ¶
type Throttler struct {
// contains filtered or unexported fields
}
Throttler keeps the mapping of Revisions to Breakers and allows updating max concurrency dynamically of respective Breakers. Max concurrency is essentially the number of semaphore tokens the Breaker has in rotation. The manipulation of the parameter is done via `UpdateCapacity()` method. It enables the use case to start with max concurrency set to 0 (no requests are sent because no endpoints are available) and gradually increase its value depending on the external condition (e.g. new endpoints become available)
func NewThrottler ¶
func NewThrottler(params ThrottlerParams) *Throttler
NewThrottler creates a new Throttler.
func (*Throttler) Remove ¶
func (t *Throttler) Remove(rev RevisionID)
Remove deletes the breaker from the bookkeeping.
func (*Throttler) Try ¶
func (t *Throttler) Try(rev RevisionID, function func()) error
Try potentially registers a new breaker in our bookkeeping and executes the `function` on the Breaker. It returns an error if either breaker doesn't have enough capacity, or breaker's registration didn't succeed, e.g. getting endpoints or update capacity failed.
func (*Throttler) UpdateCapacity ¶
func (t *Throttler) UpdateCapacity(rev RevisionID, size int32) error
UpdateCapacity updates the max concurrency of the Breaker corresponding to a revision.
type ThrottlerParams ¶
type ThrottlerParams struct { BreakerParams queue.BreakerParams Logger *zap.SugaredLogger GetEndpoints func(RevisionID) (int32, error) GetRevision func(RevisionID) (*v1alpha1.Revision, error) }
ThrottlerParams defines the parameters of the Throttler.