You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/10/29 06:50:19 UTC

[GitHub] [incubator-seatunnel] 18391713434 opened a new pull request, #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

18391713434 opened a new pull request, #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   
   ## Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   Slack sink connector https://github.com/apache/incubator-seatunnel/issues/3018
   
   ## Check list
   
   * [x] Code changed are covered with tests, or it does not need tests for reason:
   * [x] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1013537107


##########
tools/dependencies/known-dependencies.txt:
##########
@@ -105,4 +105,4 @@ snappy-java-1.1.1.3.jar
 snappy-java-1.1.7.1.jar
 snappy-java-1.1.8.3.jar
 ssl-config-core_2.11-0.3.7.jar
-xz-1.5.jar
\ No newline at end of file
+xz-1.5.jar

Review Comment:
   Why update this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1013636628


##########
tools/dependencies/known-dependencies.txt:
##########
@@ -1,108 +0,0 @@
-aircompressor-0.10.jar

Review Comment:
   Delete this file carelessly, which has been reverted.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1008778839


##########
docs/en/connector-v2/sink/Slack.md:
##########
@@ -0,0 +1,57 @@
+# Slack
+
+> Slack sink connector
+
+## Description
+
+Used to send data to Slack Channel. Both support streaming and batch mode.
+> For example, if the data from upstream is [`age: 12, name: huan`], the content send to socket server is the following: `{"name":"huan","age":17}`
+
+
+## Key features
+
+- [ ] [exactly-once](../../concept/connector-v2-features.md)
+- [ ] [schema projection](../../concept/connector-v2-features.md)
+
+## Options
+
+| name           | type   | required | default value |
+| -------------- |--------|----------|---------------|
+| webhooks_url   | String | Yes      | -             |
+| oauth_token    | String | Yes      | -             |
+| slack_channel  | String | Yes      | -             |
+| common-options |        | no       | -             |
+
+### webhooks_url [string]
+
+Slack webhook url
+
+### oauth_token [string]
+
+Slack oauth token used for the actual authentication
+
+### slack_channel [string]
+
+slack channel for data write
+
+### common options
+
+Sink plugin common parameters, please refer to [Sink Common Options](common-options.md) for details
+
+## Example
+
+```hocon
+sink {
+ SlackSink {
+  webhooks_url = "https://hooks.slack.com/services/xxxxxxxxxxxx/xxxxxxxxxxxx/xxxxxxxxxxxxxxxx"
+  oauth_token = "xoxp-xxxxxxxxxx-xxxxxxxx-xxxxxxxxx-xxxxxxxxxxx"
+  slack_channel = "channel name"
+ }
+}
+```
+
+## Changelog
+
+### 2.3.0-beta 2022-10-20

Review Comment:
   Could you please tell me how long will the new version be released?Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1019817707


##########
seatunnel-dist/pom.xml:
##########
@@ -677,7 +677,7 @@
                     <version>${project.version}</version>
                     <scope>provided</scope>
                 </dependency>
-                
+

Review Comment:
   I have added it! PTAL



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1008778839


##########
docs/en/connector-v2/sink/Slack.md:
##########
@@ -0,0 +1,57 @@
+# Slack
+
+> Slack sink connector
+
+## Description
+
+Used to send data to Slack Channel. Both support streaming and batch mode.
+> For example, if the data from upstream is [`age: 12, name: huan`], the content send to socket server is the following: `{"name":"huan","age":17}`
+
+
+## Key features
+
+- [ ] [exactly-once](../../concept/connector-v2-features.md)
+- [ ] [schema projection](../../concept/connector-v2-features.md)
+
+## Options
+
+| name           | type   | required | default value |
+| -------------- |--------|----------|---------------|
+| webhooks_url   | String | Yes      | -             |
+| oauth_token    | String | Yes      | -             |
+| slack_channel  | String | Yes      | -             |
+| common-options |        | no       | -             |
+
+### webhooks_url [string]
+
+Slack webhook url
+
+### oauth_token [string]
+
+Slack oauth token used for the actual authentication
+
+### slack_channel [string]
+
+slack channel for data write
+
+### common options
+
+Sink plugin common parameters, please refer to [Sink Common Options](common-options.md) for details
+
+## Example
+
+```hocon
+sink {
+ SlackSink {
+  webhooks_url = "https://hooks.slack.com/services/xxxxxxxxxxxx/xxxxxxxxxxxx/xxxxxxxxxxxxxxxx"
+  oauth_token = "xoxp-xxxxxxxxxx-xxxxxxxx-xxxxxxxxx-xxxxxxxxxxx"
+  slack_channel = "channel name"
+ }
+}
+```
+
+## Changelog
+
+### 2.3.0-beta 2022-10-20

Review Comment:
   Could you please tell me how long before the new version be released?Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1013582202


##########
tools/dependencies/known-dependencies.txt:
##########
@@ -105,4 +105,4 @@ snappy-java-1.1.1.3.jar
 snappy-java-1.1.7.1.jar
 snappy-java-1.1.8.3.jar
 ssl-config-core_2.11-0.3.7.jar
-xz-1.5.jar
\ No newline at end of file
+xz-1.5.jar

Review Comment:
   This update has been reverted.Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] hailin0 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
hailin0 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1013772576


##########
tools/dependencies/known-dependencies.txt:
##########
@@ -1,108 +0,0 @@
-aircompressor-0.10.jar

Review Comment:
   good



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1014271370


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private StringBuffer stringBuffer;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.stringBuffer = new StringBuffer();
+        this.slackClient = new SlackClient(slackConfig);
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+
+        for (Object field : fields) {
+            stringBuffer.append(field.toString() + ",");
+        }
+        stringBuffer.deleteCharAt(fields.length - 1);
+        stringBuffer.append("\n");

Review Comment:
   Thanks for your advice. it's a great idea!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#issuecomment-1304750799

   > If no e2e test is added, you need to comment your local test process and results in the form of pictures, etc. Convenient for later use.
   
   Spark Local Test
   
   <img src="https://imagehost-1311381309.cos.ap-nanjing.myqcloud.com/Snipaste_2022-11-06_16-56-38.jpg"/>
   
   <img src="https://imagehost-1311381309.cos.ap-nanjing.myqcloud.com/Snipaste_2022-11-06_16-56-47.jpg"/>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1008778839


##########
docs/en/connector-v2/sink/Slack.md:
##########
@@ -0,0 +1,57 @@
+# Slack
+
+> Slack sink connector
+
+## Description
+
+Used to send data to Slack Channel. Both support streaming and batch mode.
+> For example, if the data from upstream is [`age: 12, name: huan`], the content send to socket server is the following: `{"name":"huan","age":17}`
+
+
+## Key features
+
+- [ ] [exactly-once](../../concept/connector-v2-features.md)
+- [ ] [schema projection](../../concept/connector-v2-features.md)
+
+## Options
+
+| name           | type   | required | default value |
+| -------------- |--------|----------|---------------|
+| webhooks_url   | String | Yes      | -             |
+| oauth_token    | String | Yes      | -             |
+| slack_channel  | String | Yes      | -             |
+| common-options |        | no       | -             |
+
+### webhooks_url [string]
+
+Slack webhook url
+
+### oauth_token [string]
+
+Slack oauth token used for the actual authentication
+
+### slack_channel [string]
+
+slack channel for data write
+
+### common options
+
+Sink plugin common parameters, please refer to [Sink Common Options](common-options.md) for details
+
+## Example
+
+```hocon
+sink {
+ SlackSink {
+  webhooks_url = "https://hooks.slack.com/services/xxxxxxxxxxxx/xxxxxxxxxxxx/xxxxxxxxxxxxxxxx"
+  oauth_token = "xoxp-xxxxxxxxxx-xxxxxxxx-xxxxxxxxx-xxxxxxxxxxx"
+  slack_channel = "channel name"
+ }
+}
+```
+
+## Changelog
+
+### 2.3.0-beta 2022-10-20

Review Comment:
   Could you please tell me how long before the new version be released?Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1020830007


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    private static final String WEBHOOKS_URL = "webhooks_url";
+    private static final String OAUTH_TOKEN = "oauth_token";
+    private static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {

Review Comment:
   Thanks for your advice, I have done it!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] TyrantLucifer commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
TyrantLucifer commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1027031809


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/slack/exception/SlackConnectorErrorCode.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.slack.exception;
+
+import org.apache.seatunnel.common.exception.SeaTunnelErrorCode;
+
+public enum SlackConnectorErrorCode implements SeaTunnelErrorCode {
+    FIND_SLACK_CONVERSATION_FAILED("SLACK-01", "Conversation can not be founded in channels"),
+    WRITE_TO_SLACK_CHANNEL_FAILED("SLACK-02", "Write to slack channel failed");
+
+    private final String code;
+
+    private final String description;
+
+    SlackConnectorErrorCode(String code, String description) {
+        this.code = code;
+        this.description = description;
+    }
+
+    @Override
+    public String getCode() {
+        return null;

Review Comment:
   return code



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/slack/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.slack.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.slack.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.slack.exception.SlackConnectorErrorCode;
+import org.apache.seatunnel.connectors.seatunnel.slack.exception.SlackConnectorException;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.StringJoiner;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private final String conversationId;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+    private static final long POST_MSG_WAITING_TIME = 1500L;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.slackClient = new SlackClient(pluginConfig);
+        this.conversationId = slackClient.findConversation();
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+        StringJoiner stringJoiner = new StringJoiner(",", "", "\n");
+        for (Object field : fields) {
+            stringJoiner.add(String.valueOf(field));
+        }
+        String message = stringJoiner.toString();
+        try {
+            slackClient.publishMessage(conversationId, message);
+            // Slack has a limit on the frequency of sending messages
+            // One message can be sent as soon as one second
+            Thread.sleep(POST_MSG_WAITING_TIME);
+        } catch (Exception e) {
+            log.warn("Write to Slack Fail.", ExceptionUtils.getMessage(e));

Review Comment:
   ```suggestion
               log.error("Write to Slack Fail.", ExceptionUtils.getMessage(e));
   ```



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/slack/exception/SlackConnectorErrorCode.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.slack.exception;
+
+import org.apache.seatunnel.common.exception.SeaTunnelErrorCode;
+
+public enum SlackConnectorErrorCode implements SeaTunnelErrorCode {
+    FIND_SLACK_CONVERSATION_FAILED("SLACK-01", "Conversation can not be founded in channels"),
+    WRITE_TO_SLACK_CHANNEL_FAILED("SLACK-02", "Write to slack channel failed");
+
+    private final String code;
+
+    private final String description;
+
+    SlackConnectorErrorCode(String code, String description) {
+        this.code = code;
+        this.description = description;
+    }
+
+    @Override
+    public String getCode() {
+        return null;
+    }
+
+    @Override
+    public String getDescription() {
+        return null;

Review Comment:
   return description



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/slack/sink/SlackSink.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.slack.sink;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.common.SeaTunnelAPIErrorCode;
+import org.apache.seatunnel.api.sink.SeaTunnelSink;
+import org.apache.seatunnel.api.sink.SinkWriter;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.config.CheckResult;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSimpleSink;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.slack.config.SlackConfig;
+import org.apache.seatunnel.connectors.seatunnel.slack.exception.SlackConnectorException;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.auto.service.AutoService;
+
+import java.io.IOException;
+
+
+
+/**
+ * Slack sink class
+ */
+@AutoService(SeaTunnelSink.class)
+public class SlackSink extends AbstractSimpleSink<SeaTunnelRow, Void> {
+
+    private Config pluginConfig;
+    private SeaTunnelRowType seaTunnelRowType;

Review Comment:
   ```suggestion
       private final SeaTunnelRowType seaTunnelRowType;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1020829891


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.StringJoiner;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private final String conversationId;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+    private static final long POST_MSG_WAITING_TIME = 1500L;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.slackClient = new SlackClient(slackConfig);
+        this.conversationId = slackClient.findConversation();
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+        StringJoiner stringJoiner = new StringJoiner(",", "", "\n");
+        for (Object field : fields) {
+            stringJoiner.add(String.valueOf(field));
+        }
+        String message = stringJoiner.toString();
+        try {
+            slackClient.publishMessage(conversationId, message);
+            // Slack has a limit on the frequency of sending messages
+            // One message can be sent as soon as one second
+            Thread.sleep(POST_MSG_WAITING_TIME);
+        } catch (Exception e) {
+            log.warn("Write to Slack Fail.", e);

Review Comment:
   I have fixed it! Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] hailin0 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
hailin0 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1013628447


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private StringBuffer stringBuffer;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.stringBuffer = new StringBuffer();
+        this.slackClient = new SlackClient(slackConfig);
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+
+        for (Object field : fields) {
+            stringBuffer.append(field.toString() + ",");
+        }
+        stringBuffer.deleteCharAt(fields.length - 1);
+        stringBuffer.append("\n");

Review Comment:
   suggestion
   
   ```java
           StringJoiner stringJoiner = new StringJoiner(",", "", "\n");
           for (Object field : fields) {
               stringJoiner.add(field.toString());
           }
           String message = stringJoiner.toString();
   ```
   
   
   If you reuse StringBuffer objects, you need to clean up the previous content



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private StringBuffer stringBuffer;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.stringBuffer = new StringBuffer();
+        this.slackClient = new SlackClient(slackConfig);
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+
+        for (Object field : fields) {
+            stringBuffer.append(field.toString() + ",");
+        }
+        stringBuffer.deleteCharAt(fields.length - 1);
+        stringBuffer.append("\n");
+        try {
+            String conversationId = slackClient.findConversation();

Review Comment:
   Does `findConversation` need to be executed before each message is sent?



##########
tools/dependencies/known-dependencies.txt:
##########
@@ -1,108 +0,0 @@
-aircompressor-0.10.jar

Review Comment:
   revert
   
   Why delete this file?
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1014269116


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private StringBuffer stringBuffer;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.stringBuffer = new StringBuffer();
+        this.slackClient = new SlackClient(slackConfig);
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+
+        for (Object field : fields) {
+            stringBuffer.append(field.toString() + ",");
+        }
+        stringBuffer.deleteCharAt(fields.length - 1);
+        stringBuffer.append("\n");
+        try {
+            String conversationId = slackClient.findConversation();

Review Comment:
   I have fixed it! thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1014269116


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private StringBuffer stringBuffer;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.stringBuffer = new StringBuffer();
+        this.slackClient = new SlackClient(slackConfig);
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+
+        for (Object field : fields) {
+            stringBuffer.append(field.toString() + ",");
+        }
+        stringBuffer.deleteCharAt(fields.length - 1);
+        stringBuffer.append("\n");
+        try {
+            String conversationId = slackClient.findConversation();

Review Comment:
   I have fixed it! PTAL



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1008778839


##########
docs/en/connector-v2/sink/Slack.md:
##########
@@ -0,0 +1,57 @@
+# Slack
+
+> Slack sink connector
+
+## Description
+
+Used to send data to Slack Channel. Both support streaming and batch mode.
+> For example, if the data from upstream is [`age: 12, name: huan`], the content send to socket server is the following: `{"name":"huan","age":17}`
+
+
+## Key features
+
+- [ ] [exactly-once](../../concept/connector-v2-features.md)
+- [ ] [schema projection](../../concept/connector-v2-features.md)
+
+## Options
+
+| name           | type   | required | default value |
+| -------------- |--------|----------|---------------|
+| webhooks_url   | String | Yes      | -             |
+| oauth_token    | String | Yes      | -             |
+| slack_channel  | String | Yes      | -             |
+| common-options |        | no       | -             |
+
+### webhooks_url [string]
+
+Slack webhook url
+
+### oauth_token [string]
+
+Slack oauth token used for the actual authentication
+
+### slack_channel [string]
+
+slack channel for data write
+
+### common options
+
+Sink plugin common parameters, please refer to [Sink Common Options](common-options.md) for details
+
+## Example
+
+```hocon
+sink {
+ SlackSink {
+  webhooks_url = "https://hooks.slack.com/services/xxxxxxxxxxxx/xxxxxxxxxxxx/xxxxxxxxxxxxxxxx"
+  oauth_token = "xoxp-xxxxxxxxxx-xxxxxxxx-xxxxxxxxx-xxxxxxxxxxx"
+  slack_channel = "channel name"
+ }
+}
+```
+
+## Changelog
+
+### 2.3.0-beta 2022-10-20

Review Comment:
   Could you please tell me how long the new version will be released?Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1009419355


##########
docs/en/connector-v2/sink/Slack.md:
##########
@@ -0,0 +1,57 @@
+# Slack
+
+> Slack sink connector
+
+## Description
+
+Used to send data to Slack Channel. Both support streaming and batch mode.
+> For example, if the data from upstream is [`age: 12, name: huan`], the content send to socket server is the following: `{"name":"huan","age":17}`
+
+
+## Key features
+
+- [ ] [exactly-once](../../concept/connector-v2-features.md)
+- [ ] [schema projection](../../concept/connector-v2-features.md)
+
+## Options
+
+| name           | type   | required | default value |
+| -------------- |--------|----------|---------------|
+| webhooks_url   | String | Yes      | -             |
+| oauth_token    | String | Yes      | -             |
+| slack_channel  | String | Yes      | -             |
+| common-options |        | no       | -             |
+
+### webhooks_url [string]
+
+Slack webhook url
+
+### oauth_token [string]
+
+Slack oauth token used for the actual authentication
+
+### slack_channel [string]
+
+slack channel for data write
+
+### common options
+
+Sink plugin common parameters, please refer to [Sink Common Options](common-options.md) for details
+
+## Example
+
+```hocon
+sink {
+ SlackSink {
+  webhooks_url = "https://hooks.slack.com/services/xxxxxxxxxxxx/xxxxxxxxxxxx/xxxxxxxxxxxxxxxx"
+  oauth_token = "xoxp-xxxxxxxxxx-xxxxxxxx-xxxxxxxxx-xxxxxxxxxxx"
+  slack_channel = "channel name"
+ }
+}
+```
+
+## Changelog
+
+### 2.3.0-beta 2022-10-20

Review Comment:
   I have done it!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1020829864


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/client/SlackClient.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.client;
+
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import com.slack.api.Slack;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.conversations.ConversationsListResponse;
+import com.slack.api.model.Conversation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+public class SlackClient {
+    private SlackConfig slackConfig;
+    private MethodsClient methodsClient;
+
+    public SlackClient(SlackConfig slackConfig) {
+        this.slackConfig = slackConfig;
+        this.methodsClient = Slack.getInstance().methods();
+    }
+
+    /**
+     * Find conversation ID using the conversations.list method
+     */
+    public String findConversation() {
+        String conversionId = "";
+        List<Conversation> channels;
+        try {
+            // Get Conversion List
+            ConversationsListResponse conversationsListResponse = methodsClient.conversationsList(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+            );
+            channels = conversationsListResponse.getChannels();
+            for (Conversation channel : channels) {
+                if (channel.getName().equals(slackConfig.getSlackChannel())) {
+                    conversionId = channel.getId();
+                    // Break from for loop
+                    break;
+                }
+            }
+        } catch (IOException | SlackApiException e) {
+            log.warn("Find Slack Conversion Fail.", e);
+            throw new RuntimeException("Find Slack Conversion Fail.", e);
+        }
+        return conversionId;
+    }
+
+    /**
+     * Post a message to a channel using Channel ID and message text
+     */
+    public boolean publishMessage(String channelId, String text) {
+        boolean publishMessageSuccess = false;
+        try {
+            ChatPostMessageResponse chatPostMessageResponse = methodsClient.chatPostMessage(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+                .channel(channelId)
+                .text(text)
+            );
+            publishMessageSuccess = chatPostMessageResponse.isOk();
+        } catch (IOException | SlackApiException e) {
+            log.error("error: {}", e.getMessage(), e);

Review Comment:
   I have fixed it! Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1022705531


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    public static final String WEBHOOKS_URL = "webhooks_url";
+    public static final String OAUTH_TOKEN = "oauth_token";
+    public static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {
+            this.webHooksUrl = pluginConfig.getString(WEBHOOKS_URL);
+        }
+        if (pluginConfig.hasPath(OAUTH_TOKEN)) {

Review Comment:
   Thanks for your reminder.



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    public static final String WEBHOOKS_URL = "webhooks_url";
+    public static final String OAUTH_TOKEN = "oauth_token";
+    public static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {
+            this.webHooksUrl = pluginConfig.getString(WEBHOOKS_URL);
+        }
+        if (pluginConfig.hasPath(OAUTH_TOKEN)) {
+            this.oauthToken = pluginConfig.getString(OAUTH_TOKEN);
+        }
+        if (pluginConfig.hasPath(SLACK_CHANNEL)) {

Review Comment:
   Thx



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1026996376


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/client/SlackClient.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.client;
+
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import com.slack.api.Slack;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.conversations.ConversationsListResponse;
+import com.slack.api.model.Conversation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+public class SlackClient {
+    private SlackConfig slackConfig;
+    private MethodsClient methodsClient;
+
+    public SlackClient(SlackConfig slackConfig) {
+        this.slackConfig = slackConfig;
+        this.methodsClient = Slack.getInstance().methods();
+    }
+
+    /**
+     * Find conversation ID using the conversations.list method
+     */
+    public String findConversation() {
+        String conversionId = "";
+        List<Conversation> channels;
+        try {
+            // Get Conversion List
+            ConversationsListResponse conversationsListResponse = methodsClient.conversationsList(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+            );
+            channels = conversationsListResponse.getChannels();
+            for (Conversation channel : channels) {
+                if (channel.getName().equals(slackConfig.getSlackChannel())) {
+                    conversionId = channel.getId();
+                    // Break from for loop
+                    break;
+                }
+            }
+        } catch (IOException | SlackApiException e) {
+            log.warn("Find Slack Conversion Fail.", e);
+            throw new RuntimeException("Find Slack Conversion Fail.", e);
+        }
+        return conversionId;
+    }
+
+    /**
+     * Post a message to a channel using Channel ID and message text
+     */
+    public boolean publishMessage(String channelId, String text) {
+        boolean publishMessageSuccess = false;
+        try {
+            ChatPostMessageResponse chatPostMessageResponse = methodsClient.chatPostMessage(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+                .channel(channelId)
+                .text(text)
+            );
+            publishMessageSuccess = chatPostMessageResponse.isOk();
+        } catch (IOException | SlackApiException e) {
+            log.error("error: {}", ExceptionUtils.getMessage(e));
+        }
+        return publishMessageSuccess;
+    }
+
+    /**
+     * Close Conversion
+     */
+    public void closeMethodClient() {
+        methodsClient = null;

Review Comment:
   There is no close() method in Slack API.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] TyrantLucifer commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
TyrantLucifer commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1023949465


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/client/SlackClient.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.client;
+
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import com.slack.api.Slack;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.conversations.ConversationsListResponse;
+import com.slack.api.model.Conversation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+public class SlackClient {
+    private SlackConfig slackConfig;
+    private MethodsClient methodsClient;
+
+    public SlackClient(SlackConfig slackConfig) {
+        this.slackConfig = slackConfig;
+        this.methodsClient = Slack.getInstance().methods();
+    }
+
+    /**
+     * Find conversation ID using the conversations.list method
+     */
+    public String findConversation() {
+        String conversionId = "";
+        List<Conversation> channels;
+        try {
+            // Get Conversion List
+            ConversationsListResponse conversationsListResponse = methodsClient.conversationsList(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+            );
+            channels = conversationsListResponse.getChannels();
+            for (Conversation channel : channels) {
+                if (channel.getName().equals(slackConfig.getSlackChannel())) {
+                    conversionId = channel.getId();
+                    // Break from for loop
+                    break;
+                }
+            }
+        } catch (IOException | SlackApiException e) {
+            log.warn("Find Slack Conversion Fail.", e);
+            throw new RuntimeException("Find Slack Conversion Fail.", e);

Review Comment:
   You should create a `SlackConnectorException` that extended `SeaTunnelRuntimeException` instead of it. You can refer to https://github.com/apache/incubator-seatunnel/tree/dev/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/exception



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/client/SlackClient.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.client;
+
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import com.slack.api.Slack;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.conversations.ConversationsListResponse;
+import com.slack.api.model.Conversation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+public class SlackClient {
+    private SlackConfig slackConfig;
+    private MethodsClient methodsClient;
+
+    public SlackClient(SlackConfig slackConfig) {
+        this.slackConfig = slackConfig;
+        this.methodsClient = Slack.getInstance().methods();
+    }
+
+    /**
+     * Find conversation ID using the conversations.list method
+     */
+    public String findConversation() {
+        String conversionId = "";
+        List<Conversation> channels;
+        try {
+            // Get Conversion List
+            ConversationsListResponse conversationsListResponse = methodsClient.conversationsList(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+            );
+            channels = conversationsListResponse.getChannels();
+            for (Conversation channel : channels) {
+                if (channel.getName().equals(slackConfig.getSlackChannel())) {
+                    conversionId = channel.getId();
+                    // Break from for loop
+                    break;
+                }
+            }
+        } catch (IOException | SlackApiException e) {
+            log.warn("Find Slack Conversion Fail.", e);
+            throw new RuntimeException("Find Slack Conversion Fail.", e);
+        }
+        return conversionId;
+    }
+
+    /**
+     * Post a message to a channel using Channel ID and message text
+     */
+    public boolean publishMessage(String channelId, String text) {
+        boolean publishMessageSuccess = false;
+        try {
+            ChatPostMessageResponse chatPostMessageResponse = methodsClient.chatPostMessage(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+                .channel(channelId)
+                .text(text)
+            );
+            publishMessageSuccess = chatPostMessageResponse.isOk();
+        } catch (IOException | SlackApiException e) {
+            log.error("error: {}", ExceptionUtils.getMessage(e));
+        }
+        return publishMessageSuccess;
+    }
+
+    /**
+     * Close Conversion
+     */
+    public void closeMethodClient() {
+        methodsClient = null;

Review Comment:
   Is there a `close()` method in `MethodsClient`?



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.StringJoiner;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;

Review Comment:
   ```suggestion
       private final SlackConfig slackConfig;
   ```



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.StringJoiner;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private final String conversationId;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+    private static final long POST_MSG_WAITING_TIME = 1500L;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.slackClient = new SlackClient(slackConfig);
+        this.conversationId = slackClient.findConversation();
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+        StringJoiner stringJoiner = new StringJoiner(",", "", "\n");
+        for (Object field : fields) {
+            stringJoiner.add(String.valueOf(field));
+        }
+        String message = stringJoiner.toString();
+        try {
+            slackClient.publishMessage(conversationId, message);
+            // Slack has a limit on the frequency of sending messages
+            // One message can be sent as soon as one second
+            Thread.sleep(POST_MSG_WAITING_TIME);
+        } catch (Exception e) {
+            log.warn("Write to Slack Fail.", ExceptionUtils.getMessage(e));
+            throw new RuntimeException("Write to Slack Fail.", e);

Review Comment:
   Same as above, please refer to https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/source/CassandraSource.java#L78



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackSink.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import static org.apache.seatunnel.connectors.seatunnel.config.SlackConfig.OAUTH_TOKEN;
+import static org.apache.seatunnel.connectors.seatunnel.config.SlackConfig.SLACK_CHANNEL;
+import static org.apache.seatunnel.connectors.seatunnel.config.SlackConfig.WEBHOOKS_URL;
+
+import org.apache.seatunnel.api.common.PrepareFailException;
+import org.apache.seatunnel.api.sink.SeaTunnelSink;
+import org.apache.seatunnel.api.sink.SinkWriter;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.config.CheckConfigUtil;
+import org.apache.seatunnel.common.config.CheckResult;
+import org.apache.seatunnel.common.constants.PluginType;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSimpleSink;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import com.google.auto.service.AutoService;
+
+import java.io.IOException;
+
+
+
+/**
+ * Slack sink class
+ */
+@AutoService(SeaTunnelSink.class)
+public class SlackSink extends AbstractSimpleSink<SeaTunnelRow, Void> {
+
+    private Config pluginConfig;
+    private SeaTunnelRowType seaTunnelRowType;
+
+    @Override
+    public void setTypeInfo(SeaTunnelRowType seaTunnelRowType) {
+        this.seaTunnelRowType = seaTunnelRowType;
+    }
+
+    @Override
+    public SeaTunnelDataType<SeaTunnelRow> getConsumedType() {
+        return this.seaTunnelRowType;
+    }
+
+    @Override
+    public AbstractSinkWriter<SeaTunnelRow, Void> createWriter(SinkWriter.Context context) throws IOException {
+        return new SlackWriter(seaTunnelRowType, pluginConfig);
+    }
+
+    @Override
+    public String getPluginName() {
+        return "SlackSink";
+    }
+
+    @Override
+    public void prepare(Config pluginConfig) throws PrepareFailException {
+        CheckResult checkResult = CheckConfigUtil.checkAllExists(pluginConfig, WEBHOOKS_URL, OAUTH_TOKEN, SLACK_CHANNEL);
+        if (!checkResult.isSuccess()) {
+            throw new PrepareFailException("Slack", PluginType.SINK, checkResult.getMsg());

Review Comment:
   The same as above, please refer to https://github.com/apache/incubator-seatunnel/blob/dev/seatunnel-connectors-v2/connector-cassandra/src/main/java/org/apache/seatunnel/connectors/seatunnel/cassandra/source/CassandraSource.java#L65



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    public static final String WEBHOOKS_URL = "webhooks_url";
+    public static final String OAUTH_TOKEN = "oauth_token";
+    public static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;

Review Comment:
   ```suggestion
       private final String webHooksUrl;
       private final String oauthToken;
       private final String slackChannel;
   ```



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/client/SlackClient.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.client;
+
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import com.slack.api.Slack;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.conversations.ConversationsListResponse;
+import com.slack.api.model.Conversation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+public class SlackClient {
+    private SlackConfig slackConfig;
+    private MethodsClient methodsClient;

Review Comment:
   ```suggestion
       private final SlackConfig slackConfig;
       private final MethodsClient methodsClient;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] ic4y commented on pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
ic4y commented on PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#issuecomment-1302889293

   If no e2e test is added, you need to comment your local test process and results in the form of pictures, etc. Convenient for later use.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1014977402


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/client/SlackClient.java:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.client;
+
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import com.slack.api.Slack;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.conversations.ConversationsListResponse;
+import com.slack.api.model.Conversation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+public class SlackClient {
+    private SlackConfig slackConfig;
+    private MethodsClient methodsClient;
+
+    public SlackClient(SlackConfig slackConfig) {
+        this.slackConfig = slackConfig;
+        this.methodsClient = Slack.getInstance().methods();
+    }
+
+    /**
+     * Find conversation ID using the conversations.list method
+     */
+    public String findConversation() {
+        String conversionId = "";
+        List<Conversation> channels;
+        try {
+            // Get Conversion List
+            ConversationsListResponse conversationsListResponse = methodsClient.conversationsList(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+            );
+            channels = conversationsListResponse.getChannels();
+            for (Conversation channel : channels) {
+                if (channel.getName().equals(slackConfig.getSlackChannel())) {
+                    conversionId = channel.getId();
+                    // Break from for loop
+                    break;
+                }
+            }
+        } catch (IOException | SlackApiException e) {
+            log.warn("Find Slack Conversion Fail.", e);
+            throw new RuntimeException("Find Slack Conversion Fail.", e);
+        }
+        return conversionId;
+    }
+
+    /**
+     * Post a message to a channel using Channel ID and message text
+     */
+    public boolean publishMessage(String channelId, String text) {
+        boolean publishMessageSuccess = false;
+        try {
+            ChatPostMessageResponse chatPostMessageResponse = methodsClient.chatPostMessage(r -> r
+                // The Token used to initialize app
+                .token(slackConfig.getOauthToken())
+                .channel(channelId)
+                .text(text)
+            );
+            publishMessageSuccess = chatPostMessageResponse.isOk();
+        } catch (IOException | SlackApiException e) {
+            log.error("error: {}", e.getMessage(), e);

Review Comment:
   "error: {}" only can add one argu, ` e.getMessage(), e` have two.
   
   You can update reference this:
   
   ```
   log.error("error: {}", ExceptionUtils.getMessage(e));
   ```



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    private static final String WEBHOOKS_URL = "webhooks_url";
+    private static final String OAUTH_TOKEN = "oauth_token";
+    private static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {

Review Comment:
   All of `webhooks_url ` and `oauth_token ` and `slack_channel ` is required. So you use `CheckConfigUtil.checkAllExists` to check them.



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.StringJoiner;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private final String conversationId;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+    private static final long POST_MSG_WAITING_TIME = 1500L;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.slackClient = new SlackClient(slackConfig);
+        this.conversationId = slackClient.findConversation();
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+        StringJoiner stringJoiner = new StringJoiner(",", "", "\n");
+        for (Object field : fields) {
+            stringJoiner.add(String.valueOf(field));
+        }
+        String message = stringJoiner.toString();
+        try {
+            slackClient.publishMessage(conversationId, message);
+            // Slack has a limit on the frequency of sending messages
+            // One message can be sent as soon as one second
+            Thread.sleep(POST_MSG_WAITING_TIME);
+        } catch (Exception e) {
+            log.warn("Write to Slack Fail.", e);

Review Comment:
   ```            
   log.warn("Write to Slack Fail: {}",  ExceptionUtils.getMessage(e));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1027020997


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/sink/SlackWriter.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.sink;
+
+import org.apache.seatunnel.api.table.type.SeaTunnelRow;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.client.SlackClient;
+import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.StringJoiner;
+
+@Slf4j
+public class SlackWriter extends AbstractSinkWriter<SeaTunnelRow, Void> {
+    private SlackConfig slackConfig;
+    private final String conversationId;
+    private final SlackClient slackClient;
+    private final SeaTunnelRowType seaTunnelRowType;
+    private static final long POST_MSG_WAITING_TIME = 1500L;
+
+    public SlackWriter(SeaTunnelRowType seaTunnelRowType, Config pluginConfig) {
+        this.slackConfig = new SlackConfig(pluginConfig);
+        this.seaTunnelRowType = seaTunnelRowType;
+        this.slackClient = new SlackClient(slackConfig);
+        this.conversationId = slackClient.findConversation();
+    }
+
+    @Override
+    public void write(SeaTunnelRow element) throws IOException {
+        Object[] fields = element.getFields();
+        StringJoiner stringJoiner = new StringJoiner(",", "", "\n");
+        for (Object field : fields) {
+            stringJoiner.add(String.valueOf(field));
+        }
+        String message = stringJoiner.toString();
+        try {
+            slackClient.publishMessage(conversationId, message);
+            // Slack has a limit on the frequency of sending messages
+            // One message can be sent as soon as one second
+            Thread.sleep(POST_MSG_WAITING_TIME);
+        } catch (Exception e) {
+            log.warn("Write to Slack Fail.", ExceptionUtils.getMessage(e));
+            throw new RuntimeException("Write to Slack Fail.", e);

Review Comment:
   Thanks for your advice. I have fixed it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1027021140


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/client/SlackClient.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.client;
+
+import org.apache.seatunnel.common.utils.ExceptionUtils;
+import org.apache.seatunnel.connectors.seatunnel.config.SlackConfig;
+
+import com.slack.api.Slack;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.conversations.ConversationsListResponse;
+import com.slack.api.model.Conversation;
+import lombok.extern.slf4j.Slf4j;
+
+import java.io.IOException;
+import java.util.List;
+
+@Slf4j
+public class SlackClient {
+    private SlackConfig slackConfig;
+    private MethodsClient methodsClient;

Review Comment:
   Done! PTAL



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] ic4y commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
ic4y commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1019799871


##########
seatunnel-dist/pom.xml:
##########
@@ -677,7 +677,7 @@
                     <version>${project.version}</version>
                     <scope>provided</scope>
                 </dependency>
-                
+

Review Comment:
   Please add slack dependency to seatunnel profile. Around 200 to 300 lines



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] ic4y commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
ic4y commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1021041320


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    public static final String WEBHOOKS_URL = "webhooks_url";
+    public static final String OAUTH_TOKEN = "oauth_token";
+    public static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {

Review Comment:
   These three parameters have already been checked in the prepare method, and this place does not need to check again.



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    public static final String WEBHOOKS_URL = "webhooks_url";
+    public static final String OAUTH_TOKEN = "oauth_token";
+    public static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {
+            this.webHooksUrl = pluginConfig.getString(WEBHOOKS_URL);
+        }
+        if (pluginConfig.hasPath(OAUTH_TOKEN)) {

Review Comment:
   Ditto



##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    public static final String WEBHOOKS_URL = "webhooks_url";
+    public static final String OAUTH_TOKEN = "oauth_token";
+    public static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {
+            this.webHooksUrl = pluginConfig.getString(WEBHOOKS_URL);
+        }
+        if (pluginConfig.hasPath(OAUTH_TOKEN)) {
+            this.oauthToken = pluginConfig.getString(OAUTH_TOKEN);
+        }
+        if (pluginConfig.hasPath(SLACK_CHANNEL)) {

Review Comment:
   Ditto



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1022704423


##########
seatunnel-connectors-v2/connector-slack/src/main/java/org/apache/seatunnel/connectors/seatunnel/config/SlackConfig.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.config;
+
+import org.apache.seatunnel.shade.com.typesafe.config.Config;
+
+import lombok.Data;
+import lombok.NonNull;
+
+@Data
+public class SlackConfig {
+
+    public static final String WEBHOOKS_URL = "webhooks_url";
+    public static final String OAUTH_TOKEN = "oauth_token";
+    public static final String SLACK_CHANNEL = "slack_channel";
+    private String webHooksUrl;
+    private String oauthToken;
+    private String slackChannel;
+
+    public SlackConfig(@NonNull Config pluginConfig) {
+        if (pluginConfig.hasPath(WEBHOOKS_URL)) {

Review Comment:
   I have removed it.PTAL



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] TyrantLucifer merged pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
TyrantLucifer merged PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#discussion_r1008717494


##########
docs/en/connector-v2/sink/Slack.md:
##########
@@ -0,0 +1,57 @@
+# Slack
+
+> Slack sink connector
+
+## Description
+
+Used to send data to Slack Channel. Both support streaming and batch mode.
+> For example, if the data from upstream is [`age: 12, name: huan`], the content send to socket server is the following: `{"name":"huan","age":17}`
+
+
+## Key features
+
+- [ ] [exactly-once](../../concept/connector-v2-features.md)
+- [ ] [schema projection](../../concept/connector-v2-features.md)
+
+## Options
+
+| name           | type   | required | default value |
+| -------------- |--------|----------|---------------|
+| webhooks_url   | String | Yes      | -             |
+| oauth_token    | String | Yes      | -             |
+| slack_channel  | String | Yes      | -             |
+| common-options |        | no       | -             |
+
+### webhooks_url [string]
+
+Slack webhook url
+
+### oauth_token [string]
+
+Slack oauth token used for the actual authentication
+
+### slack_channel [string]
+
+slack channel for data write
+
+### common options
+
+Sink plugin common parameters, please refer to [Sink Common Options](common-options.md) for details
+
+## Example
+
+```hocon
+sink {
+ SlackSink {
+  webhooks_url = "https://hooks.slack.com/services/xxxxxxxxxxxx/xxxxxxxxxxxx/xxxxxxxxxxxxxxxx"
+  oauth_token = "xoxp-xxxxxxxxxx-xxxxxxxx-xxxxxxxxx-xxxxxxxxxxx"
+  slack_channel = "channel name"
+ }
+}
+```
+
+## Changelog
+
+### 2.3.0-beta 2022-10-20

Review Comment:
   `### 2.3.0-beta 2022-10-20` need replace with `new version`, `new version` will be update to the real version number when we release a version.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-seatunnel] 18391713434 commented on pull request #3226: [Feature][Connector-V2][Slack] Add Slack sink connector

Posted by GitBox <gi...@apache.org>.
18391713434 commented on PR #3226:
URL: https://github.com/apache/incubator-seatunnel/pull/3226#issuecomment-1303886433

   > If no e2e test is added, you need to comment your local test process and results in the form of pictures, etc. Convenient for later use.
   
   <img src="https://imagehost-1311381309.cos.ap-nanjing.myqcloud.com/Snipaste_2022-11-05_00-09-52.jpg"/>
   
   <img src="https://imagehost-1311381309.cos.ap-nanjing.myqcloud.com/Snipaste_2022-11-05_00-32-23.jpg"/>
   
   <img src="https://imagehost-1311381309.cos.ap-nanjing.myqcloud.com/Snipaste_2022-11-05_00-53-21.jpg"/>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org