mongo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMongoInitialization = errors.New("failed to start mongo writer")
)

Functions

func NewMongoDBWriter

func NewMongoDBWriter[T entities.PipelineEvent](ctx context.Context, config *Config) (sinks.Sink[T], error)

NewMongoDBWriter will construct a new MongoDB writer and validate the connection parameters via a ping request.

Types

type Config

type Config struct {
	URL        config.SecretSource `json:"url"`
	Collection string              `json:"collection"`
	InsertOnly bool                `json:"insertOnly"`

	Database string `json:"-"`
}

Config contains the configuration needed to connect to a remote MongoDB instance

func (*Config) Validate

func (c *Config) Validate() error

type Writer

type Writer[T entities.PipelineEvent] struct {
	// contains filtered or unexported fields
}

Writer is a concrete implementation of a Writer that will save and delete data from a MongoDB instance.

func (*Writer[T]) Delete

func (w *Writer[T]) Delete(ctx context.Context, data T) error

Delete implement the Writer interface

func (*Writer[T]) Insert

func (w *Writer[T]) Insert(ctx context.Context, data T) error

func (*Writer[T]) Upsert

func (w *Writer[T]) Upsert(ctx context.Context, data T) error

Write implement the Writer interface. The MongoDBWriter will do an upsert of data using its id as primary key

func (*Writer[T]) WriteData

func (w *Writer[T]) WriteData(ctx context.Context, data T) error

Jump to

Keyboard shortcuts

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