
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
celluloid_pubsub_redis_adapter
Advanced tools
CelluloidPubsubRedisAdapter is a simple ruby implementation of publish subscribe design patterns using celluloid actors and websockets, using Celluloid::Reel server and redis as a publish subscribe backend
Starting with version 0.1.0 , support for celluloid 0.17 was added
Rails >3.0 only. MRI 1.9.x, 2.x, JRuby (--1.9).
Ruby 1.8 is not officially supported. We will accept further compatibilty pull-requests but no upcoming versions will be tested against it.
Rubinius support temporarily dropped due to Rails 4 incompatibility.
Add the following to your Gemfile:
gem "celluloid_pubsub_redis_adapter"
Please read Release Details if you are upgrading. We break backward compatibility between large ticks but you can expect it to be specified at release notes.
Creating a websocket server is simple as doing this. This are all the options available with their default values.
CelluloidPubsub::WebServer.supervise_as(:web_server,
enable_debug: true, # if debug messages should be logged
adapter: 'redis' , # if set to 'redis', will instantiate a RedisReactor class to handle each connection, which requires Redis to be available. Otherwise will use a simple Reactor to handle the connections which has no dependencies .
log_file_path: "path/to/log_file.log", # The log file where all debugging information will be printed
hostname: "0.0.0.0", # the hostname of the server.
port: 1234, # the port on which the server will listen for connections
path: '/ws', # the relative path used in the URL where connections are allowed to connect
spy: false, # whether to spy all internal Websocket connections in order to get more debugging information
backlog: 1024 # the number of connections allowed to be connected to the server at a certain time
)
Creating a client is simple as doing this. If you provide the channel when you initialize the CelluloidPubsub::Client it will automatically start the subscription to that channel. But sometimes, you might want to subscribe at a later time, so you can just omit the channel when you initialize the client, and use instead @client.subscribe('test_channel'). After the subscription has started, the client must implement the method on_message and the on_close method (called when client disconnects from the channel). The method on_message will receive all incoming messages from the server. You can test if the subscription was successful by doing this @client.succesfull_subscription?(message).
class MyAwesomeClient
include Celluloid
def initialize(options = {})
@client = CelluloidPubsub::Client.new({
actor: Actor.current,
channel: 'test_channel', # the channel to which this client will subscribe to.
log_file_path: "path/to/log_file.log", # The log file where all debugging information will be printed
hostname: "0.0.0.0", # the hostname of the server.
port: 1234,# the port on which the connection will be made to
path: '/ws', # the relative path used in the URL where the connection will be connecting to
enable_debug: false # if debug messages should be logged
}.merge(options))
end
def on_message(message)
if @client.succesfull_subscription?(message)
puts "subscriber got successful subscription #{message.inspect}"
@client.publish('test_channel2', 'data' => ' subscriber got successfull subscription') # the message needs to be a Hash
else
puts "subscriber got message #{message.inspect}"
end
end
def on_close(code, reason)
puts "websocket connection closed: #{code.inspect}, #{reason.inspect}"
terminate
end
end
The methods available that the CelluloidPubsub::Client instance can execute are:
Please check the Examples Folder. There you can find some basic examples.
To test, do the following:
Please log all feedback/issues via Github Issues. Thanks.
== Copyright
Copyright (c) 2016 bogdanRada. See LICENSE.txt for further details.
FAQs
Unknown package
We found that celluloid_pubsub_redis_adapter 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 MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.