Class: Gitlab::Graphql::Subscriptions::ActionCableWithLoadBalancing

Inherits:
GraphQL::Subscriptions::ActionCableSubscriptions
  • Object
show all
Extended by:
Utils::Override
Includes:
Database::LoadBalancing::WalTrackingReceiver, Database::LoadBalancing::WalTrackingSender
Defined in:
lib/gitlab/graphql/subscriptions/action_cable_with_load_balancing.rb

Constant Summary collapse

KEY_PAYLOAD =
'gql_payload'
KEY_WAL_LOCATIONS =
'wal_locations'

Instance Method Summary collapse

Methods included from Utils::Override

extended, extensions, included, method_added, override, prepended, queue_verification, verify!

Methods included from Database::LoadBalancing::WalTrackingReceiver

#databases_in_sync?

Methods included from Database::LoadBalancing::WalTrackingSender

#wal_location_for, #wal_locations_by_db_name

Instance Method Details

#execute_all(event, object) ⇒ Object



15
16
17
18
19
20
# File 'lib/gitlab/graphql/subscriptions/action_cable_with_load_balancing.rb', line 15

def execute_all(event, object)
  super(event, {
    KEY_WAL_LOCATIONS => current_wal_locations,
    KEY_PAYLOAD => object
  })
end

#execute_update(subscription_id, event, object) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/gitlab/graphql/subscriptions/action_cable_with_load_balancing.rb', line 24

def execute_update(subscription_id, event, object)
  # Make sure we do not accidentally try to unwrap messages that are not wrapped.
  # This could in theory happen if workers roll over where some send wrapped payload
  # and others expect the original payload.
  return super(subscription_id, event, object) unless wrapped_payload?(object)

  wal_locations = object[KEY_WAL_LOCATIONS]
  ::Gitlab::Database::LoadBalancing::Session.current.use_primary! if use_primary?(wal_locations)

  super(subscription_id, event, object[KEY_PAYLOAD])
end