Commit b6df7992 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'actioncable-gcp-memorystore' into 'master'

Support Action Cable on GCP Memorystore

See merge request gitlab-org/gitlab!75173
parents 6db3e960 9524d752
......@@ -9,6 +9,8 @@ Rails.application.configure do
config.action_cable.worker_pool_size = Gitlab::ActionCable::Config.worker_pool_size
end
ActionCable::SubscriptionAdapter::Base.prepend(Gitlab::Patch::ActionCableSubscriptionAdapterIdentifier)
# https://github.com/rails/rails/blob/bb5ac1623e8de08c1b7b62b1368758f0d3bb6379/actioncable/lib/action_cable/subscription_adapter/redis.rb#L18
ActionCable::SubscriptionAdapter::Redis.redis_connector = lambda do |config|
args = config.except(:adapter, :channel_prefix)
......
# frozen_string_literal: true
# Modifies https://github.com/rails/rails/blob/v6.1.4.1/actioncable/lib/action_cable/subscription_adapter/base.rb so
# that we do not overwrite an id that was explicitly set to `nil` in cable.yml.
# This is needed to support GCP Memorystore. See https://github.com/rails/rails/issues/38244.
module Gitlab
module Patch
module ActionCableSubscriptionAdapterIdentifier
def identifier
@server.config.cable.has_key?(:id) ? @server.config.cable[:id] : super # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'ActionCableSubscriptionAdapterIdentifier override' do
describe '#identifier' do
context 'when id key is nil on cable.yml' do
it 'does not override server config id with action cable pid' do
config = {
adapter: 'redis',
url: 'unix:/home/localuser/redis/redis.socket',
channel_prefix: 'test_',
id: nil
}
::ActionCable::Server::Base.config.cable = config
sub = ActionCable.server.pubsub.send(:redis_connection)
expect(sub.connection[:id]).to eq('redis:///home/localuser/redis/redis.socket/0')
expect(ActionCable.server.config.cable[:id]).to be_nil
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment