+1
config.yaml
+1
config.yaml
+2
-1
internal/api/handlers.go
+2
-1
internal/api/handlers.go
···
187
187
didRecord, err := s.db.GetDIDRecord(r.Context(), did)
188
188
if err != nil {
189
189
if err == sql.ErrNoRows {
190
-
resp.error("DID not found", http.StatusNotFound)
190
+
// NEW: Provide helpful message if indexing is disabled
191
+
resp.error("DID not found. Note: DID indexing may be disabled in configuration.", http.StatusNotFound)
191
192
} else {
192
193
resp.error(err.Error(), http.StatusInternalServerError)
193
194
}
+1
-1
internal/api/server.go
+1
-1
internal/api/server.go
···
24
24
}
25
25
26
26
func NewServer(db storage.Database, apiCfg config.APIConfig, plcCfg config.PLCConfig) *Server {
27
-
bundleManager, _ := plc.NewBundleManager(plcCfg.BundleDir, plcCfg.UseCache, db)
27
+
bundleManager, _ := plc.NewBundleManager(plcCfg.BundleDir, plcCfg.UseCache, db, plcCfg.IndexDIDs)
28
28
29
29
s := &Server{
30
30
router: mux.NewRouter(),
+3
-2
internal/config/config.go
+3
-2
internal/config/config.go
···
23
23
DirectoryURL string `yaml:"directory_url"`
24
24
ScanInterval time.Duration `yaml:"scan_interval"`
25
25
BatchSize int `yaml:"batch_size"`
26
-
BundleDir string `yaml:"bundles_dir"` // NEW: Cache directory
27
-
UseCache bool `yaml:"use_cache"` // NEW: Enable/disable cache
26
+
BundleDir string `yaml:"bundles_dir"`
27
+
UseCache bool `yaml:"use_cache"`
28
+
IndexDIDs bool `yaml:"index_dids"`
28
29
}
29
30
30
31
type PDSConfig struct {
+24
-19
internal/plc/bundle.go
+24
-19
internal/plc/bundle.go
···
20
20
const BUNDLE_SIZE = 10000
21
21
22
22
type BundleManager struct {
23
-
dir string
24
-
enabled bool
25
-
encoder *zstd.Encoder
26
-
decoder *zstd.Decoder
27
-
db storage.Database
23
+
dir string
24
+
enabled bool
25
+
encoder *zstd.Encoder
26
+
decoder *zstd.Decoder
27
+
db storage.Database
28
+
indexDIDs bool
28
29
}
29
30
30
31
// ===== INITIALIZATION =====
31
32
32
-
func NewBundleManager(dir string, enabled bool, db storage.Database) (*BundleManager, error) {
33
+
func NewBundleManager(dir string, enabled bool, db storage.Database, indexDIDs bool) (*BundleManager, error) {
33
34
if !enabled {
34
35
return &BundleManager{enabled: false}, nil
35
36
}
···
49
50
}
50
51
51
52
return &BundleManager{
52
-
dir: dir,
53
-
enabled: enabled,
54
-
encoder: encoder,
55
-
decoder: decoder,
56
-
db: db,
53
+
dir: dir,
54
+
enabled: enabled,
55
+
encoder: encoder,
56
+
decoder: decoder,
57
+
db: db,
58
+
indexDIDs: indexDIDs, // NEW
57
59
}, nil
58
60
}
59
61
···
375
377
return err
376
378
}
377
379
378
-
start := time.Now()
379
-
// Index DIDs synchronously (will use bulk inserts for speed)
380
-
if err := bm.db.AddBundleDIDs(ctx, bundleNum, dids); err != nil {
381
-
log.Error("Failed to index DIDs for bundle %06d: %v", bundleNum, err)
382
-
// Don't return error - bundle is already created
383
-
// DID indexing can be retried later
380
+
// NEW: Only index DIDs if enabled
381
+
if bm.indexDIDs {
382
+
start := time.Now()
383
+
if err := bm.db.AddBundleDIDs(ctx, bundleNum, dids); err != nil {
384
+
log.Error("Failed to index DIDs for bundle %06d: %v", bundleNum, err)
385
+
// Don't return error - bundle is already created
386
+
} else {
387
+
elapsed := time.Since(start)
388
+
log.Verbose("✓ Indexed %d unique DIDs for bundle %06d in %v", len(dids), bundleNum, elapsed)
389
+
}
384
390
} else {
385
-
elapsed := time.Since(start)
386
-
log.Verbose("✓ Indexed %d unique DIDs for bundle %06d in %v", len(dids), bundleNum, elapsed)
391
+
log.Verbose("⊘ Skipped DID indexing for bundle %06d (disabled in config)", bundleNum)
387
392
}
388
393
389
394
return nil
+1
-1
internal/plc/scanner.go
+1
-1
internal/plc/scanner.go
···
21
21
}
22
22
23
23
func NewScanner(db storage.Database, cfg config.PLCConfig) *Scanner {
24
-
bundleManager, err := NewBundleManager(cfg.BundleDir, cfg.UseCache, db)
24
+
bundleManager, err := NewBundleManager(cfg.BundleDir, cfg.UseCache, db, cfg.IndexDIDs) // NEW: pass IndexDIDs
25
25
if err != nil {
26
26
log.Error("Warning: failed to initialize bundle manager: %v", err)
27
27
bundleManager = &BundleManager{enabled: false}