Class: AnyCable::Config
- Inherits:
-
Anyway::Config
- Object
- Anyway::Config
- AnyCable::Config
show all
- Includes:
- GRPC::Config
- Defined in:
- lib/anycable/config.rb
Overview
Constant Summary
collapse
- BROADCAST_SECRET_PHRASE =
These phareses are used to infer secret keys from the application secret and MUST match the ones used in AnyCable (Go)
"broadcast-cable"
- HTTP_RPC_SECRET_PHRASE =
"rpc-cable"
Class Method Summary
collapse
Instance Method Summary
collapse
#enhance_grpc_server_args, #log_grpc, #normalized_grpc_server_args, #tls_credentials, #to_grpc_params
Class Method Details
.usage(txt) ⇒ Object
17
18
19
|
# File 'lib/anycable/config.rb', line 17
def usage(txt)
usages << txt
end
|
.usages ⇒ Object
21
22
23
|
# File 'lib/anycable/config.rb', line 21
def usages
@usages ||= []
end
|
Instance Method Details
#broadcast_key! ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/anycable/config.rb', line 110
def broadcast_key!
if http_broadcast_secret && !broadcast_key
self.broadcast_key ||= http_broadcast_secret
warn "DEPRECATION WARNING: `http_broadcast_secret` is deprecated, use `broadcast_key` instead"
end
return broadcast_key if broadcast_key
return unless secret
self.broadcast_key = infer_from_application_secret(BROADCAST_SECRET_PHRASE)
end
|
#http_broadcast_url ⇒ Object
105
106
107
108
|
# File 'lib/anycable/config.rb', line 105
def http_broadcast_url
super || (broadcast_key! ? "http://localhost:8080/_broadcast" : "http://localhost:8090/_broadcast")
end
|
#http_health_port_provided? ⇒ Boolean
101
102
103
|
# File 'lib/anycable/config.rb', line 101
def http_health_port_provided?
!http_health_port.nil? && http_health_port != ""
end
|
#http_rpc_secret! ⇒ Object
122
123
124
125
126
127
|
# File 'lib/anycable/config.rb', line 122
def http_rpc_secret!
return http_rpc_secret if http_rpc_secret
return unless secret
self.http_rpc_secret = infer_from_application_secret(HTTP_RPC_SECRET_PHRASE)
end
|
#jwt_secret ⇒ Object
133
134
135
|
# File 'lib/anycable/config.rb', line 133
def jwt_secret
super || secret
end
|
#load(*_args) ⇒ Object
93
94
95
|
# File 'lib/anycable/config.rb', line 93
def load(*_args)
super.tap { load_presets }
end
|
#log_level ⇒ Object
97
98
99
|
# File 'lib/anycable/config.rb', line 97
def log_level
debug? ? "debug" : super
end
|
#streams_secret ⇒ Object
129
130
131
|
# File 'lib/anycable/config.rb', line 129
def streams_secret
super || secret
end
|
#to_http_health_params ⇒ Object
Build HTTP health server parameters
217
218
219
220
221
222
|
# File 'lib/anycable/config.rb', line 217
def to_http_health_params
{
port: http_health_port,
path: http_health_path
}
end
|
#to_nats_params ⇒ Object
Build options for NATS.connect
209
210
211
212
213
214
|
# File 'lib/anycable/config.rb', line 209
def to_nats_params
{
servers: Array(nats_servers),
dont_randomize_servers: nats_dont_randomize_servers
}.merge(nats_options)
end
|
#to_redis_params ⇒ Object
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# File 'lib/anycable/config.rb', line 175
def to_redis_params
base_params = {url: redis_url}
base_params.tap do |params|
sentinels = redis_sentinels
next if sentinels.nil? || sentinels.empty?
sentinels = Array(sentinels) unless sentinels.is_a?(Array)
next if sentinels.empty?
params[:sentinels] = sentinels.map { |sentinel| parse_sentinel(sentinel) }
end.tap do |params|
next unless redis_url.match?(/rediss:\/\//)
cert_path, key_path, ca_path = redis_tls_client_cert_path, redis_tls_client_key_path, redis_tls_ca_cert_path
ssl_params = {}
if cert_path && key_path
ssl_params[:cert] = OpenSSL::X509::Certificate.new(File.read(cert_path))
ssl_params[:key] = OpenSSL::PKey.read(File.read(key_path))
ssl_params[:ca_path] if ca_path
end
if !redis_tls_verify?
ssl_params[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
end
params[:ssl_params] = ssl_params unless ssl_params.empty?
end
end
|