Module: Anycable

Defined in:
lib/anycable.rb,
lib/anycable/config.rb,
lib/anycable/pubsub.rb,
lib/anycable/server.rb,
lib/anycable/socket.rb,
lib/anycable/version.rb,
lib/anycable/rpc/rpc_pb.rb,
lib/anycable/rpc_handler.rb,
lib/anycable/health_server.rb,
lib/anycable/rpc/rpc_services_pb.rb,
lib/anycable/handler/exceptions_handling.rb

Overview

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength

Defined Under Namespace

Modules: Handler, HealthServer, RPC, Server Classes: Config, PubSub, RPCHandler, Socket

Constant Summary collapse

VERSION =
"0.5.2"
ConnectionRequest =
Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.ConnectionRequest").msgclass
ConnectionResponse =
Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.ConnectionResponse").msgclass
CommandMessage =
Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.CommandMessage").msgclass
CommandResponse =
Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.CommandResponse").msgclass
DisconnectRequest =
Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.DisconnectRequest").msgclass
DisconnectResponse =
Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.DisconnectResponse").msgclass
Status =
Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.Status").enummodule

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connection_factoryObject

Provide connection factory which is a callable object with build a Connection object



19
20
21
# File 'lib/anycable.rb', line 19

def connection_factory
  @connection_factory
end

Class Method Details

.broadcast(channel, payload) ⇒ Object

Raw broadcast message to the channel, sends only string! To send hash or object use ActionCable.server.broadcast instead!



52
53
54
# File 'lib/anycable.rb', line 52

def broadcast(channel, payload)
  pubsub.broadcast(channel, payload)
end

.configObject



33
34
35
# File 'lib/anycable.rb', line 33

def config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



37
38
39
# File 'lib/anycable.rb', line 37

def configure
  yield(config) if block_given?
end

.error_handlersObject



41
42
43
44
# File 'lib/anycable.rb', line 41

def error_handlers
  return @error_handlers if instance_variable_defined?(:@error_handlers)
  @error_handlers = []
end

.loggerObject



25
26
27
28
29
30
31
# File 'lib/anycable.rb', line 25

def logger
  return @logger if instance_variable_defined?(:@logger)
  log_output = Anycable.config.log_file || STDOUT
  @logger = Logger.new(log_output).tap do |logger|
    logger.level = Anycable.config.log_level
  end
end

.logger=(logger) ⇒ Object



21
22
23
# File 'lib/anycable.rb', line 21

def logger=(logger)
  @logger = logger
end

.pubsubObject



46
47
48
# File 'lib/anycable.rb', line 46

def pubsub
  @pubsub ||= PubSub.new
end