Documentation ¶
Index ¶
- Variables
- type CollectionOption
- func WithChangeStreamPreAndPostImages() CollectionOptiondeprecated
- func WithStreamName(streamName string) CollectionOption
- func WithTokensCollCapped(collSizeInBytes int64) CollectionOption
- func WithTokensCollName(tokensCollName string) CollectionOption
- func WithTokensDbName(tokensDbName string) CollectionOption
- type Connector
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( ErrDbNameMissing = errors.New("invalid option: `dbName` is missing") ErrCollNameMissing = errors.New("invalid option: `collName` is missing") ErrInvalidCollSizeInBytes = errors.New("invalid option: `collSizeInBytes` must be greater than 0") ErrInvalidDbAndCollNames = errors.New("invalid option: `dbName` and `tokensDbName` cannot be the same if `collName` and `tokensCollName` are the same") )
Functions ¶
This section is empty.
Types ¶
type CollectionOption ¶
type CollectionOption func(*collection) error
CollectionOption is used to configure a MongoDB collection to be watched.
func WithChangeStreamPreAndPostImages
deprecated
func WithChangeStreamPreAndPostImages() CollectionOption
WithChangeStreamPreAndPostImages enables MongoDB's changeStreamPreAndPostImages configuration.
Deprecated: will be removed in future versions. Set this configuration directly on MongoDB instead.
func WithStreamName ¶
func WithStreamName(streamName string) CollectionOption
WithStreamName sets the NATS stream name, where the MongoDB change events will be published for the collection to be watched.
func WithTokensCollCapped ¶
func WithTokensCollCapped(collSizeInBytes int64) CollectionOption
WithTokensCollCapped sets the MongoDB collection that will store the resume tokens for the collection to be watched as capped, with the given size.
func WithTokensCollName ¶
func WithTokensCollName(tokensCollName string) CollectionOption
WithTokensCollName sets the name of the MongoDB collection that will store the resume tokens for the collection to be watched.
func WithTokensDbName ¶
func WithTokensDbName(tokensDbName string) CollectionOption
WithTokensDbName sets the name of the MongoDB database that will store the resume tokens collection for the collection to be watched.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
The Connector type represents a connector between MongoDB and NATS.
func (*Connector) Run ¶
Run runs the Connector. It performs the following operations:
For each configured collection to be watched: - It creates the given collection on MongoDB, if it does not already exist - It creates the resume tokens collection for the given collection on MongoDB, if it does not already exist - It creates the given stream on NATS, if it does not already exist - Spins up a goroutine to watch the given collection It runs an HTTP server in its own goroutine. It runs another goroutine that will perform graceful shutdown once the Connector's context is cancelled.
type Option ¶
Option is used to configure the Connector.
func WithCollection ¶
func WithCollection(dbName, collName string, opts ...CollectionOption) Option
WithCollection configures a collection to be watched by the Connector, with the given options.
func WithContext ¶
WithContext sets the Connector's context.
func WithLogLevel ¶
WithLogLevel sets the Connector's log level.
func WithMongoUri ¶
WithMongoUri sets the Connector's MongoDB URI.
func WithNatsUrl ¶
WithNatsUrl sets the Connector's NATS URL.
func WithServerAddr ¶
WithServerAddr sets the Connector's HTTP server address.