WatcherFactory creates and returns a Watcher based on the database engine type.
(db database.Database)
| 56 | |
| 57 | // WatcherFactory creates and returns a Watcher based on the database engine type. |
| 58 | func WatcherFactory(db database.Database) (repo storage.Watcher) { |
| 59 | switch db.GetEngineType() { |
| 60 | case "postgres": |
| 61 | // If the database engine is Postgres, create a new Watcher using the Postgres implementation |
| 62 | return PQRepository.NewWatcher(db.(*PQDatabase.Postgres)) |
| 63 | case "memory": |
| 64 | // If the database engine is in-memory, create a new Watcher using the in-memory implementation |
| 65 | return MMRepository.NewWatcher(db.(*MMDatabase.Memory)) |
| 66 | default: |
| 67 | // For any other type, use the in-memory implementation as a default |
| 68 | return MMRepository.NewWatcher(db.(*MMDatabase.Memory)) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // SchemaWriterFactory creates and returns a SchemaWriter based on the database engine type. |
| 73 | func SchemaWriterFactory(db database.Database) (repo storage.SchemaWriter) { |