Files

33 lines
731 B
Go
Raw Permalink Normal View History

package platformsettings
import (
"context"
"github.com/descrybe/descrybe-v2/apps/api/internal/eprel"
)
// DynamicEPREL resolves platform settings on each call so admin changes
// apply without restarting the worker.
type DynamicEPREL struct {
Settings *Service
}
func (d *DynamicEPREL) Enabled() bool {
if d == nil || d.Settings == nil {
return false
}
opts, err := d.Settings.ResolveEPREL(context.Background())
return err == nil && opts.Enabled
}
func (d *DynamicEPREL) Fetch(ctx context.Context, eprelID string) (*eprel.Data, error) {
if d == nil || d.Settings == nil {
return nil, nil
}
client, err := d.Settings.NewEPRELClient(ctx)
if err != nil {
return nil, err
}
return client.Fetch(ctx, eprelID)
}