Skip to content

Commit bd17fbf

Browse files
Tsotne Tabidzeachals
authored andcommitted
Pass feast project name to RedisOnlineStore
Signed-off-by: Tsotne Tabidze <tsotne@tecton.ai> Signed-off-by: Felix Wang <wangfelix98@gmail.com> Signed-off-by: Achal Shah <achals@gmail.com>
1 parent eac86a8 commit bd17fbf

3 files changed

Lines changed: 39 additions & 25 deletions

File tree

go/feast/connector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func getOnlineStore(config *RepoConfig) (OnlineStore, error) {
1111
return nil, errors.New(fmt.Sprintf("could not get online store type from online store config: %+v", config.OnlineStore))
1212
}
1313
if onlineStoreType == "redis" {
14-
onlineStore, err := NewRedisOnlineStore(config.OnlineStore)
14+
onlineStore, err := NewRedisOnlineStore(config.Project, config.OnlineStore)
1515
return onlineStore, err
1616
} else {
1717
// TODO(willem): Python connectors here

go/feast/redisonlinestore.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ type RedisOnlineStore struct {
2424
password string
2525
// Redis connection encryption
2626
ssl bool
27+
// Feast project name
28+
project string
2729
}
2830

29-
func NewRedisOnlineStore(onlineStoreConfig map[string]interface{}) (*RedisOnlineStore, error) {
30-
r := RedisOnlineStore{}
31+
func NewRedisOnlineStore(project string, onlineStoreConfig map[string]interface{}) (*RedisOnlineStore, error) {
32+
r := RedisOnlineStore{project: project}
3133
// Parse redis_type and write it into r.t
3234
redisTypeJson, ok := onlineStoreConfig["redis_type"]
3335
if !ok {

go/feast/redisonlinestore_test.go

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,71 @@ func TestNewRedisOnlineStore1(t *testing.T) {
99
onlineStoreConfig := map[string]interface{}{
1010
"type": "redis",
1111
}
12-
r, err := NewRedisOnlineStore(onlineStoreConfig)
12+
r, err := NewRedisOnlineStore("feature_repo", onlineStoreConfig)
1313
assert.Nil(t, err)
14-
assert.Equal(t, []string{"localhost:6379"}, r.addrs)
15-
assert.Empty(t, r.password)
16-
assert.False(t, r.ssl)
17-
assert.Equal(t, redisNode, r.t)
14+
assert.Equal(t, &RedisOnlineStore{
15+
t: redisNode,
16+
addrs: []string{"localhost:6379"},
17+
password: "",
18+
ssl: false,
19+
project: "feature_repo",
20+
}, r)
1821
}
1922

2023
func TestNewRedisOnlineStore2(t *testing.T) {
2124
onlineStoreConfig := map[string]interface{}{
2225
"type": "redis",
2326
"redis_type": "redis",
2427
}
25-
r, err := NewRedisOnlineStore(onlineStoreConfig)
28+
r, err := NewRedisOnlineStore("feature_repo", onlineStoreConfig)
2629
assert.Nil(t, err)
27-
assert.Equal(t, []string{"localhost:6379"}, r.addrs)
28-
assert.Empty(t, r.password)
29-
assert.False(t, r.ssl)
30-
assert.Equal(t, redisNode, r.t)
30+
assert.Equal(t, &RedisOnlineStore{
31+
t: redisNode,
32+
addrs: []string{"localhost:6379"},
33+
password: "",
34+
ssl: false,
35+
project: "feature_repo",
36+
}, r)
3137
}
3238

3339
func TestNewRedisOnlineStore3(t *testing.T) {
3440
onlineStoreConfig := map[string]interface{}{
3541
"type": "redis",
3642
"redis_type": "redis_cluster",
3743
}
38-
r, err := NewRedisOnlineStore(onlineStoreConfig)
44+
r, err := NewRedisOnlineStore("feature_repo", onlineStoreConfig)
3945
assert.Nil(t, err)
40-
assert.Equal(t, []string{"localhost:6379"}, r.addrs)
41-
assert.Empty(t, r.password)
42-
assert.False(t, r.ssl)
43-
assert.Equal(t, redisCluster, r.t)
46+
assert.Equal(t, &RedisOnlineStore{
47+
t: redisCluster,
48+
addrs: []string{"localhost:6379"},
49+
password: "",
50+
ssl: false,
51+
project: "feature_repo",
52+
}, r)
4453
}
4554

4655
func TestNewRedisOnlineStore4(t *testing.T) {
4756
onlineStoreConfig := map[string]interface{}{
4857
"type": "redis_cluster",
4958
"connection_string": "localhost:6379,localhost:6380,password=123456,ssl=true",
5059
}
51-
r, err := NewRedisOnlineStore(onlineStoreConfig)
60+
r, err := NewRedisOnlineStore("feature_repo", onlineStoreConfig)
5261
assert.Nil(t, err)
53-
assert.Equal(t, []string{"localhost:6379", "localhost:6380"}, r.addrs)
54-
assert.Equal(t, "123456", r.password)
55-
assert.True(t, r.ssl)
56-
assert.Equal(t, redisNode, r.t)
62+
assert.Equal(t, &RedisOnlineStore{
63+
t: redisNode,
64+
addrs: []string{"localhost:6379", "localhost:6380"},
65+
password: "123456",
66+
ssl: true,
67+
project: "feature_repo",
68+
}, r)
5769
}
5870

5971
func TestNewRedisOnlineStore5(t *testing.T) {
6072
onlineStoreConfig := map[string]interface{}{
6173
"type": "redis_cluster",
6274
"connection_string": "localhost:6379,foo=bar",
6375
}
64-
_, err := NewRedisOnlineStore(onlineStoreConfig)
76+
_, err := NewRedisOnlineStore("feature_repo", onlineStoreConfig)
6577
assert.NotNil(t, err)
6678
}
6779

@@ -70,6 +82,6 @@ func TestNewRedisOnlineStore6(t *testing.T) {
7082
"type": "redis_cluster",
7183
"connection_string": "localhost:6379,test",
7284
}
73-
_, err := NewRedisOnlineStore(onlineStoreConfig)
85+
_, err := NewRedisOnlineStore("feature_repo", onlineStoreConfig)
7486
assert.NotNil(t, err)
7587
}

0 commit comments

Comments
 (0)