class Sidekiq::Metrics::Adapter::Bigquery

Attributes

async[R]
raise_error[R]
with_suffix[R]

Public Class Methods

new(dataset, table, with_suffix: false, async: false, raise_error: false, sidekiq_worker_options: { queue: :default, retry: 5 }) click to toggle source

@param [Google::Cloud::Bigquery::Datset] dataset @param [String] table @param [boolean] async @param [Hash] sidekiq_worker_options

# File lib/sidekiq/metrics/adapter/bigquery.rb, line 50
def initialize(dataset,
               table,
               with_suffix: false,
               async: false,
               raise_error: false,
               sidekiq_worker_options: {
                 queue: :default,
                 retry: 5
               })
  @dataset = dataset
  @table = table
  @with_suffix = with_suffix
  @async = async
  @raise_error = raise_error
  Worker.sidekiq_options(sidekiq_worker_options)

  Sidekiq::Metrics.configure do |config|
    config.excludes << Worker.name
  end
end

Public Instance Methods

table(suffix = nil) click to toggle source
# File lib/sidekiq/metrics/adapter/bigquery.rb, line 79
def table(suffix = nil)
  unless table = @dataset.table(table_id(suffix))
    # TODO: create table?
    raise 'Table not found'
  end
  table
end
table_id(suffix) click to toggle source
# File lib/sidekiq/metrics/adapter/bigquery.rb, line 87
def table_id(suffix)
  if @with_suffix
    "#{@table}#{suffix}"
  else
    @table
  end
end
write(worker_status) click to toggle source
# File lib/sidekiq/metrics/adapter/bigquery.rb, line 71
def write(worker_status)
  if @async
    Worker.perform_async(worker_status)
  else
    Worker.new.perform(worker_status)
  end
end