Documentation ¶
Index ¶
- Constants
- func AddOrUpdateAddressableHandler(addressable duckv1.Addressable)
- func ConfigureConnectionArgs(ca *ConnectionArgs)
- func CreateHandler(handler http.Handler) http.Handler
- func DeleteAddressableHandler(addressable duckv1.Addressable)
- func SelectiveRetry(_ context.Context, response *http.Response, err error) (bool, error)
- func SetClientCleanupInterval(cleanupInterval time.Duration, forceRestart bool)
- func WithShutdownTimeout(ctx context.Context, timeout time.Duration) context.Context
- func WriteHTTPRequestWithAdditionalHeaders(ctx context.Context, message binding.Message, req *nethttp.Request, ...) error
- func WriteRequestWithAdditionalHeaders(ctx context.Context, message binding.Message, req *CloudEventRequest, ...) error
- type Backoff
- type CheckRetry
- type CloudEventRequest
- type ConnectionArgs
- type HTTPMessageReceiver
- type HTTPMessageReceiverOption
- func WithChecker(checker http.HandlerFunc) HTTPMessageReceiverOption
- func WithDrainQuietPeriod(duration time.Duration) HTTPMessageReceiverOption
- func WithReadTimeout(duration time.Duration) HTTPMessageReceiverOption
- func WithTLSConfig(cfg *tls.Config) HTTPMessageReceiverOption
- func WithWriteTimeout(duration time.Duration) HTTPMessageReceiverOption
- type HTTPMessageSender
- func (s *HTTPMessageSender) NewCloudEventRequest(ctx context.Context) (*nethttp.Request, error)
- func (s *HTTPMessageSender) NewCloudEventRequestWithTarget(ctx context.Context, target string) (*nethttp.Request, error)
- func (s *HTTPMessageSender) Send(req *nethttp.Request) (*nethttp.Response, error)
- func (s *HTTPMessageSender) SendWithRetries(req *nethttp.Request, config *RetryConfig) (*nethttp.Response, error)
- type RetryConfig
- type TypeExtractorTransformer
Constants ¶
const (
DefaultShutdownTimeout = time.Minute * 1
)
const RetryAfterHeader = "Retry-After"
Variables ¶
This section is empty.
Functions ¶
func AddOrUpdateAddressableHandler ¶ added in v0.38.0
func AddOrUpdateAddressableHandler(addressable duckv1.Addressable)
func ConfigureConnectionArgs ¶ added in v0.17.9
func ConfigureConnectionArgs(ca *ConnectionArgs)
ConfigureConnectionArgs configures the new connection args. Use sparingly, because it might lead to creating a lot of clients, none of them sharing their connection pool!
func DeleteAddressableHandler ¶ added in v0.38.0
func DeleteAddressableHandler(addressable duckv1.Addressable)
func SelectiveRetry ¶ added in v0.21.0
SelectiveRetry is an alternative function to determine whether to retry based on response
Note - Returning true indicates a retry should occur. Returning an error will result in that
error being returned instead of any errors from the Request.
A retry is triggered for: * nil responses * emitted errors * status codes that are 5XX, 404, 408, 409, 429 as well if the statuscode is -1.
func SetClientCleanupInterval ¶ added in v0.38.0
SetClientCleanupInterval sets the interval before the clients map is re-checked for expired entries. forceRestart will force the loop to restart with the new interval, cancelling the current iteration.
func WithShutdownTimeout ¶ added in v0.14.0
func WriteHTTPRequestWithAdditionalHeaders ¶ added in v0.19.0
func WriteRequestWithAdditionalHeaders ¶ added in v0.38.0
func WriteRequestWithAdditionalHeaders(ctx context.Context, message binding.Message, req *CloudEventRequest, additionalHeaders nethttp.Header, transformers ...binding.Transformer) error
Types ¶
type Backoff ¶ added in v0.17.0
Backoff specifies a policy for how long to wait between retries. It is called after a failing request to determine the amount of time that should pass before trying again.
type CheckRetry ¶ added in v0.17.0
CheckRetry specifies a policy for handling retries. It is called following each request with the response and error values returned by the http.Client. If CheckRetry returns false, the Client stops retrying and returns the response to the caller. If CheckRetry returns an error, that error value is returned in lieu of the error from the request. The Client will close any response body when retrying, but if the retry is aborted it is up to the CheckRetry callback to properly close any response body before returning.
type CloudEventRequest ¶ added in v0.38.0
type CloudEventRequest struct { *nethttp.Request Target duckv1.Addressable }
func NewCloudEventRequest ¶ added in v0.38.0
func NewCloudEventRequest(ctx context.Context, target duckv1.Addressable) (*CloudEventRequest, error)
func (*CloudEventRequest) Send ¶ added in v0.38.0
func (req *CloudEventRequest) Send() (*nethttp.Response, error)
func (*CloudEventRequest) SendWithRetries ¶ added in v0.38.0
func (req *CloudEventRequest) SendWithRetries(config *RetryConfig) (*nethttp.Response, error)
type ConnectionArgs ¶ added in v0.10.0
type ConnectionArgs struct { // MaxIdleConns refers to the max idle connections, as in net/http/transport. MaxIdleConns int // MaxIdleConnsPerHost refers to the max idle connections per host, as in net/http/transport. MaxIdleConnsPerHost int }
ConnectionArgs allow to configure connection parameters to the underlying HTTP Client transport.
type HTTPMessageReceiver ¶ added in v0.19.0
type HTTPMessageReceiver struct { // Used to signal when receiver is listening Ready chan interface{} // contains filtered or unexported fields }
func NewHTTPMessageReceiver ¶ added in v0.19.0
func NewHTTPMessageReceiver(port int, o ...HTTPMessageReceiverOption) *HTTPMessageReceiver
func (*HTTPMessageReceiver) GetAddr ¶ added in v0.38.0
func (recv *HTTPMessageReceiver) GetAddr() string
func (*HTTPMessageReceiver) StartListen ¶ added in v0.19.0
Blocking
type HTTPMessageReceiverOption ¶ added in v0.20.0
type HTTPMessageReceiverOption func(*HTTPMessageReceiver)
HTTPMessageReceiverOption enables further configuration of a HTTPMessageReceiver.
func WithChecker ¶ added in v0.21.0
func WithChecker(checker http.HandlerFunc) HTTPMessageReceiverOption
WithChecker takes a handler func which will run as an additional health check in Drainer. kncloudevents HTTPMessageReceiver uses Drainer to perform health check. By default, Drainer directly writes StatusOK to kubelet probe if the Pod is not draining. Users can configure customized liveness and readiness check logic by defining checker here.
func WithDrainQuietPeriod ¶ added in v0.22.0
func WithDrainQuietPeriod(duration time.Duration) HTTPMessageReceiverOption
WithDrainQuietPeriod configures the QuietPeriod for the Drainer.
func WithReadTimeout ¶ added in v0.34.0
func WithReadTimeout(duration time.Duration) HTTPMessageReceiverOption
WithReadTimeout sets the HTTP server's ReadTimeout. It covers the duration from reading the entire request (Headers + Body)
func WithTLSConfig ¶ added in v0.37.0
func WithTLSConfig(cfg *tls.Config) HTTPMessageReceiverOption
WithTLSConfig configures the TLS config for the receiver.
func WithWriteTimeout ¶ added in v0.34.0
func WithWriteTimeout(duration time.Duration) HTTPMessageReceiverOption
WithWriteTimeout sets the HTTP server's WriteTimeout. It covers the time between end of reading Request Header to end of writing response.
type HTTPMessageSender ¶ added in v0.19.0
HTTPMessageSender is a wrapper for an http client that can send cloudevents.Request with retries. Deprecated: Use kncloudevents.CloudEventsRequest instead.
func NewHTTPMessageSenderWithTarget ¶ added in v0.19.0
func NewHTTPMessageSenderWithTarget(target string) (*HTTPMessageSender, error)
func (*HTTPMessageSender) NewCloudEventRequest ¶ added in v0.19.0
func (*HTTPMessageSender) NewCloudEventRequestWithTarget ¶ added in v0.19.0
func (*HTTPMessageSender) SendWithRetries ¶ added in v0.19.0
func (s *HTTPMessageSender) SendWithRetries(req *nethttp.Request, config *RetryConfig) (*nethttp.Response, error)
type RetryConfig ¶ added in v0.17.0
type RetryConfig struct { // Maximum number of retries RetryMax int // These next two variables are just copied from the original DeliverySpec so // we can detect if anything has changed. We can not do that with the CheckRetry // Backoff (at least not easily). BackoffDelay *string BackoffPolicy *v1.BackoffPolicyType CheckRetry CheckRetry Backoff Backoff // RequestTimeout represents the timeout of the single request RequestTimeout time.Duration // RetryAfterMaxDuration represents an optional override for the maximum // value allowed for "Retry-After" headers in 429 / 503 responses. A nil // value indicates no maximum override. A value of "0" indicates "Retry-After" // headers are to be ignored. RetryAfterMaxDuration *time.Duration }
func NoRetries ¶ added in v0.17.0
func NoRetries() RetryConfig
func RetryConfigFromDeliverySpec ¶ added in v0.17.0
func RetryConfigFromDeliverySpec(spec v1.DeliverySpec) (RetryConfig, error)
type TypeExtractorTransformer ¶ added in v0.19.0
type TypeExtractorTransformer string
func (*TypeExtractorTransformer) Transform ¶ added in v0.19.0
func (a *TypeExtractorTransformer) Transform(reader binding.MessageMetadataReader, _ binding.MessageMetadataWriter) error