common

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package common contains various helpers for adapters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

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

Backoff provides a simple exponential backoff mechanism.

func NewBackoff

func NewBackoff(args ...time.Duration) *Backoff

NewBackoff accepts optional values for minimum and maximum wait period and returns a new instance of Backoff.

func (*Backoff) Duration

func (b *Backoff) Duration() time.Duration

Duration returns the exponential backoff duration calculated for the current step.

func (*Backoff) Reset

func (b *Backoff) Reset()

Reset sets step counter to zero.

func (*Backoff) Run

func (b *Backoff) Run(stopCh <-chan struct{}, fn RunFunc) error

Run is a blocking function that executes RunFunc until stopCh receives a value or fn returns an error.

type RunFunc

type RunFunc func(context.Context) (bool, error)

RunFunc is a user function that polls data from a source and sends it as a CloudEvent to a sink. RunFunc must return (bool, error) values where bool is true if the poll backoff duration must be reset, and error is the result of the function's execution.

Directories

Path Synopsis
Package controller contains helpers shared between controllers embedded in source adapters.
Package controller contains helpers shared between controllers embedded in source adapters.
Package env allows propagating runtime configurations via the environment.
Package env allows propagating runtime configurations via the environment.
Package health contains helpers to enable HTTP health checking.
Package health contains helpers to enable HTTP health checking.

Jump to

Keyboard shortcuts

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