Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Nov 16, 2024
1 parent 17f2e17 commit b42c329
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 14 deletions.
8 changes: 4 additions & 4 deletions internal/app/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ func createRedisEngine(n *centrifuge.Node, cfgContainer *config.Container) (*cen
}

var broker *centrifuge.RedisBroker
if cfg.Broker.Type == "" {
if !cfg.Broker.Enabled {
broker, err = confighelpers.CentrifugeRedisBroker(
n, cfg.Broker.Redis.Prefix, redisShards, cfg.Broker.Redis.RedisBrokerCommon, false)
n, cfg.Engine.Redis.Prefix, redisShards, cfg.Engine.Redis.RedisBrokerCommon, false)
if err != nil {
return nil, nil, mode, fmt.Errorf("error creating Redis broker: %w", err)
}
}
var presenceManager centrifuge.PresenceManager
if cfg.PresenceManager.Type == "" {
if !cfg.PresenceManager.Enabled {
presenceManager, err = confighelpers.CentrifugeRedisPresenceManager(
n, cfg.PresenceManager.Redis.Prefix, redisShards, cfg.PresenceManager.Redis.RedisPresenceManagerCommon)
n, cfg.Engine.Redis.Prefix, redisShards, cfg.Engine.Redis.RedisPresenceManagerCommon)
if err != nil {
return nil, nil, mode, fmt.Errorf("error creating Redis presence manager: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func Run(cmd *cobra.Command, configFile string) {
}
}

modes, err := configureEngines(node, cfgContainer, serviceManager)
modes, err := configureEngines(node, cfgContainer)
if err != nil {
log.Fatal().Msgf("%v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func checkConfig(t *testing.T, conf Config) {
require.Equal(t, configtypes.Duration(time.Second), conf.Proxies[0].Timeout)
require.Equal(t, true, conf.Consumers[0].Kafka.TLS.Enabled)
require.Equal(t, configtypes.Duration(2*time.Second), conf.WebSocket.WriteTimeout)
require.Equal(t, "redis", conf.Engine.Type)
require.Equal(t, 30*time.Second, time.Duration(conf.Engine.Redis.PresenceTTL))
}

func TestConfigJSON(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions internal/config/testdata/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"tls": {
"enabled": true
},
"engine": {
"type": "redis",
"redis": {
"presence_ttl": "30s"
}
},
"client": {
"allowed_origins": ["http://localhost:3000"],
"token": {
Expand Down
26 changes: 17 additions & 9 deletions internal/config/testdata/config.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
[tls]
enabled = true

[engine]
type = "redis"

[engine.redis]
presence_ttl = "30s"

[client]
allowed_origins = [ "http://localhost:3000" ]
ping_interval = "12s"

[client.token]
jwks_public_endpoint = "https://example.com/jwks"

[channel]
[channel.without_namespace]
presence = true
[client.proxy.connect.http.static_headers]
x = "y"

[channel.without_namespace]
presence = true

[[channel.namespaces]]
name = "ns1"
presence = true
[[channel.namespaces]]
name = "ns1"
presence = true

[[channel.namespaces]]
name = "ns2"
presence = false
[[channel.namespaces]]
name = "ns2"
presence = false

[[proxies]]
name = "ppp"
Expand Down
9 changes: 9 additions & 0 deletions internal/config/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
---
tls:
enabled: true
engine:
type: redis
redis:
presence_ttl: 30s
client:
allowed_origins:
- http://localhost:3000
token:
jwks_public_endpoint: https://example.com/jwks
ping_interval: 12s
proxy:
connect:
http:
static_headers:
x: "y"
channel:
without_namespace:
presence: true
Expand Down

0 comments on commit b42c329

Please sign in to comment.