Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions view/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"database/sql"
"fmt"
as "github.com/aerospike/aerospike-client-go"
"github.com/aerospike/aerospike-client-go/types"
"strconv"
"strings"
"sync"
"time"

as "github.com/aerospike/aerospike-client-go"
"github.com/aerospike/aerospike-client-go/types"
)

var (
Expand Down Expand Up @@ -226,18 +227,24 @@ func (d *db) keepConnectionAlive(driver string, dsn string, config *DBConfig) {
}

if err != nil || aDb == nil {
fmt.Printf("[INFO] %v database connection lost, reconnecting\n", driver)
newDb, err := sql.Open(driver, dsn)
if err != nil {
fmt.Printf("[INFO] couldn't open new %v database \n", driver)
continue
}
d.mutex.Lock()
d.actual = newDb
if newDb != nil {
d.configureDB(config, newDb)
}
d.mutex.Unlock()

ctx, timeout := d.ctxWithTimeout(time.Duration(5) * time.Second)
toSecs := 5
ctx, timeout := d.ctxWithTimeout(time.Duration(toSecs) * time.Second)
err = newDb.PingContext(ctx)
if err != nil {
fmt.Printf("[INFO] couldn't connect to one of %v database \n", driver)
fmt.Printf("[INFO] couldn't ping new %v database after %d seconds\n", driver, toSecs)
}

timeout()
Expand Down
14 changes: 9 additions & 5 deletions view/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import (
"context"
"embed"
"fmt"
"path"
"reflect"
"strings"
"sync"
"time"

"github.com/viant/afs"
"github.com/viant/afs/file"
"github.com/viant/afs/storage"
Expand All @@ -19,11 +25,6 @@ import (
"github.com/viant/xdatly/predicate"
"github.com/viant/xreflect"
"gopkg.in/yaml.v3"
"path"
"reflect"
"strings"
"sync"
"time"
)

const (
Expand Down Expand Up @@ -191,6 +192,9 @@ func (r *Resource) loadText(ctx context.Context, URL string, expand bool) (strin
embedFs = r.FSEmbedder.EmbedFS()
}
data, err := fs.DownloadWithURL(ctx, URL, embedFs)
if err != nil {
return "", err
}

if err = r.UpdateTime(ctx, URL); err != nil {
return "", err
Expand Down