Class: AnyCable::Config

Inherits:
Anyway::Config
  • Object
show all
Defined in:
lib/anycable/config.rb

Overview

AnyCable configuration.

Constant Summary collapse

DefaultHostWrapper =
Class.new(String)

Instance Method Summary collapse

Instance Method Details

#debugObject Also known as: debug?



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

def debug
  @debug != false
end

#http_health_port_provided?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/anycable/config.rb', line 57

def http_health_port_provided?
  !http_health_port.nil? && http_health_port != ""
end

#log_grpcObject



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

def log_grpc
  debug || @log_grpc
end

#log_levelObject



43
44
45
# File 'lib/anycable/config.rb', line 43

def log_level
  debug ? :debug : @log_level
end

#to_grpc_paramsObject

Build gRPC server parameters



62
63
64
65
66
67
68
69
70
# File 'lib/anycable/config.rb', line 62

def to_grpc_params
  {
    pool_size: rpc_pool_size,
    max_waiting_requests: rpc_max_waiting_requests,
    poll_period: rpc_poll_period,
    pool_keep_alive: rpc_pool_keep_alive,
    server_args: rpc_server_args
  }
end

#to_http_health_paramsObject

Build HTTP health server parameters



87
88
89
90
91
92
# File 'lib/anycable/config.rb', line 87

def to_http_health_params
  {
    port: http_health_port,
    path: http_health_path
  }
end

#to_redis_paramsObject

Build Redis parameters



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/anycable/config.rb', line 73

def to_redis_params
  { url: redis_url }.tap do |params|
    next if redis_sentinels.nil?

    raise ArgumentError, "redis_sentinels must be an array; got #{redis_sentinels}" unless
      redis_sentinels.is_a?(Array)

    next if redis_sentinels.empty?

    params[:sentinels] = redis_sentinels.map(&method(:parse_sentinel))
  end
end