MCPcopy
hub / github.com/mudler/LocalAI / NewQuantStore

Function NewQuantStore

core/services/distributed/quant.go:47–54  ·  view source on GitHub ↗

NewQuantStore creates a new QuantStore and auto-migrates. Uses a PostgreSQL advisory lock to prevent concurrent migration races when multiple instances (frontend + workers) start at the same time.

(db *gorm.DB)

Source from the content-addressed store, hash-verified

45// Uses a PostgreSQL advisory lock to prevent concurrent migration races
46// when multiple instances (frontend + workers) start at the same time.
47func NewQuantStore(db *gorm.DB) (*QuantStore, error) {
48 if err := advisorylock.WithLockCtx(context.Background(), db, advisorylock.KeySchemaMigrate, func() error {
49 return db.AutoMigrate(&QuantJobRecord{})
50 }); err != nil {
51 return nil, fmt.Errorf("migrating quantization_jobs: %w", err)
52 }
53 return &QuantStore{db: db}, nil
54}
55
56// Create stores a new quantization job.
57func (s *QuantStore) Create(job *QuantJobRecord) error {

Callers 2

quant_test.goFile · 0.92
InitStoresFunction · 0.85

Calls 1

WithLockCtxFunction · 0.92

Tested by

no test coverage detected