Skip to content

Commit 97ed40c

Browse files
samuelkim7ntkathole
authored andcommitted
fix(go): skip registry refresh when cache_ttl_seconds <= 0
Signed-off-by: samuelkim7 <samuel.kim@goflink.com>
1 parent e756ffe commit 97ed40c

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

go/internal/feast/registry/registry.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func (r *Registry) InitializeRegistry() error {
8181
}
8282

8383
func (r *Registry) RefreshRegistryOnInterval() {
84+
if r.cachedRegistryProtoTtl <= 0 {
85+
log.Info().Msg("Registry cache TTL is non-positive; skipping periodic refresh")
86+
return
87+
}
8488
ticker := time.NewTicker(r.cachedRegistryProtoTtl)
8589
for ; true; <-ticker.C {
8690
err := r.refresh()

go/internal/feast/registry/registry_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"time"
1111

1212
"github.com/aws/aws-sdk-go-v2/service/s3"
13+
"github.com/stretchr/testify/assert"
1314
)
1415

1516
func TestCloudRegistryStores(t *testing.T) {
@@ -99,6 +100,24 @@ func TestCloudRegistryStores(t *testing.T) {
99100
}
100101
}
101102

103+
func TestRefreshRegistryOnIntervalNonPositiveTTL(t *testing.T) {
104+
tests := []struct {
105+
name string
106+
ttl time.Duration
107+
}{
108+
{name: "zero ttl", ttl: 0},
109+
{name: "negative ttl", ttl: -1 * time.Second},
110+
}
111+
for _, test := range tests {
112+
t.Run(test.name, func(t *testing.T) {
113+
r := &Registry{cachedRegistryProtoTtl: test.ttl}
114+
assert.NotPanics(t, func() {
115+
r.RefreshRegistryOnInterval()
116+
})
117+
})
118+
}
119+
}
120+
102121
// MockS3Client is mock client for testing S3 registry store
103122
type MockS3Client struct {
104123
GetObjectFn func(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)

0 commit comments

Comments
 (0)