periodic

package
v2.55.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package periodic contains transformations for generating periodic sequences.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Impulse

func Impulse(s beam.Scope, start, end time.Time, interval time.Duration, applyWindow bool) beam.PCollection

Impulse is a PTransform which generates a sequence of timestamped elements at fixed runtime intervals. If applyWindow is specified, each element will be assigned to its own fixed window of interval size.

The transform behaves the same as Sequence transform, but can be used as the first transform in a pipeline.

The following applies to the arguments.

  • if start is a zero value time.Time, start is set to the current time
  • if start is after end, start is set to end
  • start and end are normalized with mtime.Normalize
  • if interval <= 0 or interval > end.Sub(start), interval is set to end.Sub(start)

The PCollection<[]byte> generated by Impulse is unbounded.

func Sequence

func Sequence(s beam.Scope, col beam.PCollection) beam.PCollection

Sequence is a PTransform which generates a sequence of timestamped elements at fixed runtime intervals.

The transform assigns each element a timestamp and will only output an element once the worker clock reach the output timestamp. Sequence is not able to guarantee that elements are output at the their exact timestamp, but it guarantees that elements will not be output prior to runtime timestamp.

The transform will not output elements prior to the start time.

Sequence receives SequenceDefinition elements and for each input element received, it will start generating output elements in the following pattern:

  • if element timestamp is less than current runtime then output element.
  • if element timestamp is greater than current runtime, wait until next element timestamp.

The PCollection<int64> generated by Sequence is unbounded.

Types

type SequenceDefinition

type SequenceDefinition struct {
	Interval time.Duration

	// Start is the number of milliseconds since the Unix epoch.
	Start int64

	// End is the number of milliseconds since the Unix epoch.
	End int64
}

SequenceDefinition holds the configuration for generating a sequence of timestamped elements at an interval.

func NewSequenceDefinition

func NewSequenceDefinition(start, end time.Time, interval time.Duration) SequenceDefinition

NewSequenceDefinition creates a new SequenceDefinition from a start and end time.Time along with its interval time.Duration.

Jump to

Keyboard shortcuts

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