diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b97e55..98ace6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +### Removed + +- Handling of pre-1.0 subscriptions data. + + If you're still using version 0.5 or below, please upgrade to 1.0 or 1.1 first with `handle_legacy_subscriptions` setting enabled. + See [release notes for version 1.0.0](https://github.com/anycable/graphql-anycable/releases/tag/v1.0.0) for details. + ## 1.1.3 - 2022-03-11 ### Changed diff --git a/README.md b/README.md index ab30e58..7d89c6b 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,6 @@ GraphQL-AnyCable uses [anyway_config] to configure itself. There are several pos ```.env GRAPHQL_ANYCABLE_SUBSCRIPTION_EXPIRATION_SECONDS=604800 GRAPHQL_ANYCABLE_USE_REDIS_OBJECT_ON_CLEANUP=true - GRAPHQL_ANYCABLE_HANDLE_LEGACY_SUBSCRIPTIONS=false GRAPHQL_ANYCABLE_USE_CLIENT_PROVIDED_UNIQ_ID=false ``` @@ -151,7 +150,6 @@ GraphQL-AnyCable uses [anyway_config] to configure itself. There are several pos production: subscription_expiration_seconds: 300 # 5 minutes use_redis_object_on_cleanup: false # For restricted redis installations - handle_legacy_subscriptions: false # For seamless upgrade from pre-1.0 versions use_client_provided_uniq_id: false # To avoid problems with non-uniqueness of Apollo channel identifiers ``` @@ -183,13 +181,6 @@ As in AnyCable there is no place to store subscription data in-memory, it should => 52ee8d65-275e-4d22-94af-313129116388 ``` - > For backward compatibility with pre-1.0 versions of this gem older `graphql-event:#{event.topic}` set containing subscription identifiers is also supported. - > - > ``` - > SMEMBERS graphql-event:1:myStats: - > => 52ee8d65-275e-4d22-94af-313129116388 - > ``` - 3. Subscription data: `graphql-subscription:#{subscription_id}` hash contains everything required to evaluate subscription on trigger and create data for client. ``` diff --git a/lib/graphql/anycable/cleaner.rb b/lib/graphql/anycable/cleaner.rb index d873d72..aab37c2 100644 --- a/lib/graphql/anycable/cleaner.rb +++ b/lib/graphql/anycable/cleaner.rb @@ -8,7 +8,6 @@ module Cleaner def clean clean_channels clean_subscriptions - clean_events clean_fingerprint_subscriptions clean_topic_fingerprints end @@ -37,21 +36,6 @@ def clean_subscriptions end end - def clean_events - return unless config.handle_legacy_subscriptions - - redis.scan_each(match: "#{adapter::SUBSCRIPTION_EVENTS_PREFIX}*") do |key| - subscription_id = key.sub(/\A#{adapter::SUBSCRIPTION_EVENTS_PREFIX}/, "") - next if redis.exists?(adapter::SUBSCRIPTION_PREFIX + subscription_id) - - redis.smembers(key).each do |event_topic| - redis.srem(adapter::EVENT_PREFIX + event_topic, subscription_id) - end - - redis.del(key) - end - end - def clean_fingerprint_subscriptions redis.scan_each(match: "#{adapter::SUBSCRIPTIONS_PREFIX}*") do |key| redis.smembers(key).each do |subscription_id| diff --git a/lib/graphql/anycable/config.rb b/lib/graphql/anycable/config.rb index 5758c00..e225344 100644 --- a/lib/graphql/anycable/config.rb +++ b/lib/graphql/anycable/config.rb @@ -10,7 +10,6 @@ class Config < Anyway::Config attr_config subscription_expiration_seconds: nil attr_config use_redis_object_on_cleanup: true - attr_config handle_legacy_subscriptions: false attr_config use_client_provided_uniq_id: true on_load do diff --git a/lib/graphql/anycable/tasks/clean_expired_subscriptions.rake b/lib/graphql/anycable/tasks/clean_expired_subscriptions.rake index c28d696..c9043a6 100644 --- a/lib/graphql/anycable/tasks/clean_expired_subscriptions.rake +++ b/lib/graphql/anycable/tasks/clean_expired_subscriptions.rake @@ -18,11 +18,6 @@ namespace :graphql do GraphQL::AnyCable::Cleaner.clean_subscriptions end - # Clean up legacy subscription_ids from events for expired subscriptions - task :events do - GraphQL::AnyCable::Cleaner.clean_events - end - # Clean up subscription_ids from event fingerprints for expired subscriptions task :fingerprint_subscriptions do GraphQL::AnyCable::Cleaner.clean_fingerprint_subscriptions diff --git a/lib/graphql/subscriptions/anycable_subscriptions.rb b/lib/graphql/subscriptions/anycable_subscriptions.rb index cf6a648..9096fc9 100644 --- a/lib/graphql/subscriptions/anycable_subscriptions.rb +++ b/lib/graphql/subscriptions/anycable_subscriptions.rb @@ -60,9 +60,6 @@ class AnyCableSubscriptions < GraphQL::Subscriptions FINGERPRINTS_PREFIX = "graphql-fingerprints:" # ZSET: To get fingerprints by topic SUBSCRIPTIONS_PREFIX = "graphql-subscriptions:" # SET: To get subscriptions by fingerprint CHANNEL_PREFIX = "graphql-channel:" # SET: Auxiliary structure for whole channel's subscriptions cleanup - # For backward compatibility: - EVENT_PREFIX = "graphql-event:" - SUBSCRIPTION_EVENTS_PREFIX = "graphql-subscription-events:" # @param serializer [<#dump(obj), #load(string)] Used for serializing messages before handing them to `.broadcast(msg)` def initialize(serializer: Serialize, **rest) @@ -73,8 +70,6 @@ def initialize(serializer: Serialize, **rest) # An event was triggered. # Re-evaluate all subscribed queries and push the data over ActionCable. def execute_all(event, object) - execute_legacy(event, object) if config.handle_legacy_subscriptions - fingerprints = redis.zrange(FINGERPRINTS_PREFIX + event.topic, 0, -1) return if fingerprints.empty? @@ -109,17 +104,6 @@ def execute_grouped(fingerprint, subscription_ids, event, object) deliver(SUBSCRIPTIONS_PREFIX + fingerprint, result) end - # For migration from pre-1.0 graphql-anycable gem - def execute_legacy(event, object) - redis.smembers(EVENT_PREFIX + event.topic).each do |subscription_id| - next unless redis.exists?(SUBSCRIPTION_PREFIX + subscription_id) - result = execute_update(subscription_id, event, object) - next unless result - - deliver(SUBSCRIPTION_PREFIX + subscription_id, result) - end - end - # Disable this method as there is no fingerprint (it can be retrieved from subscription though) def execute(subscription_id, event, object) raise NotImplementedError, "Use execute_all method instead of execute to get actual event fingerprint" @@ -206,19 +190,6 @@ def delete_subscription(subscription_id) pipeline.zremrangebyscore(key, '-inf', '0') if score.value.zero? end end - delete_legacy_subscription(subscription_id) - end - - def delete_legacy_subscription(subscription_id) - return unless config.handle_legacy_subscriptions - - events = redis.smembers(SUBSCRIPTION_EVENTS_PREFIX + subscription_id) - redis.pipelined do - events.each do |event_topic| - redis.srem(EVENT_PREFIX + event_topic, subscription_id) - end - redis.del(SUBSCRIPTION_EVENTS_PREFIX + subscription_id) - end end # The channel was closed, forget about it and its subscriptions