Class: Sumologic::Search::Job
- Inherits:
-
Object
- Object
- Sumologic::Search::Job
- Defined in:
- lib/sumologic/search/job.rb
Overview
Manages search job lifecycle: create, poll, fetch, delete
Instance Method Summary collapse
-
#execute(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Object
Execute a complete search workflow for raw messages Returns array of messages.
-
#execute_aggregation(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Object
Execute a complete search workflow for aggregation records Use this for queries with: count by, group by, etc.
-
#initialize(http_client:, config:) ⇒ Job
constructor
A new instance of Job.
Constructor Details
#initialize(http_client:, config:) ⇒ Job
Returns a new instance of Job.
10 11 12 13 14 15 16 |
# File 'lib/sumologic/search/job.rb', line 10 def initialize(http_client:, config:) @http = http_client @config = config @poller = Poller.new(http_client: http_client, config: config) = MessageFetcher.new(http_client: http_client, config: config) @record_fetcher = RecordFetcher.new(http_client: http_client, config: config) end |
Instance Method Details
#execute(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Object
Execute a complete search workflow for raw messages Returns array of messages
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sumologic/search/job.rb', line 20 def execute(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) job_id = create(query, from_time, to_time, time_zone) @poller.poll(job_id) = .fetch_all(job_id, limit: limit) delete(job_id) rescue StandardError => e delete(job_id) if job_id raise Error, "Search failed: #{e.message}" end |
#execute_aggregation(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) ⇒ Object
Execute a complete search workflow for aggregation records Use this for queries with: count by, group by, etc. Returns array of records
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sumologic/search/job.rb', line 34 def execute_aggregation(query:, from_time:, to_time:, time_zone: 'UTC', limit: nil) job_id = create(query, from_time, to_time, time_zone) @poller.poll(job_id) records = @record_fetcher.fetch_all(job_id, limit: limit) delete(job_id) records rescue StandardError => e delete(job_id) if job_id raise Error, "Search failed: #{e.message}" end |