nativepubsubio

package
v2.56.0-RC2 Latest Latest
Warning

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

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

Documentation

Overview

Package nativepubsubio contains a Golang implementation of streaming reads and writes to PubSub. This is not as fully featured as the cross-language pubsubio package present in the Beam Go repository and should not be used in place of it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(ctx context.Context, s beam.Scope, project, topic, subscription string) beam.PCollection

Read reads messages from a PubSub topic in a streaming context, outputting received messages as a PCollection of byte slices. If the provided subscription name exists for the given topic, the DoFn will read from that subscription; otherwise, a new subscription with the given subscription name will be created and read from.

This is an example and subject to change, including its behavior and function signature. Please use the cross-language implementation Read() instead.

func Write

func Write(ctx context.Context, s beam.Scope, col beam.PCollection, project, topic string)

Write publishes elements from a PCollection of byte slices to a PubSub topic. If the topic does not exist at pipeline construction time, the function will panic.

This is an example and subject to change, including its behavior and function signature. Please use the cross-language implementation Write() instead.

Types

type SubscriptionRTracker

type SubscriptionRTracker struct {
	Subscription string
	Done         bool
}

The SubscriptionRTracker maintains a single entry string to keep up with the PubSub subscription being used in the NativeRead SDF.

func NewSubscriptionRTracker

func NewSubscriptionRTracker(entry string) *SubscriptionRTracker

NewSubscriptionRTracker returns an RTracker wrapping the provided subscription and a "Done" boolean.

func (*SubscriptionRTracker) GetError

func (s *SubscriptionRTracker) GetError() error

GetError is a no-op.

func (*SubscriptionRTracker) GetProgress

func (s *SubscriptionRTracker) GetProgress() (done float64, remaining float64)

GetProgress returns complete just so the runner doesn't try to do much in the way of splitting.

func (*SubscriptionRTracker) GetRestriction

func (s *SubscriptionRTracker) GetRestriction() any

GetRestriction returns the name of the subscription.

func (*SubscriptionRTracker) IsBounded

func (s *SubscriptionRTracker) IsBounded() bool

IsBounded always returns false, as the StaticRTracker represents an unbounded number of reads from PubSub.

func (*SubscriptionRTracker) IsDone

func (s *SubscriptionRTracker) IsDone() bool

IsDone returns whether or not the StaticRTracker is complete (e.g. has stopped processing.)

func (*SubscriptionRTracker) TryClaim

func (s *SubscriptionRTracker) TryClaim(pos any) bool

TryClaim returns true iff the given position is a string and matches the underlying subscription ID.

func (*SubscriptionRTracker) TrySplit

func (s *SubscriptionRTracker) TrySplit(frac float64) (primary, residual any, err error)

TrySplit is a no-op for the StaticRTracker in the normal case and moves the subscription to the residual in the checkpointing case, marking itself as done to keep the logical checks around SDF data loss happy.

Jump to

Keyboard shortcuts

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