
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Manage whether users are online when you have a regular heartbeat, coming from a websocket for example. It allows you to have frequent heartbeats, but you only update the user's status when they transition between online and offline states. I have not run any benchmarks, but this is probably faster than updating your database every few seconds with a last_online timestamp.
It runs in an eventmachine reactor, and defines a simple DSL with callbacks which are executed when a user transitions between online and offline states.
Add this line to your application's Gemfile:
gem 'online_manager'
And then execute:
$ bundle
Or install it yourself as:
$ gem install online_manager
require 'online_manager'
# You should set all the users offline when it first runs,
# since otherwise you'll be left with users marked online from when it last quit.
class OnlineConfig
# How long since a heartbeat was last received until the user is considered offline? (in seconds)
def timeout
5
end
# All the blocks below will be called inside an eventmachine reactor.
def setup
# Set up any websocket server/connection to pubsub server, etc
# This must use eventmachine, otherwise it will block the reactor.
# Then yield(user_id) whenever you receive a heartbeat from a user.
end
def online(user_id)
puts "Booster #{user_id} online"
# Update the user to online in the database or whatever
# This must use asynchronous i/o, otherwise it will block the reactor.
end
def offline(user_id)
puts "Booster #{user_id} offline"
# Called when a user transitions from online -> offline
end
end
# This runs an eventmachine reactor, so the call to .run blocks.
OnlineManager.run(OnlineConfig.new)
If you already are in the context of an eventmachine reactor, or you want to run multiple of these in the same thread,
you can use .setup
.
EM.run do
OnlineManager.setup(OnlineConfig.new)
end
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that online_manager demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.