+1
config.yaml
+1
config.yaml
+2
-1
internal/api/handlers.go
+2
-1
internal/api/handlers.go
···
187
didRecord, err := s.db.GetDIDRecord(r.Context(), did)
188
if err != nil {
189
if err == sql.ErrNoRows {
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)
192
} else {
193
resp.error(err.Error(), http.StatusInternalServerError)
194
}
+1
-1
internal/api/server.go
+1
-1
internal/api/server.go
+3
-2
internal/config/config.go
+3
-2
internal/config/config.go
···
23
DirectoryURL string `yaml:"directory_url"`
24
ScanInterval time.Duration `yaml:"scan_interval"`
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
28
}
29
30
type PDSConfig struct {
+24
-19
internal/plc/bundle.go
+24
-19
internal/plc/bundle.go
···
20
const BUNDLE_SIZE = 10000
21
22
type BundleManager struct {
23
-
dir string
24
-
enabled bool
25
-
encoder *zstd.Encoder
26
-
decoder *zstd.Decoder
27
-
db storage.Database
28
}
29
30
// ===== INITIALIZATION =====
31
32
-
func NewBundleManager(dir string, enabled bool, db storage.Database) (*BundleManager, error) {
33
if !enabled {
34
return &BundleManager{enabled: false}, nil
35
}
···
49
}
50
51
return &BundleManager{
52
-
dir: dir,
53
-
enabled: enabled,
54
-
encoder: encoder,
55
-
decoder: decoder,
56
-
db: db,
57
}, nil
58
}
59
···
375
return err
376
}
377
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
384
} else {
385
-
elapsed := time.Since(start)
386
-
log.Verbose("✓ Indexed %d unique DIDs for bundle %06d in %v", len(dids), bundleNum, elapsed)
387
}
388
389
return nil
···
20
const BUNDLE_SIZE = 10000
21
22
type BundleManager struct {
23
+
dir string
24
+
enabled bool
25
+
encoder *zstd.Encoder
26
+
decoder *zstd.Decoder
27
+
db storage.Database
28
+
indexDIDs bool
29
}
30
31
// ===== INITIALIZATION =====
32
33
+
func NewBundleManager(dir string, enabled bool, db storage.Database, indexDIDs bool) (*BundleManager, error) {
34
if !enabled {
35
return &BundleManager{enabled: false}, nil
36
}
···
50
}
51
52
return &BundleManager{
53
+
dir: dir,
54
+
enabled: enabled,
55
+
encoder: encoder,
56
+
decoder: decoder,
57
+
db: db,
58
+
indexDIDs: indexDIDs, // NEW
59
}, nil
60
}
61
···
377
return err
378
}
379
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
+
}
390
} else {
391
+
log.Verbose("⊘ Skipped DID indexing for bundle %06d (disabled in config)", bundleNum)
392
}
393
394
return nil
+1
-1
internal/plc/scanner.go
+1
-1
internal/plc/scanner.go
···
21
}
22
23
func NewScanner(db storage.Database, cfg config.PLCConfig) *Scanner {
24
-
bundleManager, err := NewBundleManager(cfg.BundleDir, cfg.UseCache, db)
25
if err != nil {
26
log.Error("Warning: failed to initialize bundle manager: %v", err)
27
bundleManager = &BundleManager{enabled: false}
···
21
}
22
23
func NewScanner(db storage.Database, cfg config.PLCConfig) *Scanner {
24
+
bundleManager, err := NewBundleManager(cfg.BundleDir, cfg.UseCache, db, cfg.IndexDIDs) // NEW: pass IndexDIDs
25
if err != nil {
26
log.Error("Warning: failed to initialize bundle manager: %v", err)
27
bundleManager = &BundleManager{enabled: false}