-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
52 changed files
with
7,333 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Test & Build | ||
name: Raccoon Test & Build | ||
|
||
on: | ||
- push | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Integration Test | ||
name: Raccoon Integration Test | ||
|
||
on: | ||
- push | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Release | ||
name: Release Raccoon | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Release Client - JAVA | ||
|
||
on: | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-java-client: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '8' | ||
- name: Publish java client | ||
run: | | ||
printf "$GPG_SIGNING_KEY" | base64 --decode > private.key | ||
./gradlew clean publishToSonatype closeAndReleaseSonatypeStagingRepository -Psigning.keyId=${GPG_SIGNING_KEY_ID} -Psigning.password=${GPG_SIGNING_PASSWORD} -Psigning.secretKeyRingFile=private.key --console=verbose | ||
working-directory: clients/java | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | ||
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} | ||
GPG_SIGNING_KEY_ID: ${{ secrets.GPG_SIGNING_KEY_ID }} | ||
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Test Raccoon GO client | ||
on: | ||
push: | ||
paths: | ||
- "clients/go/**" | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- "clients/go/**" | ||
branches: | ||
- main | ||
jobs: | ||
test-go: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.16 | ||
id: go | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
- name: Test | ||
run: cd clients/go; go test -count 1 -cover ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Test Raccoon Java Client | ||
on: | ||
push: | ||
paths: | ||
- "clients/java/**" | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- "clients/java/**" | ||
branches: | ||
- main | ||
jobs: | ||
test-java: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 1.8 | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '8' | ||
- name: Grant execute permission for gradlew | ||
working-directory: clients/java | ||
run: chmod +x gradlew | ||
- name: Test | ||
working-directory: clients/java | ||
run: ./gradlew test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.idea | ||
out | ||
.gradle | ||
*.iml | ||
.DS_Store | ||
|
||
build | ||
src/test/generated/ | ||
src/test/resources/ | ||
classpath | ||
|
||
.classpath | ||
.vscode/ | ||
.project | ||
.settings/ | ||
bin/ | ||
private.key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.PHONY: all | ||
|
||
all: generate-proto build | ||
|
||
# generates the raccoon protos from the https://github.com/odpf/proton using the buf | ||
generate-proto: | ||
rm -rf .temp | ||
mkdir -p .temp | ||
curl -o .temp/proton.tar.gz -L http://api.github.com/repos/odpf/proton/tarball/main; tar xvf .temp/proton.tar.gz -C .temp/ --strip-components 1 | ||
buf generate --path=.temp/odpf/raccoon | ||
|
||
clean: | ||
rm -rf .temp | ||
|
||
build: | ||
./gradlew build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Java Client for Raccoon | ||
|
||
|
||
## Requirements | ||
|
||
- [Gradle v5+](https://gradle.org/) | ||
- [JDK 8+](https://openjdk.java.net/projects/jdk8/) | ||
|
||
|
||
### Add raccoon as dependency | ||
|
||
#### Gradle | ||
|
||
```groovy | ||
implementation group: 'io.odpf', name: 'raccoon', version: '0.1.0' | ||
``` | ||
|
||
#### Maven | ||
|
||
```xml | ||
<dependency> | ||
<groupId>io.odpf</groupId> | ||
<artifactId>racoon</artifactId> | ||
<version>0.1.0</version> | ||
</dependency> | ||
``` | ||
|
||
## Usage | ||
|
||
#### Construct a new REST client, then use the various options to build the client. | ||
For example: | ||
|
||
```java | ||
// build the configuration. | ||
RestConfig config = RestConfig.builder() | ||
.url("http://localhost:8080/api/v1/events") | ||
.header("x-connection-id", "123") | ||
.serializer(new ProtoSerializer()) // default is Json | ||
.marshaler(new ProtoWire()) // default is Json | ||
.retryMax(5) // default is 3 | ||
.retryWait(2000) // default is one second | ||
.build(); | ||
|
||
// get the rest client instance. | ||
RaccoonClient restClient = RaccoonClientFactory.getRestClient(config); | ||
|
||
// prepare the event to be send. | ||
PageEventProto.PageEvent pageEvent = PageEventProto.PageEvent.newBuilder() | ||
.setEventGuid(UUID.randomUUID().toString()) | ||
.setEventName("clicked") | ||
.setSentTime(Timestamp.newBuilder().build()) | ||
.build(); | ||
|
||
// send the event batch to the raccoon. | ||
Response response = restClient.send( | ||
new Event[] { | ||
new Event("page", pageEvent) | ||
}); | ||
|
||
// check the status of the request. | ||
if (response.isSuccess() && response.getStatus() == ResponseStatus.STATUS_SUCCESS) { | ||
System.out.println("The event sent successfully"); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: v1 | ||
plugins: | ||
- remote: buf.build/protocolbuffers/plugins/java:v3.19.1-1 | ||
out: src/main/java | ||
- remote: buf.build/grpc/plugins/java:v1.42.1-1 | ||
out: src/main/java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
plugins { | ||
id "java" | ||
id 'idea' | ||
id 'signing' | ||
id 'checkstyle' | ||
id 'java-library' | ||
id 'maven-publish' | ||
id 'io.franzbecker.gradle-lombok' version '5.0.0' | ||
id "io.github.gradle-nexus.publish-plugin" version "1.1.0" | ||
} | ||
|
||
group 'io.odpf' | ||
version '1.0.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
mavenLocal() | ||
maven { | ||
url("https://plugins.gradle.org/m2/") | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25' | ||
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '3.1.0' | ||
implementation group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.1.0' | ||
implementation group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2' | ||
implementation 'io.grpc:grpc-all:1.51.0' | ||
implementation 'com.google.code.gson:gson:2.10' | ||
|
||
testImplementation group: 'junit', name: 'junit', version: '4.11' | ||
testImplementation group: 'com.github.tomakehurst', name: 'wiremock', version: '2.18.0' | ||
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.1.0' | ||
} | ||
|
||
idea { | ||
module { | ||
testSourceDirs += file("$projectDir/src/test/java") | ||
} | ||
} | ||
|
||
clean { | ||
delete "$projectDir/src/test/resources/__files" | ||
} | ||
|
||
checkstyle { | ||
toolVersion '7.6.1' | ||
configFile rootProject.file("config/checkstyle/checkstyle.xml") | ||
} | ||
|
||
checkstyleMain { | ||
source = 'src/main/java/io/odpf/raccoon' | ||
} | ||
|
||
checkstyleTest { | ||
source = 'src/test/java/io/odpf/raccoon' | ||
} | ||
|
||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "OSSRH" | ||
url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" | ||
credentials { | ||
username = System.getenv("MAVEN_USERNAME") | ||
password = System.getenv("MAVEN_PASSWORD") | ||
} | ||
} | ||
} | ||
|
||
publications { | ||
maven(MavenPublication) { | ||
pom { | ||
groupId = project.group | ||
artifactId = project.name | ||
version = project.version | ||
name = 'Raccoon' | ||
description = 'Java client library for sending events to the Raccoon' | ||
url = 'https://github.com/odpf/raccoon' | ||
|
||
scm { | ||
url = 'https://github.com/odpf/raccoon.git' | ||
} | ||
|
||
licenses { | ||
license { | ||
name = 'The Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'AkbaraliShaikh' | ||
name = 'Akbar Shaikh' | ||
email = '[email protected]' | ||
} | ||
} | ||
from components.java | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
sign publishing.publications.maven | ||
} | ||
|
||
nexusPublishing { | ||
repositories { | ||
sonatype { | ||
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) | ||
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) | ||
username = System.getenv("MAVEN_USERNAME") | ||
password = System.getenv("MAVEN_PASSWORD") | ||
} | ||
} | ||
} |
Oops, something went wrong.