services:

  # PURGE.LOGGER
  #
  # Provides logging services to purge and its submodules, via a single channel.
  purge.logger:
    class: Drupal\purge\Logger\LoggerService
    arguments: ['@config.factory', '@purge.logger.parts_factory']
    public: true
    tags:
      - { name: needs_destruction }
  purge.logger.parts_factory:
    class: Drupal\purge\Logger\LoggerChannelPartFactory
    arguments: ['@logger.channel.purge']
    public: false
  logger.channel.purge:
    parent: logger.channel_base
    arguments: ['purge']
    public: false

  # PURGE.QUEUERS
  #
  # Manages services tagged 'purge_queuer' by exposing them in end-user
  # interfaces and allowing users to disable/enable them.
  purge.queuers:
    class: Drupal\purge\Plugin\Purge\Queuer\QueuersService
    arguments: ['@plugin.manager.purge.queuer', '@config.factory']
    public: true
  plugin.manager.purge.queuer:
    class: Drupal\purge\Plugin\Purge\Queuer\PluginManager
    parent: default_plugin_manager
    public: false

  # PURGE.INVALIDATION.FACTORY
  #
  # The invalidation object factory, generates 'purge instruction' value objects
  # on demand. Invalidations have state and flow freely between queue and
  # purgers, but can also be instantiated through the factory and get fed to the
  # purger straight away.
  purge.invalidation.factory:
    class: Drupal\purge\Plugin\Purge\Invalidation\InvalidationsService
    arguments: ['@plugin.manager.purge.invalidation', '@purge.purgers']
    public: true
  plugin.manager.purge.invalidation:
    class: Drupal\purge\Plugin\Purge\Invalidation\PluginManager
    parent: default_plugin_manager
    public: false

  # PURGE.QUEUE:
  #
  # The queue service which stores, claims, releases and accepts invalidation
  # objects returning from 'purge.purgers'.
  purge.queue:
    class: Drupal\purge\Plugin\Purge\Queue\QueueService
    arguments: ['@plugin.manager.purge.queue', '@purge.logger', '@config.factory', '@purge.queue.txbuffer',  '@purge.queue.stats', '@purge.invalidation.factory', '@purge.purgers']
    public: true
    tags:
      - { name: needs_destruction }
  purge.queue.txbuffer:
    public: true
    class: Drupal\purge\Plugin\Purge\Queue\TxBuffer
  purge.queue.stats:
    class: Drupal\purge\Plugin\Purge\Queue\StatsTracker
    arguments: ['@state']
    public: true
    tags:
      - { name: needs_destruction }
  plugin.manager.purge.queue:
    class: Drupal\purge\Plugin\Purge\Queue\PluginManager
    parent: default_plugin_manager
    public: false

  # PURGE.DIAGNOSTICS:
  #
  # The diagnostics service which monitors and warns for problematic situations
  # that can occur during purging. When it detects severe issues, it will
  # prevent all purges in the first place.
  purge.diagnostics:
    class: Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService
    arguments: ['@plugin.manager.purge.diagnostics', '@service_container']
    public: true
  plugin.manager.purge.diagnostics:
    class:  Drupal\purge\Plugin\Purge\DiagnosticCheck\PluginManager
    parent: default_plugin_manager
    public: false

  # PURGE.PROCESSORS
  #
  # Processors pull items from the queue and initiate purging activity.
  purge.processors:
    class: Drupal\purge\Plugin\Purge\Processor\ProcessorsService
    arguments: ['@plugin.manager.purge.processor', '@config.factory']
    public: true
  plugin.manager.purge.processor:
    class: Drupal\purge\Plugin\Purge\Processor\PluginManager
    parent: default_plugin_manager
    public: false

  # PURGE.PURGERS:
  #
  # The executive service which lets enabled purgers invalidate external caches.
  purge.purgers:
    class: Drupal\purge\Plugin\Purge\Purger\PurgersService
    arguments: ['@plugin.manager.purge.purgers', '@purge.logger', '@purge.purgers.tracker.capacity', '@purge.purgers.tracker.runtime_measurement', '@config.factory', '@lock', '@purge.diagnostics']
    public: true
  purge.purgers.tracker.capacity:
    class: Drupal\purge\Plugin\Purge\Purger\CapacityTracker
    public: true
  purge.purgers.tracker.runtime_measurement:
    class: Drupal\purge\Plugin\Purge\Purger\RuntimeMeasurementTracker
    arguments: ['@state']
    public: true
    tags:
      - { name: needs_destruction }
  plugin.manager.purge.purgers:
    class: Drupal\purge\Plugin\Purge\Purger\PluginManager
    parent: default_plugin_manager
    public: false

  # PURGE.TAGSHEADERS
  #
  # Discovered tagsheader plugins, register required response headers using the
  # CacheableResponseSubscriber declared below. Each plugin defines the name
  # of the header to be send out and can override header value formatting.
  purge.tagsheaders:
    class: Drupal\purge\Plugin\Purge\TagsHeader\TagsHeadersService
    arguments: ['@plugin.manager.purge.tagsheader', '@service_container']
    public: true
  purge.tagsheaders.cacheable_response_subscriber:
    class: Drupal\purge\EventSubscriber\CacheableResponseSubscriber
    arguments: ['@purge.tagsheaders']
    public: true
    tags:
      - { name: event_subscriber }
  plugin.manager.purge.tagsheader:
    class: Drupal\purge\Plugin\Purge\TagsHeader\PluginManager
    parent: default_plugin_manager
    public: false

  # PURGE_DRUSH services. Moved over from drush.services.yml for Drush 12 compatibility.
  purge_drush.debug_commands:
    class: Drupal\purge\Drush\Commands\DebugCommands
    arguments: ['@purge.logger']
    tags:
      - { name: drush.command }
  purge_drush.diagnostics_command:
    class: Drupal\purge\Drush\Commands\DiagnosticsCommand
    arguments: ['@purge.diagnostics']
    tags:
      - { name: drush.command }
  purge_drush.invalidate_command:
    class: Drupal\purge\Drush\Commands\InvalidateCommand
    arguments: ['@purge.invalidation.factory', '@purge.processors', '@purge.purgers']
    tags:
      - { name: drush.command }
  purge_drush.processor_commands:
    class: Drupal\purge\Drush\Commands\ProcessorCommands
    arguments: ['@purge.processors']
    tags:
      - { name: drush.command }
  purge_drush.purger_commands:
    class: Drupal\purge\Drush\Commands\PurgerCommands
    arguments: ['@purge.purgers']
    tags:
      - { name: drush.command }
  purge_drush.queue_commands:
    class: Drupal\purge\Drush\Commands\QueueCommands
    arguments: ['@purge.processors', '@purge.purgers', '@purge.invalidation.factory', '@purge.queue', '@purge.queue.stats', '@purge.queuers']
    tags:
      - { name: drush.command }
  purge_drush.queuer_commands:
    class: Drupal\purge\Drush\Commands\QueuerCommands
    arguments: ['@purge.queuers']
    tags:
      - { name: drush.command }
  purge_drush.types_command:
    class: Drupal\purge\Drush\Commands\TypesCommand
    arguments: ['@purge.invalidation.factory', '@purge.purgers']
    tags:
      - { name: drush.command }
