Sha256: 10145bd7de316bfc6b703753788a7a43596688c655a4ee50300e18cb715bec4a
Contents?: true
Size: 1003 Bytes
Versions: 1
Compression:
Stored size: 1003 Bytes
Contents
# frozen_string_literal: true require 'httparty' require 'no_proxy_fix' require 'slack-notifier' module MShard class MShard include HTTParty base_uri ENV['MSHARD_URI'] def get(id) self.class.get("/v2/shards/#{id}").body end def set(params) self.class.post('/v2/shards', body: params)['id'] end def try(times: 3, delay: 2) times.times do begin return yield rescue StandardError sleep delay end end nil end def get_safe(*args) try { get(*args) } end def set_safe(*args) # rubocop:disable Naming/AccessorMethodName try { set(*args) } end def detour? ENV['http_proxy'] end def notify(**args) return set(args) if detour? args[:slack] ||= true args[:webhook_url] ||= ENV['SLACK_WEBHOOK_URI'] args[:channel] ||= ENV['SLACK_CHANNEL'] Slack::Notifier.new(args[:webhook_url], **args).ping(args[:text]) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mshard-0.6.0 | lib/mshard/mshard.rb |