Documentation ¶
Overview ¶
Monresql: MongoDB to PostgreSQL Data Pipeline Tool
Overview Monresql is a specialized library designed to facilitate efficient data replication, transfer, and synchronization from MongoDB to PostgreSQL databases. Inspired by similar tools like Moresql, Monresql focuses on unidirectional data movement, ensuring seamless integration and synchronization between MongoDB documents and PostgreSQL tables.
Key Features Data Replication: Efficiently replicate data from MongoDB collections to corresponding PostgreSQL tables.
Incremental Updates: Support for incremental updates to keep PostgreSQL data up-to-date without full data reloads.
Performance Optimization: Optimizes data transfer processes for minimal latency and optimal resource utilization.
API Reference LoadFieldsMap() Loads a mapping file to define how MongoDB documents should be mapped to PostgreSQL tables.
ValidateOrCreatePostgresTable() Validates the existence of a PostgreSQL table to ensure it's ready for data replication.
Replicate() Initiates the data replication process from MongoDB to PostgreSQL based on the loaded mapping.
Sync() Starts the synchronization process, ensuring that changes in MongoDB are reflected in PostgreSQL in real-time and also save the marker to sync from the last stopped mark if the service stopped
NewSyncOptions() NewSyncOptions will return the pointer of the syncoptions struct with default values of
&syncOptions{checkpoint: true, checkPointPeriod: time.Minute * 1, lastEpoch: 0, reportPeriod: time.Minute * 1} then you can edit and change the values by set methods
Index ¶
- Constants
- func LoadFieldsMap(jsonString string) (fieldsMap, error)
- func NewSyncOptions() *syncOptions
- func Replicate(config fieldsMap, pg *sqlx.DB, mongo *mongo.Client, replicaName string) string
- func Sync(fieldMap fieldsMap, pg *sqlx.DB, client *mongo.Client, syncName string, ...) syncStop
- func ValidateOrCreatePostgresTable(fieldMap fieldsMap, pg *sqlx.DB) (string, error)
Constants ¶
const COMPLEX string = `` /* 127-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func LoadFieldsMap ¶
LoadFieldsMap receive the file as json string and return FieldsMap please refer the moresql config file structure
func NewSyncOptions ¶
func NewSyncOptions() *syncOptions
NewSyncOptions method return the pointer of syncOptions with default values of {checkpoint: true, checkPointPeriod: time.Minute * 1, lastEpoch: 0, reportPeriod: time.Minute * 1} NewSyncOptions give you fucntion to set few options SetCheckPoint() if the checkpoint is true it will save the marker in monresql_metada as time epoch SetCheckPointPeriod() the marker saving period interval SetLastEpoch() if you want run the sync from the known epoch time you can use this method and restart the service SetReportPeriod() it log out the read and write counts in the console
func Replicate ¶
if the table is validated you can start the replication using this method please find sample code in the example
func Sync ¶
func Sync(fieldMap fieldsMap, pg *sqlx.DB, client *mongo.Client, syncName string, syncOption *syncOptions) syncStop
if the table is validated you can start the sync using this method and it return a stop function, by using that method you can stop sync anytime please find sample code in the example
func ValidateOrCreatePostgresTable ¶
ValidateOrCreatePostgresTable validates the postgres table fileds against the jsonfile, if table not exists and it is a valid file it creates postgres table, but you must create the Database yourself, always use the small letters in the postgres fields name please refer the complex structure
Types ¶
This section is empty.