Commit 57141bd0 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Support Action Cable on GCP Memorystore

This patches Action Cable so that an id that is explicitly set to nil
in cable.yml is not overwritten.

A nil id is needed so that the Redis client does not call CLIENT SETNAME
which is not supported in GCP Memorystore

Changelog: fixed
parent 6e8ae813
......@@ -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] : "ActionCable-PID-#{$$}" # rubocop:disable Gitlab/ModuleWithInstanceVariables
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