BundleReaderFactory is a factory function that creates and returns a BundleReader based on the type of database engine being used.
(db database.Database)
| 117 | // BundleReaderFactory is a factory function that creates and returns a BundleReader |
| 118 | // based on the type of database engine being used. |
| 119 | func BundleReaderFactory(db database.Database) (repo storage.BundleReader) { |
| 120 | // The switch statement determines the type of database engine. |
| 121 | switch db.GetEngineType() { |
| 122 | case "postgres": |
| 123 | // If the engine type is "postgres", create and return a PostgreSQL specific BundleReader. |
| 124 | return PQRepository.NewBundleReader(db.(*PQDatabase.Postgres)) |
| 125 | case "memory": |
| 126 | // If the engine type is "memory", create and return a memory-based BundleReader. |
| 127 | return MMRepository.NewBundleReader(db.(*MMDatabase.Memory)) |
| 128 | default: |
| 129 | // For any other engine type, default to using a memory-based BundleReader. |
| 130 | return MMRepository.NewBundleReader(db.(*MMDatabase.Memory)) |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | // BundleWriterFactory is a factory function that creates and returns a BundleWriter |
| 135 | // based on the type of database engine being used. |
no test coverage detected