Skip to content

Commit

Permalink
Merge pull request #2 from globeandmail/feature/SOPHI4-1034
Browse files Browse the repository at this point in the history
Feature/SOPHI4-1034
  • Loading branch information
ereasat authored Apr 12, 2021
2 parents f171854 + 936b13d commit 2f0b7a8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Java Maven build

on: [push]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'
- name: Publish to GitHub Packages
run: mvn deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This command will install all the components in your `.m2` directory. To use you

```
<dependency>
<groupId>net.galgus</groupId>
<groupId>tgamforks</groupId>
<artifactId>flink-connector-http</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Expand Down
11 changes: 10 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>net.galgus</groupId>
<groupId>tgamforks</groupId>
<artifactId>flink-connector-http</artifactId>
<version>1.0-SNAPSHOT</version>

Expand Down Expand Up @@ -37,4 +37,13 @@
</plugin>
</plugins>
</build>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub globeandmail Apache Maven Packages</name>
<url>https://maven.pkg.github.com/globeandmail/flink-connector-http</url>
</repository>
</distributionManagement>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;

public class HTTPSink<IN> extends RichSinkFunction<IN> {
private static final Logger log = LoggerFactory.getLogger(HTTPSink.class);
Expand All @@ -25,9 +26,10 @@ public HTTPSink(HTTPConnectionConfig httpConnectionConfig) {
public void invoke(IN value, Context context) throws Exception {
if (value != null) {
URL url = new URL(httpConnectionConfig.getEndpoint());


long start = System.nanoTime();

HttpURLConnection conn = httpConnectionConfig.isHttpsEnabled() ? (HttpsURLConnection) url.openConnection() : (HttpURLConnection) url.openConnection();

conn.setDoOutput(true);
conn.setRequestMethod(httpConnectionConfig.getMethod());

Expand Down Expand Up @@ -58,6 +60,10 @@ public void invoke(IN value, Context context) throws Exception {
+ ", headers: " + httpConnectionConfig.getHeaders());

conn.disconnect();
long elapsedNano = System.nanoTime() - start;
long elapsedTime = TimeUnit.NANOSECONDS.toMillis(elapsedNano);
log.info("Request from url = {}, with status = {} and message = {} in duration = {}ms",
conn.getURL(), status, conn.getResponseMessage(), Long.toString(elapsedTime));
}
}
}

0 comments on commit 2f0b7a8

Please sign in to comment.