Skip to content

Commit 92a91f3

Browse files
Runtime DB in redis
1 parent 29d6e6a commit 92a91f3

File tree

32 files changed

+4717
-33
lines changed

32 files changed

+4717
-33
lines changed

.github/actions/run-integration-tests/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Run Integration Tests
2-
description: Runs integration tests against a specific database type
2+
description: Runs integration tests against a specific database type (sqlite, postgres, or redis)
33
inputs:
44
database-type:
5-
description: 'Database type to test against (sqlite or postgres)'
5+
description: 'Database type to test against (sqlite, postgres, or redis)'
66
required: true
77
type: string
88
coverage-enabled:
@@ -35,7 +35,7 @@ runs:
3535
go mod download
3636
3737
- name: 🗄️ Setup PostgreSQL Database
38-
if: inputs.database-type == 'postgres'
38+
if: inputs.database-type == 'postgres' || inputs.database-type == 'redis'
3939
shell: bash
4040
run: |
4141
PGPASSWORD=asgthunder psql -h localhost -p 5432 -U asgthunder -d thunderdb -c "CREATE DATABASE configdb;"

.github/workflows/pr-builder.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ jobs:
474474
runs-on: ubuntu-latest
475475
strategy:
476476
matrix:
477-
database: [sqlite, postgres]
477+
database: [sqlite, postgres, redis]
478478
fail-fast: false
479479
services:
480480
postgres:
@@ -490,6 +490,15 @@ jobs:
490490
--health-interval 10s
491491
--health-timeout 5s
492492
--health-retries 5
493+
redis:
494+
image: redis:latest
495+
ports:
496+
- 6379:6379
497+
options: >-
498+
--health-cmd "redis-cli ping"
499+
--health-interval 10s
500+
--health-timeout 5s
501+
--health-retries 5
493502
steps:
494503
- name: 📥 Checkout Code
495504
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

backend/cmd/server/repository/resources/conf/default.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
"options": "_journal_mode=WAL&_busy_timeout=5000&_pragma=foreign_keys(1)",
4444
"max_open_conns": 500,
4545
"max_idle_conns": 100,
46-
"conn_max_lifetime": 3600
46+
"conn_max_lifetime": 3600,
47+
"address": "",
48+
"db": 0,
49+
"key_prefix": ""
4750
},
4851
"user": {
4952
"type": "sqlite",

backend/internal/attributecache/init.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,18 @@
1818

1919
package attributecache
2020

21-
// Initialize initializes the attribute cache service with a SQL store
22-
// and returns an instance of AttributeCacheServiceInterface.
21+
import (
22+
"github.com/asgardeo/thunder/internal/system/config"
23+
"github.com/asgardeo/thunder/internal/system/database/provider"
24+
)
25+
26+
// Initialize initializes the attribute cache service and returns an instance of AttributeCacheServiceInterface.
2327
func Initialize() AttributeCacheServiceInterface {
24-
store := newAttributeCacheStore()
28+
var store attributeCacheStoreInterface
29+
if config.GetThunderRuntime().Config.Database.Runtime.Type == provider.DataSourceTypeRedis {
30+
store = newRedisAttributeCacheStore(provider.GetRedisProvider())
31+
} else {
32+
store = newAttributeCacheStore()
33+
}
2534
return newAttributeCacheService(store)
2635
}

0 commit comments

Comments
 (0)