Class: Flexite::Diff::AsyncShowService

Inherits:
SyncShowService show all
Defined in:
app/services/flexite/diff/async_show_service.rb

Instance Method Summary collapse

Methods inherited from SyncShowService

#initialize

Constructor Details

This class inherits a constructor from Flexite::Diff::SyncShowService

Instance Method Details

#callObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/services/flexite/diff/async_show_service.rb', line 4

def call
  response = Flexite.cache.read("#{Flexite.state_digest}-#{@stage}-show-diff")

  if response.present?
    return result(response)
  end

  expire_old
  nodes = Config.t_nodes
  checksum = Digest::MD5.hexdigest(nodes.to_json)
  Flexite.cache.write("#{Flexite.state_digest}-#{@stage}-diff-checksum", checksum)
  @remote_diff.check({ token: Flexite.config.migration_token, tree: nodes, stage: Flexite.config.stagename, checksum: checksum })
  ActionService::Result.new(flash: { type: :warning, message: "You will be notified via #{Flexite.config.async_diff_handler&.notifier} when difference check will be completed" },
                            endpoint: { partial: 'flexite/shared/show_flash' })
end