Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Prevent interweaving apps flushing
Browse files Browse the repository at this point in the history
Change-Id: Ic6dbc7c23dde78e855bc7701a3b384379e99bb70
  • Loading branch information
Anfernee Gui committed Jul 24, 2012
1 parent 0e43fd0 commit dcb843b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/router/router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def config(config)
@flush_apps_interval = config['flush_apps_interval'] || 30
@active_apps = Set.new
@flushing_apps = Set.new
@flushing = false
end
end

Expand Down Expand Up @@ -235,6 +236,9 @@ def add_active_app(app_id)
def flush_active_apps
return unless @enable_nonprod_apps

return if @flushing
@flushing = true

@active_apps, @flushing_apps = @flushing_apps, @active_apps
@active_apps.clear

Expand All @@ -244,6 +248,8 @@ def flush_active_apps

log.info("Flushing active apps, app size: #{@flushing_apps.size}, msg size: #{zmsg.size}")
EM.next_tick { NATS.publish('router.active_apps', zmsg) }

@flushing = false
end

end
Expand Down

0 comments on commit dcb843b

Please sign in to comment.