Module: AnyCable
- Defined in:
- lib/anycable.rb,
lib/anycable/cli.rb,
lib/anycable/jwt.rb,
lib/anycable/rpc.rb,
lib/anycable/grpc.rb,
lib/anycable/config.rb,
lib/anycable/socket.rb,
lib/anycable/streams.rb,
lib/anycable/version.rb,
lib/anycable/grpc_kit.rb,
lib/anycable/middleware.rb,
lib/anycable/serializer.rb,
lib/anycable/grpc/config.rb,
lib/anycable/grpc/server.rb,
lib/anycable/rpc/handler.rb,
lib/anycable/grpc/handler.rb,
lib/anycable/health_server.rb,
lib/anycable/httrpc/server.rb,
lib/anycable/protos/rpc_pb.rb,
lib/anycable/grpc_kit/server.rb,
lib/anycable/middleware_chain.rb,
lib/anycable/broadcast_adapters.rb,
lib/anycable/exceptions_handling.rb,
lib/anycable/middlewares/env_sid.rb,
lib/anycable/grpc/rpc_services_pb.rb,
lib/anycable/rpc/handlers/command.rb,
lib/anycable/rpc/handlers/connect.rb,
lib/anycable/middlewares/exceptions.rb,
lib/anycable/broadcast_adapters/base.rb,
lib/anycable/broadcast_adapters/http.rb,
lib/anycable/broadcast_adapters/nats.rb,
lib/anycable/rpc/handlers/disconnect.rb,
lib/anycable/broadcast_adapters/redis.rb,
lib/anycable/broadcast_adapters/redisx.rb,
lib/anycable/middlewares/check_version.rb
Overview
Extend some PB auto-generated classes
Defined Under Namespace
Modules: BroadcastAdapters, ExceptionsHandling, GRPC, HTTRPC, JWT, Middlewares, RPC, Serializer, StatusPredicates, Streams, WithConnectionState Classes: CLI, CommandMessage, CommandResponse, Config, ConnectionResponse, DisconnectRequest, DisconnectResponse, Env, HealthServer, Middleware, MiddlewareChain, Socket
Constant Summary collapse
- PROTO_VERSION =
Current RPC proto version (used for compatibility checks)
"v1"
- SESSION_KEY =
"_s_"
- WHISPER_KEY =
"$w"
- PRESENCE_KEY =
"$p"
- VERSION =
"1.6.0.rc.1"
- EnvResponse =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.EnvResponse").msgclass
- PresenceResponse =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.PresenceResponse").msgclass
- ConnectionRequest =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.ConnectionRequest").msgclass
- Status =
::Google::Protobuf::DescriptorPool.generated_pool.lookup("anycable.Status").enummodule
Class Attribute Summary collapse
-
.connection_factory ⇒ Object
Provide connection factory which is a callable object with build a Connection object.
- .logger ⇒ Object
-
.middleware ⇒ Object
readonly
Returns the value of attribute middleware.
- .rpc_handler ⇒ Object
-
.server_builder ⇒ Object
Provide a method to build a server to serve RPC.
Class Method Summary collapse
-
.broadcast ⇒ Object
Raw broadcast message to the channel, sends only string! To send hash or object use ActionCable.server.broadcast instead!.
- .broadcast_adapter ⇒ Object
- .broadcast_adapter=(adapter) ⇒ Object
-
.capture_exception(&block) ⇒ Object
Register a custom block that will be called when an exception is raised during RPC call.
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
-
.configure_server(&block) ⇒ Object
Register a callback to be invoked before the server starts.
- .server_callbacks ⇒ Object
Class Attribute Details
.connection_factory ⇒ Object
Provide connection factory which is a callable object with build a Connection object
37 38 39 |
# File 'lib/anycable.rb', line 37 def connection_factory @connection_factory end |
.logger ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/anycable.rb', line 46 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 |
.middleware ⇒ Object
Returns the value of attribute middleware.
44 45 46 |
# File 'lib/anycable.rb', line 44 def middleware @middleware end |
.rpc_handler ⇒ Object
103 104 105 |
# File 'lib/anycable.rb', line 103 def rpc_handler @rpc_handler ||= AnyCable::RPC::Handler.new end |
.server_builder ⇒ Object
Provide a method to build a server to serve RPC
40 41 42 |
# File 'lib/anycable.rb', line 40 def server_builder @server_builder end |
Class Method Details
.broadcast ⇒ Object
Raw broadcast message to the channel, sends only string! To send hash or object use ActionCable.server.broadcast instead!
99 100 101 |
# File 'lib/anycable.rb', line 99 def broadcast(...) broadcast_adapter.broadcast(...) end |
.broadcast_adapter ⇒ Object
79 80 81 82 |
# File 'lib/anycable.rb', line 79 def broadcast_adapter self.broadcast_adapter = AnyCable.config.broadcast_adapter.to_sym unless instance_variable_defined?(:@broadcast_adapter) @broadcast_adapter end |
.broadcast_adapter=(adapter) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/anycable.rb', line 84 def broadcast_adapter=(adapter) if adapter.is_a?(Symbol) || adapter.is_a?(Array) adapter = BroadcastAdapters.lookup_adapter(adapter) end unless adapter.respond_to?(:broadcast) raise ArgumentError, "BroadcastAdapter must implement #broadcast method. " \ "#{adapter.class} doesn't implement it." end @broadcast_adapter = adapter end |
.capture_exception(&block) ⇒ Object
Register a custom block that will be called when an exception is raised during RPC call
65 66 67 |
# File 'lib/anycable.rb', line 65 def capture_exception(&block) ExceptionsHandling << block end |
.config ⇒ Object
55 56 57 |
# File 'lib/anycable.rb', line 55 def config @config ||= Config.new end |
.configure {|config| ... } ⇒ Object
59 60 61 |
# File 'lib/anycable.rb', line 59 def configure yield(config) if block_given? end |
.configure_server(&block) ⇒ Object
Register a callback to be invoked before the server starts
71 72 73 |
# File 'lib/anycable.rb', line 71 def configure_server(&block) server_callbacks << block end |
.server_callbacks ⇒ Object
75 76 77 |
# File 'lib/anycable.rb', line 75 def server_callbacks @server_callbacks ||= [] end |