Skip to content

Commit 1244475

Browse files
committed
fix
1 parent c597df2 commit 1244475

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

internal/server/resources/resources.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package resources
1616

1717
import (
18+
"errors"
1819
"sync"
1920

2021
"github.com/googleapis/genai-toolbox/internal/auth"
@@ -142,12 +143,15 @@ func (r *ResourceManager) Close() error {
142143
r.mu.Lock()
143144
defer r.mu.Unlock()
144145

146+
var errs []error
145147
for _, source := range r.sources {
146148
if closeable, ok := source.(sources.CloseableSource); ok {
147-
_ = closeable.Close()
149+
if err := closeable.Close(); err != nil {
150+
errs = append(errs, err)
151+
}
148152
}
149153
}
150-
return nil
154+
return errors.Join(errs...)
151155
}
152156

153157
func (r *ResourceManager) GetEmbeddingModelMap() map[string]embeddingmodels.EmbeddingModel {

internal/sources/bigquery/bigquery.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ func (s *Source) ToConfig() sources.SourceConfig {
313313

314314
// Close closes the BigQuery source and its associated caches/clients.
315315
func (s *Source) Close() error {
316+
var err error
316317
if s.Client != nil {
317-
s.Client.Close()
318+
err = s.Client.Close()
318319
}
319320
if s.bqClientCache != nil {
320321
s.bqClientCache.Stop()
@@ -325,7 +326,7 @@ func (s *Source) Close() error {
325326
if s.dataplexCache != nil {
326327
s.dataplexCache.Stop()
327328
}
328-
return nil
329+
return err
329330
}
330331

331332
func (s *Source) BigQueryClient() *bigqueryapi.Client {

internal/sources/cloudloggingadmin/cloud_logging_admin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,14 @@ func (s *Source) ToConfig() sources.SourceConfig {
124124

125125
// Close closes the Cloud Logging Admin source and its associated caches/clients.
126126
func (s *Source) Close() error {
127+
var err error
127128
if s.Client != nil {
128-
s.Client.Close()
129+
err = s.Client.Close()
129130
}
130131
if s.logadminClientCache != nil {
131132
s.logadminClientCache.Stop()
132133
}
133-
return nil
134+
return err
134135
}
135136

136137
func (s *Source) UseClientAuthorization() bool {

0 commit comments

Comments
 (0)