From 1b05c690a21ac5ed8daf683dbce6a1075bb4f147 Mon Sep 17 00:00:00 2001 From: Hannes Gustafsson Date: Wed, 22 Mar 2023 01:19:35 +0000 Subject: [PATCH] periodic: document start and end and add constructor --- .../pkg/beam/transforms/periodic/periodic.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sdks/go/pkg/beam/transforms/periodic/periodic.go b/sdks/go/pkg/beam/transforms/periodic/periodic.go index 3dbe6a640757..f8752dc2c93b 100644 --- a/sdks/go/pkg/beam/transforms/periodic/periodic.go +++ b/sdks/go/pkg/beam/transforms/periodic/periodic.go @@ -43,8 +43,22 @@ func init() { // timestamped elements at an interval. type SequenceDefinition struct { Interval time.Duration - Start int64 - End int64 + + // Start is the number of milliseconds since the Unix epoch. + Start int64 + + // End is the number of milliseconds since the Unix epoch. + End int64 +} + +// NewSequenceDefinition creates a new [SequenceDefinition] from a start and +// end [time.Time] along with its interval [time.Duration]. +func NewSequenceDefinition(start, end time.Time, interval time.Duration) SequenceDefinition { + return SequenceDefinition{ + Start: start.UnixMilli(), + End: end.UnixMilli(), + Interval: interval, + } } type sequenceGenDoFn struct{}