flush

package
v0.0.0-...-ba0629f Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtTheEnd

type AtTheEnd struct {
}

AtTheEnd strategy is the simply flushing the data at the end of the execution of the function.

func (*AtTheEnd) Failure

func (s *AtTheEnd) Failure(t time.Time)

Failure modify state to keep track of failure

func (*AtTheEnd) ShouldFlush

func (s *AtTheEnd) ShouldFlush(moment Moment, t time.Time) bool

ShouldFlush returns true if this strategy want to flush at the given moment.

func (*AtTheEnd) String

func (s *AtTheEnd) String() string

func (*AtTheEnd) Success

func (s *AtTheEnd) Success()

Success reset the state when a flush is successful

type Moment

type Moment string

Moment represents at which moment we're asking the flush strategy if we should flush or not. Note that there is no entry for the shutdown of the environment because we always flush in this situation.

const (
	// Starting is used to represent the moment the function is starting because
	// it has been invoked.
	Starting Moment = "starting"
	// Stopping is used to represent the moment right after the function has finished
	// its execution.
	Stopping Moment = "stopping"
)

type Periodically

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

Periodically is the strategy flushing at least every N [nano/micro/milli]seconds at the start of the function.

func NewPeriodically

func NewPeriodically(interval time.Duration) *Periodically

NewPeriodically returns an initialized Periodically flush strategy.

func (*Periodically) Failure

func (s *Periodically) Failure(t time.Time)

Failure modify state to keep track of failure

func (*Periodically) ShouldFlush

func (s *Periodically) ShouldFlush(moment Moment, t time.Time) bool

ShouldFlush returns true if this strategy want to flush at the given moment.

func (*Periodically) String

func (s *Periodically) String() string

func (*Periodically) Success

func (s *Periodically) Success()

Success reset the state when a flush is successful

type Strategy

type Strategy interface {
	String() string
	ShouldFlush(moment Moment, t time.Time) bool
	Failure(t time.Time)
	Success()
}

Strategy is deciding whether the data should be flushed or not at the given moment.

func StrategyFromString

func StrategyFromString(str string) (Strategy, error)

StrategyFromString returns a flush strategy from the given string. Possible values:

  • end
  • periodically[,milliseconds]

Jump to

Keyboard shortcuts

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