Module: Wukong::Deploy::PrepareSyncerOverride

Defined in:
lib/wukong-deploy/extensions/prepare_syncer.rb

Overview

Attaches to the hooks provided by the Wukong::Load::Syncer class to write data to Vayacondios.

Defined Under Namespace

Modules: HandlerOverride

Instance Method Summary collapse

Instance Method Details

#after_syncObject

Announces a successful sync and updates the last sync state and time.



16
17
18
19
20
21
22
23
24
25
# File 'lib/wukong-deploy/extensions/prepare_syncer.rb', line 16

def after_sync
  super()
  Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
    success: success?,
    step:    'prepare',
    counts:   counts,
    files:    files,
  }.tap { |e| e[:duration] = duration if duration })
  Wukong::Deploy.vayacondios_client.set(vayacondios_topic, "prepare.last", { state: (success? ? 1 : 0), time: Time.now.utc.to_i })
end

#before_syncObject

Saves the syncer as a stash in Vayacondios.



9
10
11
12
# File 'lib/wukong-deploy/extensions/prepare_syncer.rb', line 9

def before_sync
  super()
  Wukong::Deploy.vayacondios_client.set(vayacondios_topic, 'prepare', self)
end

#on_error(error) ⇒ Object

Announces an error during a sync and updates the last sync state and time.



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wukong-deploy/extensions/prepare_syncer.rb', line 29

def on_error error
  super(error)
  Wukong::Deploy.vayacondios_client.announce(vayacondios_topic, {
    success: false,
    step:    'prepare',
    error:   error.class,
    message: error.message,
    counts:   counts,
    files:    files,
  })
  Wukong::Deploy.vayacondios_client.set(vayacondios_topic, "prepare.last", { state: 0, time: Time.now.utc.to_i })
end

#to_vayacondiosHash

Returns a representation of this PrepareSyncer suitable for a Vayacondios stash.

Returns:

  • (Hash)


53
54
55
56
57
58
59
60
61
# File 'lib/wukong-deploy/extensions/prepare_syncer.rb', line 53

def to_vayacondios
  {
    split:     settings[:split],
    lines:     settings[:lines],
    bytes:     settings[:bytes],
    ordered:   settings[:ordered],
    metadata:  settings[:metadata],
  }
end

#vayacondios_topicString

Returns the Vayacondios topic for this PrepareSyncer.

Returns:

  • (String)

    the Vayacondios topic



45
46
47
# File 'lib/wukong-deploy/extensions/prepare_syncer.rb', line 45

def vayacondios_topic
  "listeners.#{name}"
end