uc3-dmp-event-bridge 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9050634a720bb8d2305dc87eea00153073d7f361fec587dc12e6d013fd720061
4
- data.tar.gz: 7516cf1dc9c634f7b0c5a0ccc62dabab4e7dadd9fff5834930d04b3d1af87d5e
3
+ metadata.gz: 76c287b95fca7cb4d306a4a232c679c4c9959811c2d4473829f4bbb9b30a9fab
4
+ data.tar.gz: 232c3a045a0ef6ceb5ed8729668fe2118240d843b36cb0bd2518f5abf7642d8f
5
5
  SHA512:
6
- metadata.gz: 1ac808ba12eb73443acee84fbc7a3c508620772702df0b8a9efe2083e62b9a69591502d27333a9dcf2d68c18ec9150ea8e8ed90a6f7ef5a030457898d9b1fed8
7
- data.tar.gz: 722c336b4c7c5af9745a32d962ee80adfe594b97974d7dfc18a9511985d55e19cefbe6e555ffa1236d28950d1474a7d87b030e20cb707344f71aa32808cd15f2
6
+ metadata.gz: 29153fdd3888a81f29e0005fe322731275b8fea510d8f019c6956047cfc5e92c29185f45aec36ca966847dc6e4a6e0a51bdb7e2f85f542a4aa641b8ea048f452
7
+ data.tar.gz: cfbcf2aca3b42721e851c252a897c4cbe41f7e0520919f4548531e941d3e2fc78b587f7b93855b52e7930ed4073b39365684db786309d38bb2ff859fde115756
data/README.md CHANGED
@@ -0,0 +1,3 @@
1
+ # Uc3DmpEventBridge
2
+
3
+ Helper functions for interacting with an AWS EventBridge
@@ -27,26 +27,27 @@ module Uc3DmpEventBridge
27
27
 
28
28
  # Publish an event to the EventBus so that other Lambdas can do their thing
29
29
  # rubocop:disable Metrics/AbcSize
30
- def publish(source:, dmp:, event_type: DEFAULT_EVENT_TYPE, debug: false)
30
+ def publish(source:, dmp:, event_type: DEFAULT_EVENT_TYPE, detail:: nil, logger: nil)
31
31
  source = "#{source} -> #{SOURCE}.publish"
32
+ detail = detail.nil? ? _generate_detail(dmp: dmp).to_json : (detail.is_a?(Hash) ? detail.to_json : detail.to_s)
32
33
 
33
34
  message = {
34
35
  entries: [{
35
36
  time: Time.now,
36
37
  source: "#{ENV.fetch('DOMAIN', nil)}:lambda:event_publisher",
37
38
  detail_type: event_type.to_s,
38
- detail: _generate_detail(dmp: dmp).to_json,
39
+ detail: detail,
39
40
  event_bus_name: ENV.fetch('EVENT_BUS_NAME', nil)
40
41
  }]
41
42
  }
42
- puts "#{SOURCE}.publish - Publishing event -> details: #{message}" if debug
43
+ logger.debug(message: "#{SOURCE} published event", details: message) if logger.respond_to?(:debug)
43
44
  resp = client.put_events(message)
44
45
  return true unless resp.failed_entry_count.nil? || resp.failed_entry_count.positive?
45
46
 
46
47
  # The EventBridge returned errors, so log the error
47
48
  raise PublisherError, _generate_failure(source: source, response: resp, payload: payload)
48
49
  rescue Aws::Errors::ServiceError => e
49
- puts "#{SOURCE} - #{MSG_BUS_ERROR % { msg: e.message, trace: e.backtrace }}"
50
+ logger.error(message: "#{SOURCE} #{e.message}", details: e.backtrace) if logger.respond_to?(:debug)
50
51
  raise PublisherError, MSG_BUS_ERROR % { msg: e.message }
51
52
  end
52
53
  # rubocop:enable Metrics/AbcSize
@@ -60,6 +61,7 @@ module Uc3DmpEventBridge
60
61
  SK: dmp['SK'],
61
62
  dmphub_provenance_id: dmp.fetch('dmphub_provenance_id', nil),
62
63
  dmproadmap_links: dmp.fetch('dmproadmap_links', {}),
64
+ dmproadmap_related_identifiers: relateds,
63
65
  dmphub_updater_is_provenance: dmp.fetch('dmphub_updater_is_provenance', false)
64
66
  }
65
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpEventBridge
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-event-bridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-08 00:00:00.000000000 Z
11
+ date: 2023-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json