MCPcopy Create free account
hub / github.com/Permify/permify / BundleReaderFactory

Function BundleReaderFactory

internal/factories/storage.go:119–132  ·  view source on GitHub ↗

BundleReaderFactory is a factory function that creates and returns a BundleReader based on the type of database engine being used.

(db database.Database)

Source from the content-addressed store, hash-verified

117// BundleReaderFactory is a factory function that creates and returns a BundleReader
118// based on the type of database engine being used.
119func 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.

Callers 2

NewContainerFunction · 0.92
serveFunction · 0.92

Calls 1

GetEngineTypeMethod · 0.65

Tested by

no test coverage detected