fluent-plugin-feedly 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,7 +7,7 @@ Fluentd input plugin to fetch RSS/ATOM feed via feedly Cloud API.
7
7
  ## Dependencies
8
8
 
9
9
  * Ruby 1.9.3+
10
- * Fluentd 0.10.54+
10
+ * Fluentd 0.10.55+
11
11
 
12
12
  ## Installation
13
13
 
@@ -19,6 +19,9 @@ $ gem install fluent-plugin-feedly
19
19
 
20
20
  # for td-agent
21
21
  $ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-feedly
22
+
23
+ # for td-agent2
24
+ $ sudo td-agent-gem install fluent-plugin-feedly
22
25
  `````
23
26
 
24
27
  ## Configuration
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-feedly"
7
- spec.version = "0.0.2"
7
+ spec.version = "0.0.3"
8
8
  spec.authors = ["Kentaro Yoshida"]
9
9
  spec.email = ["y.ken.studio@gmail.com"]
10
10
  spec.summary = %q{Fluentd input plugin to fetch RSS/ATOM feed via feedly Cloud API.}
@@ -35,13 +35,11 @@ module Fluent
35
35
 
36
36
  @client = Feedlr::Client.new(
37
37
  oauth_access_token: @access_token,
38
- sandbox: @enable_sandbox,
38
+ sandbox: @enable_sandbox
39
39
  )
40
40
  end
41
41
 
42
42
  def start
43
- @profile_id = @client.user_profile.id
44
- @state_store = StateStore.new(@state_file)
45
43
  @thread = Thread.new(&method(:run))
46
44
  end
47
45
 
@@ -54,26 +52,32 @@ module Fluent
54
52
  loop do
55
53
  begin
56
54
  fetch
55
+ rescue Feedlr::Error::Unauthorized, Feedlr::Error::Forbidden => e
56
+ log.error "Feedly: unrecoverable error has occoured.", error: e.message, error_class: e.class
57
+ log.error_backtrace e.backtrace
58
+ break
57
59
  rescue => e
58
- log.error "Feedly: unexpected error has occoured.", error: e.message, error_class: e.class
60
+ log.error "Feedly: error has occoured. trying to retry after #{@run_interval} seconds.", error: e.message, error_class: e.class
59
61
  log.error_backtrace e.backtrace
60
62
  sleep @run_interval
61
63
  retry
62
64
  end
63
65
  sleep @run_interval
64
66
  end
67
+ log.error "Feedly: stopped fetching process due to the previous error."
65
68
  end
66
69
 
67
70
  def fetch
71
+ @profile_id ||= @client.user_profile.id
72
+ @state_store ||= StateStore.new(@state_file)
68
73
  @subscribe_categories.each do |category_name|
69
74
  category_id = "user/#{@profile_id}/category/#{category_name}"
70
75
  fetch_time_range = get_fetch_time_range
71
- loop {
76
+ loop do
72
77
  request_option = { count: @fetch_count, continuation: get_continuation_id, newerThan: fetch_time_range }
73
78
  cursor = @client.stream_entries_contents(category_id, request_option)
74
79
  if cursor.items.nil?
75
- log.error "Feedly: unexpected error has occoured.", cursor: cursor
76
- break
80
+ return raise Feedlr::Error::ServerError, cursor
77
81
  end
78
82
  cursor.items.each do |item|
79
83
  Engine.emit(@tag, Engine.now, item)
@@ -81,7 +85,7 @@ module Fluent
81
85
  log.info "Feedly: fetched articles.", articles: cursor.items.size, request_option: request_option
82
86
  set_continuation_id(cursor.continuation)
83
87
  break if get_continuation_id.nil?
84
- }
88
+ end
85
89
  end
86
90
  end
87
91
 
@@ -150,3 +154,4 @@ module Fluent
150
154
  end
151
155
  end
152
156
  end
157
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-feedly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-17 00:00:00.000000000 Z
12
+ date: 2014-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd