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

Function WatcherFactory

internal/factories/storage.go:58–70  ·  view source on GitHub ↗

WatcherFactory creates and returns a Watcher based on the database engine type.

(db database.Database)

Source from the content-addressed store, hash-verified

56
57// WatcherFactory creates and returns a Watcher based on the database engine type.
58func 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.
73func SchemaWriterFactory(db database.Database) (repo storage.SchemaWriter) {

Callers 1

serveFunction · 0.92

Calls 1

GetEngineTypeMethod · 0.65

Tested by

no test coverage detected