Sha256: fc5b492634b3f33af2c5ee73a3e213120890c15d8c1db01ec7282b822a74bc5f
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
require 'thor' module SearchKit class Events class CLI < Thor # An extraction of the CLI command, "publish". # class Publish include Messaging attr_reader :client, :channel, :payload def initialize(client, channel, options = {}) @client = client @channel = channel @payload = options.fetch('payload', {}) end def perform info "Event published, status @ #{status_uri}" rescue Faraday::ConnectionFailed warning "Remote events service not found" rescue Errors::PublicationFailed => error warning "Publication failed: #{error}" rescue JSON::ParserError => error warning "Response unreadable: #{error}" error.backtrace.each(&method(:warning)) end private def status_uri return @status_uri if @status_uri response = client.publish(channel, payload) links = response.fetch(:data, {}).fetch(:links, {}) @status_uri = links.fetch(:self, '') end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
search-kit-0.0.2 | lib/search_kit/events/cli/publish.rb |
search-kit-0.0.1 | lib/search_kit/events/cli/publish.rb |