fluent-plugin-zulip 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8c492b2c2284d81f89494a2f8627b269fba06772
4
- data.tar.gz: 2e4034d94b629adc71b551ed062a1d048c0512a1
2
+ SHA256:
3
+ metadata.gz: 4c5550a900e952282b33adf8dbcf3bc83c952edfdd23dc384fb5455eac5d9d5f
4
+ data.tar.gz: 89efb548af4c58dfd5fe811866cf9192eaeb4e2d8db164745ea46e993c73bad9
5
5
  SHA512:
6
- metadata.gz: 4c34389a79c8e7f34d9e7aaba5e9e9bc2c2cd531f0c57c4df92012f0545e07ea6e7c159c9dd3c731c8fa6f4ebc835035521840eaf296424ea0f400cef76493cd
7
- data.tar.gz: 0d38b190a61dab04421b7bcdf590edbfd0fb2550296ffb642f1b8f447f89a281c44b2368ac8b5ac188c967775de0daf2249341fe3212eb6415bc168df515796a
6
+ metadata.gz: aaa30b5fef8588d29771ce57ac95019e49f82b5a480c7bf0407f7022943aeedab44e70943b309bb500d6e356a0b5c800d9767337940df020d08a426d07c766e3
7
+ data.tar.gz: b0556c0e86c1463806aa8eb0a72a741e797dc831eb86f5e9194ed5a4f4912c214f0c2707fea1e9be370ca912d11cfe1dc4a96411d336262ccc9bf3d6bde046fd
data/README.md CHANGED
@@ -56,7 +56,7 @@ $ bundle
56
56
 
57
57
  ## Fluent::Plugin::ZulipOutput
58
58
 
59
- * **api_endpoint** (string) (required): API endpoint
59
+ * **site** (string) (required): Site URI
60
60
  * **bot_email_address** (string) (required): Bot email address
61
61
  * **bot_api_key** (string) (required): Bot API key
62
62
  * **message_type** (enum) (optional): Send message type
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-zulip"
6
- spec.version = "0.2.0"
6
+ spec.version = "0.3.0"
7
7
  spec.authors = ["Kenji Okimoto"]
8
8
  spec.email = ["okimoto@clear-code.com"]
9
9
 
@@ -24,7 +24,7 @@ module Fluent
24
24
  ZULIP_SUBJECT_MAX_SIZE = 60
25
25
  ZULIP_CONTENT_MAX_SIZE = 10000
26
26
 
27
- desc "API endpoint"
27
+ desc "Site URI. ex: https://zulip.exmaple.com/"
28
28
  config_param :site, :string
29
29
  desc "Bot email address"
30
30
  config_param :bot_email_address, :string
@@ -42,6 +42,15 @@ module Fluent
42
42
  config_param :subject_key, :string, default: nil
43
43
  desc "Content from record"
44
44
  config_param :content_key, :string, default: "message"
45
+ config_param :verify_ssl, :bool, default: true
46
+
47
+ config_section :buffer do
48
+ config_set_default :chunk_keys, ["tag"]
49
+ end
50
+
51
+ def multi_workers_ready?
52
+ true
53
+ end
45
54
 
46
55
  def configure(conf)
47
56
  super
@@ -63,20 +72,41 @@ module Fluent
63
72
 
64
73
  @client = Zulip::Client.new(site: @site,
65
74
  username: @bot_email_address,
66
- api_key: @bot_api_key)
75
+ api_key: @bot_api_key,
76
+ ssl: { verify: @verify_ssl })
67
77
  end
68
78
 
69
79
  def process(tag, es)
70
80
  es.each do |time, record|
81
+ process_record(tag, time, record)
82
+ end
83
+ end
84
+
85
+ def write(chunk)
86
+ tag = chunk.metadata.tag
87
+ chunk.each do |time, record|
88
+ process_record(tag, time, record)
89
+ end
90
+ end
91
+
92
+ def process_record(tag, time, record)
93
+ loop do
71
94
  response = send_message(tag, time, record)
72
- if response.success?
73
- log.info(response.body)
95
+ case
96
+ when response.success?
97
+ log.trace(response.body)
98
+ when response.status == 429
99
+ interval = response.headers["X-RateLimit-Reset"].to_i - Time.now.to_i
100
+ log.info("Sleeping: #{interval} sec")
101
+ sleep(interval)
102
+ next
74
103
  else
75
104
  log.error(status: response.status,
76
105
  message: response.reason_phrase,
77
106
  body: response.body)
78
107
  end
79
108
  log.debug(response)
109
+ break
80
110
  end
81
111
  end
82
112
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-zulip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Okimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-04 00:00:00.000000000 Z
11
+ date: 2018-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.6.11
139
+ rubygems_version: 2.7.3
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Fluentd output plugin for Zulip powerful open source group chat.