source

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package source implements the source logic of the MongoDB connector.

Index

Constants

View Source
const (
	// ConfigKeyBatchSize is a config name for a batch size.
	ConfigKeyBatchSize = "batchSize"
	// ConfigKeySnapshot is a config name for a snapshot field.
	ConfigKeySnapshot = "snapshot"
	// ConfigKeyOrderingField is a config name for a orderingField field.
	ConfigKeyOrderingField = "orderingField"
)

Variables

This section is empty.

Functions

func NewSource

func NewSource() sdk.Source

NewSource creates a new instance of the Source.

Types

type Config

type Config struct {
	config.Config

	// BatchSize is the size of a document batch.
	BatchSize int `key:"batchSize" validate:"gte=1,lte=100000"`
	// Snapshot determines whether or not the connector will take a snapshot
	// of the entire collection before starting CDC mode.
	Snapshot bool `key:"snapshot"`
	// OrderingField is the name of a field that is used for ordering
	// collection documents when capturing a snapshot.
	OrderingField string `key:"orderingField"`
}

Config contains source-specific configurable values.

func ParseConfig

func ParseConfig(raw map[string]string) (Config, error)

ParseConfig maps the incoming map to the Config and validates it.

type Iterator

type Iterator interface {
	HasNext(context.Context) (bool, error)
	Next(context.Context) (sdk.Record, error)
	Stop(context.Context) error
}

Iterator defines an Iterator interface needed for the Source.

type Source

type Source struct {
	sdk.UnimplementedSource
	// contains filtered or unexported fields
}

Source implements the source logic of the MongoDB connector.

func (*Source) Ack

func (s *Source) Ack(ctx context.Context, position sdk.Position) error

Ack just logs a provided position.

func (*Source) Configure

func (s *Source) Configure(_ context.Context, raw map[string]string) error

Configure provides the connector with the configuration that is validated and stored. In case the configuration is not valid it returns an error.

func (*Source) Open

func (s *Source) Open(ctx context.Context, sdkPosition sdk.Position) error

Open opens needed connections and prepares to start producing records.

func (*Source) Parameters

func (s *Source) Parameters() map[string]sdk.Parameter

Parameters is a map of named Parameters that describe how to configure the Source.

func (*Source) Read

func (s *Source) Read(ctx context.Context) (sdk.Record, error)

Read returns a new sdk.Record. It can return the error sdk.ErrBackoffRetry to signal to the SDK it should call Read again with a backoff retry.

func (*Source) Teardown

func (s *Source) Teardown(ctx context.Context) error

Teardown closes connections, stops iterators and prepares for a graceful shutdown.

Directories

Path Synopsis
Package iterator implements the CDC and Snapshot iterators for MongoDB.
Package iterator implements the CDC and Snapshot iterators for MongoDB.
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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