class AzureQuery

Public Class Methods

new(logger, azure_table_service, table_name, query_str, query_id, entity_count_to_process) click to toggle source
# File lib/logstash/inputs/azurenlogtable.rb, line 167
def initialize(logger, azure_table_service, table_name, query_str, query_id, entity_count_to_process)
  @logger = logger
  @query_str = query_str
  @query_id = query_id
  @entity_count_to_process = entity_count_to_process
  @azure_table_service = azure_table_service
  @table_name = table_name
  @continuation_token = nil
end

Public Instance Methods

id() click to toggle source
# File lib/logstash/inputs/azurenlogtable.rb, line 181
def id
  return @query_id
end
reset() click to toggle source
# File lib/logstash/inputs/azurenlogtable.rb, line 177
def reset
  @continuation_token = nil
end
run(on_result_cbk) click to toggle source
# File lib/logstash/inputs/azurenlogtable.rb, line 185
def run(on_result_cbk)
  results_found = false
  @logger.debug("[#{@query_id}]Query filter: " + @query_str)
  begin
    @logger.debug("[#{@query_id}]Running query. continuation_token: #{@continuation_token}")
    query = { :top => @entity_count_to_process, :filter => @query_str, :continuation_token => @continuation_token }
    result = @azure_table_service.query_entities(@table_name, query)

    if result and result.length > 0
      results_found = true
      @logger.debug("[#{@query_id}] #{result.length} results found.")
      result.each do |entity|
        on_result_cbk.call(entity)
      end
    end

    @continuation_token = result.continuation_token
  end until !@continuation_token

  return results_found
end