lib/cyclone_lariat/abstract/client.rb in cyclone_lariat-0.3.10 vs lib/cyclone_lariat/abstract/client.rb in cyclone_lariat-0.4.0

- old
+ new

@@ -12,40 +12,46 @@ include LunaPark::Extensions::Injector dependency(:aws_client_class) { raise ArgumentError, 'Client class should be defined' } dependency(:aws_credentials_class) { Aws::Credentials } - def initialize(key: nil, secret_key: nil, region: nil, version: nil, publisher: nil, instance: nil, client_id: nil) + def initialize(key: nil, secret_key: nil, region: nil, version: nil, publisher: nil, instance: nil, account_id: nil) @key = key @secret_key = secret_key @region = region @version = version @publisher = publisher @instance = instance - @client_id = client_id + @account_id = account_id end - def event(type, data: {}, version: self.version, uuid: SecureRandom.uuid) - Event.wrap( + def event(type, data: {}, version: self.version, request_id: nil, uuid: SecureRandom.uuid) + params = { uuid: uuid, type: type, - sent_at: Time.now.iso8601, + sent_at: Time.now.iso8601(3), version: version, publisher: publisher, - data: data - ) + data: data, + request_id: request_id + } + + Event.wrap(params.compact) end - def command(type, data: {}, version: self.version, uuid: SecureRandom.uuid) - Command.wrap( + def command(type, data: {}, version: self.version, request_id: nil, uuid: SecureRandom.uuid) + params = { uuid: uuid, type: type, - sent_at: Time.now.iso8601, + sent_at: Time.now.iso8601(3), version: version, publisher: publisher, - data: data - ) + data: data, + request_id: request_id + } + + Command.wrap(params.compact) end def publish raise LunaPark::Errors::AbstractMethod, 'Publish method should be defined' end @@ -86,11 +92,11 @@ def region @region ||= CycloneLariat.aws_default_region end - def client_id - @client_id ||= CycloneLariat.aws_client_id + def account_id + @account_id ||= CycloneLariat.aws_account_id end private def aws_client