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

Function SchemaReaderFactory

internal/factories/storage.go:43–55  ·  view source on GitHub ↗

SchemaReaderFactory creates and returns a SchemaReader based on the database engine type.

(db database.Database)

Source from the content-addressed store, hash-verified

41
42// SchemaReaderFactory creates and returns a SchemaReader based on the database engine type.
43func SchemaReaderFactory(db database.Database) (repo storage.SchemaReader) {
44 switch db.GetEngineType() {
45 case "postgres":
46 // If the database engine is Postgres, create a new SchemaReader using the Postgres implementation
47 return PQRepository.NewSchemaReader(db.(*PQDatabase.Postgres))
48 case "memory":
49 // If the database engine is in-memory, create a new SchemaReader using the in-memory implementation
50 return MMRepository.NewSchemaReader(db.(*MMDatabase.Memory))
51 default:
52 // For any other type, use the in-memory implementation as a default
53 return MMRepository.NewSchemaReader(db.(*MMDatabase.Memory))
54 }
55}
56
57// WatcherFactory creates and returns a Watcher based on the database engine type.
58func WatcherFactory(db database.Database) (repo storage.Watcher) {

Callers 8

NewContainerFunction · 0.92
serveFunction · 0.92
check_test.goFile · 0.92
expand_test.goFile · 0.92
lookup_test.goFile · 0.92
check_test.goFile · 0.92

Calls 1

GetEngineTypeMethod · 0.65

Tested by

no test coverage detected