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

Function BundleWriterFactory

internal/factories/storage.go:136–149  ·  view source on GitHub ↗

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

(db database.Database)

Source from the content-addressed store, hash-verified

134// BundleWriterFactory is a factory function that creates and returns a BundleWriter
135// based on the type of database engine being used.
136func BundleWriterFactory(db database.Database) (repo storage.BundleWriter) {
137 // The switch statement determines the type of database engine.
138 switch db.GetEngineType() {
139 case "postgres":
140 // If the engine type is "postgres", create and return a PostgreSQL specific BundleWriter.
141 return PQRepository.NewBundleWriter(db.(*PQDatabase.Postgres))
142 case "memory":
143 // If the engine type is "memory", create and return a memory-based BundleWriter.
144 return MMRepository.NewBundleWriter(db.(*MMDatabase.Memory))
145 default:
146 // For any other engine type, default to using a memory-based BundleWriter.
147 return MMRepository.NewBundleWriter(db.(*MMDatabase.Memory))
148 }
149}

Callers 2

NewContainerFunction · 0.92
serveFunction · 0.92

Calls 1

GetEngineTypeMethod · 0.65

Tested by

no test coverage detected