Class: Fluent::GithubActivitiesInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_github-activities.rb

Constant Summary collapse

DEFAULT_BASE_TAG =
"github-activity"

Instance Method Summary collapse

Constructor Details

#initializeGithubActivitiesInput

Returns a new instance of GithubActivitiesInput.



35
36
37
38
39
40
41
# File 'lib/fluent/plugin/in_github-activities.rb', line 35

def initialize
  super

  require "thread"
  require "pathname"
  require "fluent/plugin/github-activities"
end

Instance Method Details

#shutdownObject



66
67
68
# File 'lib/fluent/plugin/in_github-activities.rb', line 66

def shutdown
  @thread.exit
end

#startObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fluent/plugin/in_github-activities.rb', line 43

def start
  @base_tag = @base_tag.sub(/\.\z/, "")
  @thread = Thread.new do
    crawler_options = {
      :access_token => @access_token,
      :watching_users => prepare_users_list,
      :include_commits_from_pull_request => @include_commits_from_pull_request,
      :include_foreign_commits => @include_foreign_commits,
      :pos_file => @pos_file,
      :default_interval => @interval,
    }
    @crawler = ::Fluent::GithubActivities::Crawler.new(crawler_options)
    @crawler.on_emit = lambda do |tag, record|
      Engine.emit("#{@base_tag}.#{tag}", Engine.now, record)
    end

    loop do
      @crawler.process_request
      sleep(@crawler.interval_for_next_request)
    end
  end
end