Skip to content

Commit

Permalink
lwc-events: make refresh frequency configurable (#1659)
Browse files Browse the repository at this point in the history
Add config setting for the config refresh frequency.
  • Loading branch information
brharrington committed May 22, 2024
1 parent b5912b4 commit 5557a77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions atlas-lwc-events/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ atlas.lwc.events {
config-uri = ${atlas.lwc.events.base-uri}"/expressions"
eval-uri = ${atlas.lwc.events.base-uri}"/evaluate"

// Frequency for refreshing configs
config-refresh-frequency = 10s

// Frequency for sending heartbeats
heartbeat-frequency = 2s

// Max buffer size before events will start getting dropped. Used to avoid OOM.
buffer-size = 1000000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class RemoteLwcEventClient(registry: Registry, config: Config)
private val configUri = URI.create(scopedConfig.getString("config-uri"))
private val evalUri = URI.create(scopedConfig.getString("eval-uri"))

private val configRefreshFrequency = scopedConfig.getDuration("config-refresh-frequency")
private val heartbeatFrequency = scopedConfig.getDuration("heartbeat-frequency")

private val bufferSize = scopedConfig.getInt("buffer-size")
private val flushSize = scopedConfig.getInt("flush-size")
private val batchSize = scopedConfig.getInt("batch-size")
Expand All @@ -66,12 +69,12 @@ class RemoteLwcEventClient(registry: Registry, config: Config)
scheduler = new Scheduler(registry, "LwcEventClient", 2)

val refreshOptions = new Scheduler.Options()
.withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofSeconds(10))
.withFrequency(Scheduler.Policy.FIXED_DELAY, configRefreshFrequency)
.withStopOnFailure(false)
scheduler.schedule(refreshOptions, () => refreshConfigs())

val heartbeatOptions = new Scheduler.Options()
.withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofSeconds(2))
.withFrequency(Scheduler.Policy.FIXED_DELAY, heartbeatFrequency)
.withStopOnFailure(false)
scheduler.schedule(heartbeatOptions, () => sendHeartbeat())

Expand Down

0 comments on commit 5557a77

Please sign in to comment.