mongo

package
v0.0.0-...-3119971 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeEventHandler

type ChangeEventHandler func(ctx context.Context, subj, msgId string, data []byte) error

type Client

type Client interface {
	server.NamedMonitor
	io.Closer

	CreateCollection(ctx context.Context, opts *CreateCollectionOptions) error
	WatchCollection(ctx context.Context, opts *WatchCollectionOptions) error
}

type ClientOption

type ClientOption func(*DefaultClient)

func WithEventListeners

func WithEventListeners(listeners ...EventListener) ClientOption

func WithLogger

func WithLogger(logger *slog.Logger) ClientOption

func WithMongoUri

func WithMongoUri(uri string) ClientOption

type CreateCollectionOptions

type CreateCollectionOptions struct {
	DbName                       string
	CollName                     string
	Capped                       bool
	SizeInBytes                  int64
	ChangeStreamPreAndPostImages bool
}

type DefaultClient

type DefaultClient struct {
	// contains filtered or unexported fields
}

func NewDefaultClient

func NewDefaultClient(opts ...ClientOption) (*DefaultClient, error)

func (*DefaultClient) Close

func (c *DefaultClient) Close() error

func (*DefaultClient) CreateCollection

func (c *DefaultClient) CreateCollection(ctx context.Context, opts *CreateCollectionOptions) error

func (*DefaultClient) Monitor

func (c *DefaultClient) Monitor(ctx context.Context) error

func (*DefaultClient) Name

func (c *DefaultClient) Name() string

func (*DefaultClient) WatchCollection

func (c *DefaultClient) WatchCollection(ctx context.Context, opts *WatchCollectionOptions) error

type EventListener

type EventListener func(*DefaultClient)

func OnChangeEventProcessingEvent

func OnChangeEventProcessingEvent(onChangeEventProcessing func(collName, subj string, duration time.Duration)) EventListener

func OnCmdFailedEvent

func OnCmdFailedEvent(onCmdFailedEvent func(dbName, cmdName string, duration time.Duration)) EventListener

func OnCmdStartedEvent

func OnCmdStartedEvent(onCmdStartedEvent func(dbName, cmdName string)) EventListener

func OnCmdSucceededEvent

func OnCmdSucceededEvent(onCmdSucceededEvent func(dbName, cmdName string, duration time.Duration)) EventListener

type WatchCollectionOptions

type WatchCollectionOptions struct {
	WatchedDbName          string
	WatchedCollName        string
	ResumeTokensDbName     string
	ResumeTokensCollName   string
	ResumeTokensCollCapped bool
	StreamName             string
	ChangeEventHandler     ChangeEventHandler
}

Jump to

Keyboard shortcuts

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