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
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/anycable/config.rb', line 104
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_health_port_provided? ⇒ Boolean
100
101
102
|
# File 'lib/anycable/config.rb', line 100
def http_health_port_provided?
!http_health_port.nil? && http_health_port != ""
end
|
#http_rpc_secret! ⇒ Object
116
117
118
119
120
121
|
# File 'lib/anycable/config.rb', line 116
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
127
128
129
|
# File 'lib/anycable/config.rb', line 127
def jwt_secret
super || secret
end
|
#load(*_args) ⇒ Object
92
93
94
|
# File 'lib/anycable/config.rb', line 92
def load(*_args)
super.tap { load_presets }
end
|
#log_level ⇒ Object
96
97
98
|
# File 'lib/anycable/config.rb', line 96
def log_level
debug? ? "debug" : super
end
|
#streams_secret ⇒ Object
123
124
125
|
# File 'lib/anycable/config.rb', line 123
def streams_secret
super || secret
end
|
#to_http_health_params ⇒ Object
Build HTTP health server parameters
210
211
212
213
214
215
|
# File 'lib/anycable/config.rb', line 210
def to_http_health_params
{
port: http_health_port,
path: http_health_path
}
end
|
#to_nats_params ⇒ Object
Build options for NATS.connect
202
203
204
205
206
207
|
# File 'lib/anycable/config.rb', line 202
def to_nats_params
{
servers: Array(nats_servers),
dont_randomize_servers: nats_dont_randomize_servers
}.merge(nats_options)
end
|
#to_redis_params ⇒ Object
168
169
170
171
172
173
174
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
|
# File 'lib/anycable/config.rb', line 168
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:\/\//)
if !!redis_tls_client_cert_path ^ !!redis_tls_client_key_path
raise_validation_error "Both Redis TLS client certificate and private key must be specified (or none of them)"
end
if !redis_tls_verify?
params[:ssl_params] = {verify_mode: OpenSSL::SSL::VERIFY_NONE}
else
cert_path, key_path = redis_tls_client_cert_path, redis_tls_client_key_path
if cert_path && key_path
params[:ssl_params] = {
cert: OpenSSL::X509::Certificate.new(File.read(cert_path)),
key: OpenSSL::PKey.read(File.read(key_path))
}
end
end
end
end
|