embulk-output-mailchimp 0.3.22 → 0.3.23
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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +3 -0
- data/README.md +2 -0
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/output/mailchimp/MailChimpOutputPluginDelegate.java +18 -2
- data/src/main/java/org/embulk/output/mailchimp/MailChimpRecordBuffer.java +3 -2
- data/src/test/java/org/embulk/output/mailchimp/TestMailChimpOutputPlugin.java +6 -0
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f18ee80430139a3e22677d7e18e3fd80eed89665
|
4
|
+
data.tar.gz: 1c3ebcd7abeaae441d926103f0920ca7d5d6ac6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae75be9b1e060a13d6f0bcb4dfa71cea026f653832944bbcfd023df5987b819407decfac00fbdb84c8f31431c7c30dfe1dd8f2b16dcfa47f813ada7a93ba8a64
|
7
|
+
data.tar.gz: 960ede6f290226c7f35d3d2554175669e14db0a2ecc8ec89f87a8e2548b63f4438b54651f1e04a5a4122853709473a8a15acbae35e5f9e654cda87a62b062200
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 0.3.23 - 2018-09-12
|
2
|
+
- Introduce an option to fail the job when there is an error returning from Mailchimp. Previous versions marked the job as success with
|
3
|
+
detail error in log
|
1
4
|
## 0.3.22 - 2018-03-07
|
2
5
|
- Fixed bug NPE when checking interest categories [#41](https://github.com/treasure-data/embulk-output-mailchimp/pull/41)
|
3
6
|
|
data/README.md
CHANGED
@@ -25,6 +25,7 @@ add e-mail to List in MailChimp.
|
|
25
25
|
- **grouping_columns**: Array for group names in MailChimp dashboard(array, default: nil)
|
26
26
|
- **language_column**: column name for language (string, optional, default: nil)
|
27
27
|
- **double_optin**: control whether to send an opt-in confirmation email (boolean, default: true)
|
28
|
+
- **atomic_upsert** : Control the atomicity for the job. Job will be marked as success only when there is no error from Mailchimp. Default as false.
|
28
29
|
- **max_records_per_request**: The max records per batch request. MailChimp API enables max records is 500 per batch request (int, default: 500)
|
29
30
|
- **sleep_between_requests_millis**: The time to sleep between requests to avoid flood MailChimp API (int, default: 3000)
|
30
31
|
|
@@ -38,6 +39,7 @@ out:
|
|
38
39
|
list_id: 'XXXXXXXXXX'
|
39
40
|
update_existing: false
|
40
41
|
double_optin: false
|
42
|
+
atomic_upsert: false
|
41
43
|
email_column: e-mail
|
42
44
|
fname_column: first name
|
43
45
|
lname_column: lname
|
data/build.gradle
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
package org.embulk.output.mailchimp;
|
2
2
|
|
3
3
|
import com.google.common.base.Optional;
|
4
|
+
import com.google.common.base.Throwables;
|
4
5
|
import org.embulk.base.restclient.RestClientOutputPluginDelegate;
|
5
6
|
import org.embulk.base.restclient.RestClientOutputTaskBase;
|
6
7
|
import org.embulk.base.restclient.jackson.JacksonServiceRequestMapper;
|
@@ -13,6 +14,7 @@ import org.embulk.config.ConfigDiff;
|
|
13
14
|
import org.embulk.config.ConfigException;
|
14
15
|
import org.embulk.config.TaskReport;
|
15
16
|
import org.embulk.output.mailchimp.model.AuthMethod;
|
17
|
+
import org.embulk.spi.DataException;
|
16
18
|
import org.embulk.spi.Exec;
|
17
19
|
import org.embulk.spi.Schema;
|
18
20
|
import org.slf4j.Logger;
|
@@ -96,6 +98,10 @@ public class MailChimpOutputPluginDelegate
|
|
96
98
|
@ConfigDefault("false")
|
97
99
|
boolean getUpdateExisting();
|
98
100
|
|
101
|
+
@Config("atomic_upsert")
|
102
|
+
@ConfigDefault("false")
|
103
|
+
boolean getAtomicUpsert();
|
104
|
+
|
99
105
|
@Config("replace_interests")
|
100
106
|
@ConfigDefault("true")
|
101
107
|
boolean getReplaceInterests();
|
@@ -146,6 +152,9 @@ public class MailChimpOutputPluginDelegate
|
|
146
152
|
if (!checkExistColumns(schema, task.getEmailColumn(), task.getFnameColumn(), task.getLnameColumn())) {
|
147
153
|
throw new ConfigException("Columns ['email', 'fname', 'lname'] must not be null or empty string");
|
148
154
|
}
|
155
|
+
if (task.getAtomicUpsert()) {
|
156
|
+
LOG.info(" Treating upsert as atomic operation");
|
157
|
+
}
|
149
158
|
}
|
150
159
|
|
151
160
|
@Override
|
@@ -167,14 +176,21 @@ public class MailChimpOutputPluginDelegate
|
|
167
176
|
final List<TaskReport> taskReports)
|
168
177
|
{
|
169
178
|
long totalInserted = 0;
|
179
|
+
int totalError = 0;
|
170
180
|
for (TaskReport taskReport : taskReports) {
|
171
181
|
if (taskReport.has("pushed")) {
|
172
182
|
totalInserted += taskReport.get(Long.class, "pushed");
|
173
183
|
}
|
184
|
+
if (taskReport.has("error_count")) {
|
185
|
+
totalError += taskReport.get(Integer.class, "error_count");
|
186
|
+
}
|
174
187
|
}
|
175
|
-
|
176
188
|
LOG.info("Pushed completed. {} records", totalInserted);
|
177
|
-
|
189
|
+
// When atomic upsert is true, client expects all records are done properly.
|
190
|
+
if (task.getAtomicUpsert() && totalError > 0) {
|
191
|
+
LOG.info("Job requires atomic operation for all records. And there were {} errors in processing => Error as job's status", totalError);
|
192
|
+
throw Throwables.propagate(new DataException("Some records are not properly processed at MailChimp. See log for detail"));
|
193
|
+
}
|
178
194
|
return Exec.newConfigDiff();
|
179
195
|
}
|
180
196
|
}
|
@@ -54,6 +54,7 @@ public class MailChimpRecordBuffer
|
|
54
54
|
private final ObjectMapper mapper;
|
55
55
|
private final Schema schema;
|
56
56
|
private int requestCount;
|
57
|
+
private int errorCount;
|
57
58
|
private long totalCount;
|
58
59
|
private List<JsonNode> records;
|
59
60
|
private Map<String, Map<String, InterestResponse>> categories;
|
@@ -129,8 +130,7 @@ public class MailChimpRecordBuffer
|
|
129
130
|
uniqueRecords = new ArrayList<>();
|
130
131
|
duplicatedRecords = new ArrayList<>();
|
131
132
|
}
|
132
|
-
|
133
|
-
return Exec.newTaskReport().set("pushed", totalCount);
|
133
|
+
return Exec.newTaskReport().set("pushed", totalCount).set("error_count", errorCount);
|
134
134
|
}
|
135
135
|
catch (JsonProcessingException jpe) {
|
136
136
|
throw new DataException(jpe);
|
@@ -304,6 +304,7 @@ public class MailChimpRecordBuffer
|
|
304
304
|
records.size(), reportResponse.getTotalCreated(),
|
305
305
|
reportResponse.getTotalUpdated(),
|
306
306
|
reportResponse.getErrorCount(), System.currentTimeMillis() - startTime);
|
307
|
+
errorCount += reportResponse.getErrors().size();
|
307
308
|
mailChimpClient.handleErrors(reportResponse.getErrors());
|
308
309
|
|
309
310
|
mailChimpClient.avoidFloodAPI("Process next request", task.getSleepBetweenRequestsMillis());
|
@@ -98,6 +98,12 @@ public class TestMailChimpOutputPlugin
|
|
98
98
|
ConfigSource config = baseConfig.set("list_id", "");
|
99
99
|
doSetUpSchemaAndRun(config, plugin);
|
100
100
|
}
|
101
|
+
@Test(expected = ConfigException.class)
|
102
|
+
public void test_config_atomicUpsert()
|
103
|
+
{
|
104
|
+
ConfigSource config = baseConfig.set("atomic_upsert", true);
|
105
|
+
doSetUpSchemaAndRun(config, plugin);
|
106
|
+
}
|
101
107
|
|
102
108
|
@Test(expected = ConfigException.class)
|
103
109
|
public void test_config_invalidWithColumnEmailRequires()
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-output-mailchimp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thang Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
14
|
requirement: !ruby/object:Gem::Requirement
|
21
15
|
requirements:
|
22
16
|
- - ~>
|
23
17
|
- !ruby/object:Gem::Version
|
24
18
|
version: '1.0'
|
19
|
+
name: bundler
|
25
20
|
prerelease: false
|
26
21
|
type: :development
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
22
|
version_requirements: !ruby/object:Gem::Requirement
|
30
23
|
requirements:
|
31
|
-
- -
|
24
|
+
- - ~>
|
32
25
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
34
28
|
requirement: !ruby/object:Gem::Requirement
|
35
29
|
requirements:
|
36
30
|
- - '>='
|
37
31
|
- !ruby/object:Gem::Version
|
38
32
|
version: '10.0'
|
33
|
+
name: rake
|
39
34
|
prerelease: false
|
40
35
|
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
41
|
description: Dumps records to MailChimp.
|
42
42
|
email:
|
43
43
|
- thang@treasure-data.com
|
@@ -88,13 +88,13 @@ files:
|
|
88
88
|
- test/embulk/output/test_mailchimp.rb
|
89
89
|
- test/override_assert_raise.rb
|
90
90
|
- test/run-test.rb
|
91
|
-
- classpath/jetty-io-9.2.14.v20151106.jar
|
92
|
-
- classpath/jetty-util-9.2.14.v20151106.jar
|
93
|
-
- classpath/embulk-output-mailchimp-0.3.22.jar
|
94
|
-
- classpath/jetty-http-9.2.14.v20151106.jar
|
95
|
-
- classpath/jetty-client-9.2.14.v20151106.jar
|
96
91
|
- classpath/embulk-base-restclient-0.5.3.jar
|
92
|
+
- classpath/embulk-output-mailchimp-0.3.23.jar
|
97
93
|
- classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
|
94
|
+
- classpath/jetty-client-9.2.14.v20151106.jar
|
95
|
+
- classpath/jetty-http-9.2.14.v20151106.jar
|
96
|
+
- classpath/jetty-io-9.2.14.v20151106.jar
|
97
|
+
- classpath/jetty-util-9.2.14.v20151106.jar
|
98
98
|
homepage: https://github.com/treasure-data/embulk-output-mailchimp
|
99
99
|
licenses:
|
100
100
|
- MIT
|