Respect provider rate limits and preserve bank connections on throttling

This commit is contained in:
Lars Nolden
2026-09-10 17:25:09 +02:00
parent 2259db3e85
commit ba3ea6ae5a
14 changed files with 1250 additions and 95 deletions
+4 -2
View File
@@ -70,7 +70,7 @@ func (a *App) Preview(ctx context.Context, r PreviewRequest) (Preview, error) {
}
a.mu.Lock()
s, err := a.snapshot(ctx)
client := a.classifier
client := a.classifier.WithModel(r.Model)
a.mu.Unlock()
if err != nil {
return Preview{}, err
@@ -78,7 +78,6 @@ func (a *App) Preview(ctx context.Context, r PreviewRequest) (Preview, error) {
if r.Revision != s.Revision {
return Preview{}, errors.New("revision conflict: reload before analysing")
}
client.Model = r.Model
p := Preview{ID: domain.NewID("preview"), Revision: s.Revision, Changes: []Change{}, Errors: []ClassificationError{}, created: time.Now()}
baseMerchants := len(s.Data.Merchants)
for _, t := range s.Data.Transactions {
@@ -90,6 +89,9 @@ func (a *App) Preview(ctx context.Context, r PreviewRequest) (Preview, error) {
}
p.Analysed++
proposal, e := client.Classify(ctx, t.Facts, s.Data, true)
if err = ctx.Err(); err != nil {
return Preview{}, err
}
if e != nil {
p.Errors = append(p.Errors, ClassificationError{t.Facts.ID, e.Error()})
continue