diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d60c4f45..9c40b272 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: Test & Build +name: Raccoon Test & Build on: - push diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 016c05d8..6f6348c3 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -1,4 +1,4 @@ -name: Integration Test +name: Raccoon Integration Test on: - push diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index b41b5ad6..f390d5a2 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -1,4 +1,4 @@ -name: Release +name: Release Raccoon on: push: # Sequence of patterns matched against refs/tags diff --git a/.github/workflows/release-java-client.yaml b/.github/workflows/release-java-client.yaml new file mode 100644 index 00000000..c637950a --- /dev/null +++ b/.github/workflows/release-java-client.yaml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/test-go-client.yaml b/.github/workflows/test-go-client.yaml new file mode 100644 index 00000000..26e79905 --- /dev/null +++ b/.github/workflows/test-go-client.yaml @@ -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 ./... \ No newline at end of file diff --git a/.github/workflows/test-java-client.yaml b/.github/workflows/test-java-client.yaml new file mode 100644 index 00000000..f2aac5b9 --- /dev/null +++ b/.github/workflows/test-java-client.yaml @@ -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 \ No newline at end of file diff --git a/clients/java/.gitignore b/clients/java/.gitignore new file mode 100644 index 00000000..a93b923e --- /dev/null +++ b/clients/java/.gitignore @@ -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 \ No newline at end of file diff --git a/clients/java/Makefile b/clients/java/Makefile new file mode 100644 index 00000000..c2fe7748 --- /dev/null +++ b/clients/java/Makefile @@ -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 \ No newline at end of file diff --git a/clients/java/README.md b/clients/java/README.md new file mode 100644 index 00000000..3596b5a2 --- /dev/null +++ b/clients/java/README.md @@ -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 + + io.odpf + racoon + 0.1.0 + +``` + +## 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"); + } +``` \ No newline at end of file diff --git a/clients/java/buf.gen.yaml b/clients/java/buf.gen.yaml new file mode 100644 index 00000000..266b6c96 --- /dev/null +++ b/clients/java/buf.gen.yaml @@ -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 \ No newline at end of file diff --git a/clients/java/build.gradle b/clients/java/build.gradle new file mode 100644 index 00000000..f3ca9db6 --- /dev/null +++ b/clients/java/build.gradle @@ -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 = 'aashaikh55@gmail.com' + } + } + 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") + } + } +} \ No newline at end of file diff --git a/clients/java/config/checkstyle/checkstyle.xml b/clients/java/config/checkstyle/checkstyle.xml new file mode 100644 index 00000000..5e1244d9 --- /dev/null +++ b/clients/java/config/checkstyle/checkstyle.xml @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/clients/java/config/checkstyle/suppressions.xml b/clients/java/config/checkstyle/suppressions.xml new file mode 100644 index 00000000..c75ef9b4 --- /dev/null +++ b/clients/java/config/checkstyle/suppressions.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/clients/java/gradle/wrapper/gradle-wrapper.jar b/clients/java/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..41d9927a Binary files /dev/null and b/clients/java/gradle/wrapper/gradle-wrapper.jar differ diff --git a/clients/java/gradle/wrapper/gradle-wrapper.properties b/clients/java/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..a0f7639f --- /dev/null +++ b/clients/java/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/clients/java/gradlew b/clients/java/gradlew new file mode 100755 index 00000000..1b6c7873 --- /dev/null +++ b/clients/java/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed 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 +# +# https://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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/clients/java/gradlew.bat b/clients/java/gradlew.bat new file mode 100644 index 00000000..ac1b06f9 --- /dev/null +++ b/clients/java/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/clients/java/settings.gradle b/clients/java/settings.gradle new file mode 100644 index 00000000..77998f60 --- /dev/null +++ b/clients/java/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'raccoon' + diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/Code.java b/clients/java/src/main/java/io/odpf/proton/raccoon/Code.java new file mode 100644 index 00000000..5ff82afb --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/Code.java @@ -0,0 +1,205 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +/** + * Protobuf enum {@code odpf.raccoon.v1beta1.Code} + */ +public enum Code + implements com.google.protobuf.ProtocolMessageEnum { + /** + *
+   * `CODE_UNSPECIFIED` indicates no appropriate/existing code can describe it.
+   * 
+ * + * CODE_UNSPECIFIED = 0; + */ + CODE_UNSPECIFIED(0), + /** + *
+   * `OK` indicates the request is processed successfully.
+   * 
+ * + * CODE_OK = 1; + */ + CODE_OK(1), + /** + *
+   * `BAD_REQUEST` indicates there is something wrong with the request.
+   * 
+ * + * CODE_BAD_REQUEST = 2; + */ + CODE_BAD_REQUEST(2), + /** + *
+   * `INTERNAL_ERROR` indicates that Raccoon encountered an unexpected condition that prevented it from fulfilling the request.
+   * 
+ * + * CODE_INTERNAL_ERROR = 3; + */ + CODE_INTERNAL_ERROR(3), + /** + *
+   * `MAX_CONNECTION_LIMIT_REACHED` indicates that Raccoon is unable to accepts new connection due to max connection is reached.
+   * To prevent Raccoon from eating up resources, connection limit needs to be set. The limit is configurable on Raccoon by setting `SERVER_WEBSOCKET_MAX_CONN`
+   * 
+ * + * CODE_MAX_CONNECTION_LIMIT_REACHED = 4; + */ + CODE_MAX_CONNECTION_LIMIT_REACHED(4), + /** + *
+   * `MAX_USER_LIMIT_REACHED` indicates that existing connection with the same ID.
+   * Raccoon ensures unique connection using unique identifier passed from the header 
+   * the first time Websocket connection is established. The header key that
+   * contains unique identifier is configurable on Raccoon by setting `SERVER_WEBSOCKET_CONN_UNIQ_ID_HEADER`
+   * 
+ * + * CODE_MAX_USER_LIMIT_REACHED = 5; + */ + CODE_MAX_USER_LIMIT_REACHED(5), + UNRECOGNIZED(-1), + ; + + /** + *
+   * `CODE_UNSPECIFIED` indicates no appropriate/existing code can describe it.
+   * 
+ * + * CODE_UNSPECIFIED = 0; + */ + public static final int CODE_UNSPECIFIED_VALUE = 0; + /** + *
+   * `OK` indicates the request is processed successfully.
+   * 
+ * + * CODE_OK = 1; + */ + public static final int CODE_OK_VALUE = 1; + /** + *
+   * `BAD_REQUEST` indicates there is something wrong with the request.
+   * 
+ * + * CODE_BAD_REQUEST = 2; + */ + public static final int CODE_BAD_REQUEST_VALUE = 2; + /** + *
+   * `INTERNAL_ERROR` indicates that Raccoon encountered an unexpected condition that prevented it from fulfilling the request.
+   * 
+ * + * CODE_INTERNAL_ERROR = 3; + */ + public static final int CODE_INTERNAL_ERROR_VALUE = 3; + /** + *
+   * `MAX_CONNECTION_LIMIT_REACHED` indicates that Raccoon is unable to accepts new connection due to max connection is reached.
+   * To prevent Raccoon from eating up resources, connection limit needs to be set. The limit is configurable on Raccoon by setting `SERVER_WEBSOCKET_MAX_CONN`
+   * 
+ * + * CODE_MAX_CONNECTION_LIMIT_REACHED = 4; + */ + public static final int CODE_MAX_CONNECTION_LIMIT_REACHED_VALUE = 4; + /** + *
+   * `MAX_USER_LIMIT_REACHED` indicates that existing connection with the same ID.
+   * Raccoon ensures unique connection using unique identifier passed from the header 
+   * the first time Websocket connection is established. The header key that
+   * contains unique identifier is configurable on Raccoon by setting `SERVER_WEBSOCKET_CONN_UNIQ_ID_HEADER`
+   * 
+ * + * CODE_MAX_USER_LIMIT_REACHED = 5; + */ + public static final int CODE_MAX_USER_LIMIT_REACHED_VALUE = 5; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Code valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Code forNumber(int value) { + switch (value) { + case 0: return CODE_UNSPECIFIED; + case 1: return CODE_OK; + case 2: return CODE_BAD_REQUEST; + case 3: return CODE_INTERNAL_ERROR; + case 4: return CODE_MAX_CONNECTION_LIMIT_REACHED; + case 5: return CODE_MAX_USER_LIMIT_REACHED; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + Code> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Code findValueByNumber(int number) { + return Code.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.getDescriptor().getEnumTypes().get(1); + } + + private static final Code[] VALUES = values(); + + public static Code valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Code(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:odpf.raccoon.v1beta1.Code) +} + diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/Event.java b/clients/java/src/main/java/io/odpf/proton/raccoon/Event.java new file mode 100644 index 00000000..0b98906a --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/Event.java @@ -0,0 +1,690 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +/** + * Protobuf type {@code odpf.raccoon.v1beta1.Event} + */ +public final class Event extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:odpf.raccoon.v1beta1.Event) + EventOrBuilder { +private static final long serialVersionUID = 0L; + // Use Event.newBuilder() to construct. + private Event(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Event() { + eventBytes_ = com.google.protobuf.ByteString.EMPTY; + type_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Event(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Event( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + + eventBytes_ = input.readBytes(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + type_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_Event_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_Event_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.odpf.proton.raccoon.Event.class, io.odpf.proton.raccoon.Event.Builder.class); + } + + public static final int EVENT_BYTES_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString eventBytes_; + /** + *
+   * `event_bytes` is where you put bytes serialized event.
+   * 
+ * + * bytes event_bytes = 1 [json_name = "eventBytes"]; + * @return The eventBytes. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEventBytes() { + return eventBytes_; + } + + public static final int TYPE_FIELD_NUMBER = 2; + private volatile java.lang.Object type_; + /** + *
+   * `type` denotes an event type that the producer of this proto message may set.
+   * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+   * users of this proto can use this type to set strings which can be processed in their
+   * ingestion systems to distribute or perform other functions.
+   * 
+ * + * string type = 2 [json_name = "type"]; + * @return The type. + */ + @java.lang.Override + public java.lang.String getType() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } + } + /** + *
+   * `type` denotes an event type that the producer of this proto message may set.
+   * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+   * users of this proto can use this type to set strings which can be processed in their
+   * ingestion systems to distribute or perform other functions.
+   * 
+ * + * string type = 2 [json_name = "type"]; + * @return The bytes for type. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!eventBytes_.isEmpty()) { + output.writeBytes(1, eventBytes_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(type_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, type_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!eventBytes_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, eventBytes_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(type_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, type_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.odpf.proton.raccoon.Event)) { + return super.equals(obj); + } + io.odpf.proton.raccoon.Event other = (io.odpf.proton.raccoon.Event) obj; + + if (!getEventBytes() + .equals(other.getEventBytes())) return false; + if (!getType() + .equals(other.getType())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + EVENT_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getEventBytes().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.odpf.proton.raccoon.Event parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.Event parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.Event parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.Event parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.Event parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.Event parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.Event parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.Event parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.odpf.proton.raccoon.Event parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.Event parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.odpf.proton.raccoon.Event parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.Event parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.odpf.proton.raccoon.Event prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code odpf.raccoon.v1beta1.Event} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:odpf.raccoon.v1beta1.Event) + io.odpf.proton.raccoon.EventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_Event_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_Event_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.odpf.proton.raccoon.Event.class, io.odpf.proton.raccoon.Event.Builder.class); + } + + // Construct using io.odpf.proton.raccoon.Event.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + eventBytes_ = com.google.protobuf.ByteString.EMPTY; + + type_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_Event_descriptor; + } + + @java.lang.Override + public io.odpf.proton.raccoon.Event getDefaultInstanceForType() { + return io.odpf.proton.raccoon.Event.getDefaultInstance(); + } + + @java.lang.Override + public io.odpf.proton.raccoon.Event build() { + io.odpf.proton.raccoon.Event result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.odpf.proton.raccoon.Event buildPartial() { + io.odpf.proton.raccoon.Event result = new io.odpf.proton.raccoon.Event(this); + result.eventBytes_ = eventBytes_; + result.type_ = type_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.odpf.proton.raccoon.Event) { + return mergeFrom((io.odpf.proton.raccoon.Event)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.odpf.proton.raccoon.Event other) { + if (other == io.odpf.proton.raccoon.Event.getDefaultInstance()) return this; + if (other.getEventBytes() != com.google.protobuf.ByteString.EMPTY) { + setEventBytes(other.getEventBytes()); + } + if (!other.getType().isEmpty()) { + type_ = other.type_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.odpf.proton.raccoon.Event parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.odpf.proton.raccoon.Event) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString eventBytes_ = com.google.protobuf.ByteString.EMPTY; + /** + *
+     * `event_bytes` is where you put bytes serialized event.
+     * 
+ * + * bytes event_bytes = 1 [json_name = "eventBytes"]; + * @return The eventBytes. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEventBytes() { + return eventBytes_; + } + /** + *
+     * `event_bytes` is where you put bytes serialized event.
+     * 
+ * + * bytes event_bytes = 1 [json_name = "eventBytes"]; + * @param value The eventBytes to set. + * @return This builder for chaining. + */ + public Builder setEventBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + eventBytes_ = value; + onChanged(); + return this; + } + /** + *
+     * `event_bytes` is where you put bytes serialized event.
+     * 
+ * + * bytes event_bytes = 1 [json_name = "eventBytes"]; + * @return This builder for chaining. + */ + public Builder clearEventBytes() { + + eventBytes_ = getDefaultInstance().getEventBytes(); + onChanged(); + return this; + } + + private java.lang.Object type_ = ""; + /** + *
+     * `type` denotes an event type that the producer of this proto message may set.
+     * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+     * users of this proto can use this type to set strings which can be processed in their
+     * ingestion systems to distribute or perform other functions.
+     * 
+ * + * string type = 2 [json_name = "type"]; + * @return The type. + */ + public java.lang.String getType() { + java.lang.Object ref = type_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + type_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * `type` denotes an event type that the producer of this proto message may set.
+     * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+     * users of this proto can use this type to set strings which can be processed in their
+     * ingestion systems to distribute or perform other functions.
+     * 
+ * + * string type = 2 [json_name = "type"]; + * @return The bytes for type. + */ + public com.google.protobuf.ByteString + getTypeBytes() { + java.lang.Object ref = type_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + type_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * `type` denotes an event type that the producer of this proto message may set.
+     * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+     * users of this proto can use this type to set strings which can be processed in their
+     * ingestion systems to distribute or perform other functions.
+     * 
+ * + * string type = 2 [json_name = "type"]; + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value; + onChanged(); + return this; + } + /** + *
+     * `type` denotes an event type that the producer of this proto message may set.
+     * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+     * users of this proto can use this type to set strings which can be processed in their
+     * ingestion systems to distribute or perform other functions.
+     * 
+ * + * string type = 2 [json_name = "type"]; + * @return This builder for chaining. + */ + public Builder clearType() { + + type_ = getDefaultInstance().getType(); + onChanged(); + return this; + } + /** + *
+     * `type` denotes an event type that the producer of this proto message may set.
+     * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+     * users of this proto can use this type to set strings which can be processed in their
+     * ingestion systems to distribute or perform other functions.
+     * 
+ * + * string type = 2 [json_name = "type"]; + * @param value The bytes for type to set. + * @return This builder for chaining. + */ + public Builder setTypeBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + type_ = value; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:odpf.raccoon.v1beta1.Event) + } + + // @@protoc_insertion_point(class_scope:odpf.raccoon.v1beta1.Event) + private static final io.odpf.proton.raccoon.Event DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.odpf.proton.raccoon.Event(); + } + + public static io.odpf.proton.raccoon.Event getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Event parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Event(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public io.odpf.proton.raccoon.Event getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/EventOrBuilder.java b/clients/java/src/main/java/io/odpf/proton/raccoon/EventOrBuilder.java new file mode 100644 index 00000000..89e8b0d8 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/EventOrBuilder.java @@ -0,0 +1,45 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +public interface EventOrBuilder extends + // @@protoc_insertion_point(interface_extends:odpf.raccoon.v1beta1.Event) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * `event_bytes` is where you put bytes serialized event.
+   * 
+ * + * bytes event_bytes = 1 [json_name = "eventBytes"]; + * @return The eventBytes. + */ + com.google.protobuf.ByteString getEventBytes(); + + /** + *
+   * `type` denotes an event type that the producer of this proto message may set.
+   * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+   * users of this proto can use this type to set strings which can be processed in their
+   * ingestion systems to distribute or perform other functions.
+   * 
+ * + * string type = 2 [json_name = "type"]; + * @return The type. + */ + java.lang.String getType(); + /** + *
+   * `type` denotes an event type that the producer of this proto message may set.
+   * It is currently used by raccoon to distribute events to respective Kafka topics. However the
+   * users of this proto can use this type to set strings which can be processed in their
+   * ingestion systems to distribute or perform other functions.
+   * 
+ * + * string type = 2 [json_name = "type"]; + * @return The bytes for type. + */ + com.google.protobuf.ByteString + getTypeBytes(); +} diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/EventProto.java b/clients/java/src/main/java/io/odpf/proton/raccoon/EventProto.java new file mode 100644 index 00000000..4eaf3e38 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/EventProto.java @@ -0,0 +1,107 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +public final class EventProto { + private EventProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_odpf_raccoon_v1beta1_SendEventRequest_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_odpf_raccoon_v1beta1_SendEventRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_odpf_raccoon_v1beta1_Event_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_odpf_raccoon_v1beta1_Event_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_odpf_raccoon_v1beta1_SendEventResponse_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_odpf_raccoon_v1beta1_SendEventResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_odpf_raccoon_v1beta1_SendEventResponse_DataEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_odpf_raccoon_v1beta1_SendEventResponse_DataEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n(.temp/odpf/raccoon/v1beta1/raccoon.pro" + + "to\022\024odpf.raccoon.v1beta1\032\037google/protobu" + + "f/timestamp.proto\"\233\001\n\020SendEventRequest\022\031" + + "\n\010req_guid\030\001 \001(\tR\007reqGuid\0227\n\tsent_time\030\002" + + " \001(\0132\032.google.protobuf.TimestampR\010sentTi" + + "me\0223\n\006events\030\003 \003(\0132\033.odpf.raccoon.v1beta" + + "1.EventR\006events\"<\n\005Event\022\037\n\013event_bytes\030" + + "\001 \001(\014R\neventBytes\022\022\n\004type\030\002 \001(\tR\004type\"\256\002" + + "\n\021SendEventResponse\0224\n\006status\030\001 \001(\0162\034.od" + + "pf.raccoon.v1beta1.StatusR\006status\022.\n\004cod" + + "e\030\002 \001(\0162\032.odpf.raccoon.v1beta1.CodeR\004cod" + + "e\022\033\n\tsent_time\030\003 \001(\003R\010sentTime\022\026\n\006reason" + + "\030\004 \001(\tR\006reason\022E\n\004data\030\005 \003(\01321.odpf.racc" + + "oon.v1beta1.SendEventResponse.DataEntryR" + + "\004data\0327\n\tDataEntry\022\020\n\003key\030\001 \001(\tR\003key\022\024\n\005" + + "value\030\002 \001(\tR\005value:\0028\001*F\n\006Status\022\026\n\022STAT" + + "US_UNSPECIFIED\020\000\022\022\n\016STATUS_SUCCESS\020\001\022\020\n\014" + + "STATUS_ERROR\020\002*\240\001\n\004Code\022\024\n\020CODE_UNSPECIF" + + "IED\020\000\022\013\n\007CODE_OK\020\001\022\024\n\020CODE_BAD_REQUEST\020\002" + + "\022\027\n\023CODE_INTERNAL_ERROR\020\003\022%\n!CODE_MAX_CO" + + "NNECTION_LIMIT_REACHED\020\004\022\037\n\033CODE_MAX_USE" + + "R_LIMIT_REACHED\020\0052l\n\014EventService\022\\\n\tSen" + + "dEvent\022&.odpf.raccoon.v1beta1.SendEventR" + + "equest\032\'.odpf.raccoon.v1beta1.SendEventR" + + "esponseBS\n\026io.odpf.proton.raccoonB\nEvent" + + "ProtoP\001Z+github.com/odpf/proton/raccoon/" + + "v1;raccoonv1b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_odpf_raccoon_v1beta1_SendEventRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_odpf_raccoon_v1beta1_SendEventRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_odpf_raccoon_v1beta1_SendEventRequest_descriptor, + new java.lang.String[] { "ReqGuid", "SentTime", "Events", }); + internal_static_odpf_raccoon_v1beta1_Event_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_odpf_raccoon_v1beta1_Event_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_odpf_raccoon_v1beta1_Event_descriptor, + new java.lang.String[] { "EventBytes", "Type", }); + internal_static_odpf_raccoon_v1beta1_SendEventResponse_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_odpf_raccoon_v1beta1_SendEventResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_odpf_raccoon_v1beta1_SendEventResponse_descriptor, + new java.lang.String[] { "Status", "Code", "SentTime", "Reason", "Data", }); + internal_static_odpf_raccoon_v1beta1_SendEventResponse_DataEntry_descriptor = + internal_static_odpf_raccoon_v1beta1_SendEventResponse_descriptor.getNestedTypes().get(0); + internal_static_odpf_raccoon_v1beta1_SendEventResponse_DataEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_odpf_raccoon_v1beta1_SendEventResponse_DataEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/EventServiceGrpc.java b/clients/java/src/main/java/io/odpf/proton/raccoon/EventServiceGrpc.java new file mode 100644 index 00000000..554fb3c6 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/EventServiceGrpc.java @@ -0,0 +1,276 @@ +package io.odpf.proton.raccoon; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.42.1)", + comments = "Source: .temp/odpf/raccoon/v1beta1/raccoon.proto") +@io.grpc.stub.annotations.GrpcGenerated +public final class EventServiceGrpc { + + private EventServiceGrpc() {} + + public static final String SERVICE_NAME = "odpf.raccoon.v1beta1.EventService"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor getSendEventMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "SendEvent", + requestType = io.odpf.proton.raccoon.SendEventRequest.class, + responseType = io.odpf.proton.raccoon.SendEventResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor getSendEventMethod() { + io.grpc.MethodDescriptor getSendEventMethod; + if ((getSendEventMethod = EventServiceGrpc.getSendEventMethod) == null) { + synchronized (EventServiceGrpc.class) { + if ((getSendEventMethod = EventServiceGrpc.getSendEventMethod) == null) { + EventServiceGrpc.getSendEventMethod = getSendEventMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "SendEvent")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.odpf.proton.raccoon.SendEventRequest.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + io.odpf.proton.raccoon.SendEventResponse.getDefaultInstance())) + .setSchemaDescriptor(new EventServiceMethodDescriptorSupplier("SendEvent")) + .build(); + } + } + } + return getSendEventMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static EventServiceStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public EventServiceStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new EventServiceStub(channel, callOptions); + } + }; + return EventServiceStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static EventServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public EventServiceBlockingStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new EventServiceBlockingStub(channel, callOptions); + } + }; + return EventServiceBlockingStub.newStub(factory, channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static EventServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public EventServiceFutureStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new EventServiceFutureStub(channel, callOptions); + } + }; + return EventServiceFutureStub.newStub(factory, channel); + } + + /** + */ + public static abstract class EventServiceImplBase implements io.grpc.BindableService { + + /** + */ + public void sendEvent(io.odpf.proton.raccoon.SendEventRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSendEventMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getSendEventMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + io.odpf.proton.raccoon.SendEventRequest, + io.odpf.proton.raccoon.SendEventResponse>( + this, METHODID_SEND_EVENT))) + .build(); + } + } + + /** + */ + public static final class EventServiceStub extends io.grpc.stub.AbstractAsyncStub { + private EventServiceStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected EventServiceStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new EventServiceStub(channel, callOptions); + } + + /** + */ + public void sendEvent(io.odpf.proton.raccoon.SendEventRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getSendEventMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class EventServiceBlockingStub extends io.grpc.stub.AbstractBlockingStub { + private EventServiceBlockingStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected EventServiceBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new EventServiceBlockingStub(channel, callOptions); + } + + /** + */ + public io.odpf.proton.raccoon.SendEventResponse sendEvent(io.odpf.proton.raccoon.SendEventRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getSendEventMethod(), getCallOptions(), request); + } + } + + /** + */ + public static final class EventServiceFutureStub extends io.grpc.stub.AbstractFutureStub { + private EventServiceFutureStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected EventServiceFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new EventServiceFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture sendEvent( + io.odpf.proton.raccoon.SendEventRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getSendEventMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_SEND_EVENT = 0; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final EventServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(EventServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SEND_EVENT: + serviceImpl.sendEvent((io.odpf.proton.raccoon.SendEventRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class EventServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + EventServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return io.odpf.proton.raccoon.EventProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("EventService"); + } + } + + private static final class EventServiceFileDescriptorSupplier + extends EventServiceBaseDescriptorSupplier { + EventServiceFileDescriptorSupplier() {} + } + + private static final class EventServiceMethodDescriptorSupplier + extends EventServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + EventServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (EventServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new EventServiceFileDescriptorSupplier()) + .addMethod(getSendEventMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventRequest.java b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventRequest.java new file mode 100644 index 00000000..5c0b8ded --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventRequest.java @@ -0,0 +1,1404 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +/** + *
+ * `EventRequest` defines the contract to push events to Raccoon
+ * An `EventRequest` allows you to push more than one events(batch). The events
+ * are wrapped inside `events` repeated field. All of the fields on `EventRequest`
+ * are required.
+ * 
+ * + * Protobuf type {@code odpf.raccoon.v1beta1.SendEventRequest} + */ +public final class SendEventRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:odpf.raccoon.v1beta1.SendEventRequest) + SendEventRequestOrBuilder { +private static final long serialVersionUID = 0L; + // Use SendEventRequest.newBuilder() to construct. + private SendEventRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SendEventRequest() { + reqGuid_ = ""; + events_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SendEventRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SendEventRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + reqGuid_ = s; + break; + } + case 18: { + com.google.protobuf.Timestamp.Builder subBuilder = null; + if (sentTime_ != null) { + subBuilder = sentTime_.toBuilder(); + } + sentTime_ = input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sentTime_); + sentTime_ = subBuilder.buildPartial(); + } + + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + events_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + events_.add( + input.readMessage(io.odpf.proton.raccoon.Event.parser(), extensionRegistry)); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + events_ = java.util.Collections.unmodifiableList(events_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.odpf.proton.raccoon.SendEventRequest.class, io.odpf.proton.raccoon.SendEventRequest.Builder.class); + } + + public static final int REQ_GUID_FIELD_NUMBER = 1; + private volatile java.lang.Object reqGuid_; + /** + *
+   * `req_guid` is unique identifier of the request the client is making.
+   * Raccoon uses the identifier to send response of the request. The client can handle the
+   * response accordingly. For example, the client can retry the request in case the response is
+   * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+   * This identifier is necessary because on event-based protocols like WebSocket the response is
+   * returned asynchronously. If there is no identifier, no way the client can tell which response
+   * belongs to which request.
+   * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+   * debug logs with `ReqGUID` keyword.
+   * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @return The reqGuid. + */ + @java.lang.Override + public java.lang.String getReqGuid() { + java.lang.Object ref = reqGuid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + reqGuid_ = s; + return s; + } + } + /** + *
+   * `req_guid` is unique identifier of the request the client is making.
+   * Raccoon uses the identifier to send response of the request. The client can handle the
+   * response accordingly. For example, the client can retry the request in case the response is
+   * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+   * This identifier is necessary because on event-based protocols like WebSocket the response is
+   * returned asynchronously. If there is no identifier, no way the client can tell which response
+   * belongs to which request.
+   * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+   * debug logs with `ReqGUID` keyword.
+   * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @return The bytes for reqGuid. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getReqGuidBytes() { + java.lang.Object ref = reqGuid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + reqGuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SENT_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp sentTime_; + /** + *
+   * `sent_time` defines the time the request is sent.
+   * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+   * request is sent until the events are published.
+   * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + * @return Whether the sentTime field is set. + */ + @java.lang.Override + public boolean hasSentTime() { + return sentTime_ != null; + } + /** + *
+   * `sent_time` defines the time the request is sent.
+   * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+   * request is sent until the events are published.
+   * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + * @return The sentTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSentTime() { + return sentTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : sentTime_; + } + /** + *
+   * `sent_time` defines the time the request is sent.
+   * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+   * request is sent until the events are published.
+   * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSentTimeOrBuilder() { + return getSentTime(); + } + + public static final int EVENTS_FIELD_NUMBER = 3; + private java.util.List events_; + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + @java.lang.Override + public java.util.List getEventsList() { + return events_; + } + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + @java.lang.Override + public java.util.List + getEventsOrBuilderList() { + return events_; + } + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + @java.lang.Override + public int getEventsCount() { + return events_.size(); + } + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + @java.lang.Override + public io.odpf.proton.raccoon.Event getEvents(int index) { + return events_.get(index); + } + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + @java.lang.Override + public io.odpf.proton.raccoon.EventOrBuilder getEventsOrBuilder( + int index) { + return events_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(reqGuid_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, reqGuid_); + } + if (sentTime_ != null) { + output.writeMessage(2, getSentTime()); + } + for (int i = 0; i < events_.size(); i++) { + output.writeMessage(3, events_.get(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(reqGuid_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, reqGuid_); + } + if (sentTime_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getSentTime()); + } + for (int i = 0; i < events_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, events_.get(i)); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.odpf.proton.raccoon.SendEventRequest)) { + return super.equals(obj); + } + io.odpf.proton.raccoon.SendEventRequest other = (io.odpf.proton.raccoon.SendEventRequest) obj; + + if (!getReqGuid() + .equals(other.getReqGuid())) return false; + if (hasSentTime() != other.hasSentTime()) return false; + if (hasSentTime()) { + if (!getSentTime() + .equals(other.getSentTime())) return false; + } + if (!getEventsList() + .equals(other.getEventsList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + REQ_GUID_FIELD_NUMBER; + hash = (53 * hash) + getReqGuid().hashCode(); + if (hasSentTime()) { + hash = (37 * hash) + SENT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSentTime().hashCode(); + } + if (getEventsCount() > 0) { + hash = (37 * hash) + EVENTS_FIELD_NUMBER; + hash = (53 * hash) + getEventsList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.SendEventRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.SendEventRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.odpf.proton.raccoon.SendEventRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * `EventRequest` defines the contract to push events to Raccoon
+   * An `EventRequest` allows you to push more than one events(batch). The events
+   * are wrapped inside `events` repeated field. All of the fields on `EventRequest`
+   * are required.
+   * 
+ * + * Protobuf type {@code odpf.raccoon.v1beta1.SendEventRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:odpf.raccoon.v1beta1.SendEventRequest) + io.odpf.proton.raccoon.SendEventRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.odpf.proton.raccoon.SendEventRequest.class, io.odpf.proton.raccoon.SendEventRequest.Builder.class); + } + + // Construct using io.odpf.proton.raccoon.SendEventRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + getEventsFieldBuilder(); + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + reqGuid_ = ""; + + if (sentTimeBuilder_ == null) { + sentTime_ = null; + } else { + sentTime_ = null; + sentTimeBuilder_ = null; + } + if (eventsBuilder_ == null) { + events_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + eventsBuilder_.clear(); + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventRequest_descriptor; + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventRequest getDefaultInstanceForType() { + return io.odpf.proton.raccoon.SendEventRequest.getDefaultInstance(); + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventRequest build() { + io.odpf.proton.raccoon.SendEventRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventRequest buildPartial() { + io.odpf.proton.raccoon.SendEventRequest result = new io.odpf.proton.raccoon.SendEventRequest(this); + int from_bitField0_ = bitField0_; + result.reqGuid_ = reqGuid_; + if (sentTimeBuilder_ == null) { + result.sentTime_ = sentTime_; + } else { + result.sentTime_ = sentTimeBuilder_.build(); + } + if (eventsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + events_ = java.util.Collections.unmodifiableList(events_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.events_ = events_; + } else { + result.events_ = eventsBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.odpf.proton.raccoon.SendEventRequest) { + return mergeFrom((io.odpf.proton.raccoon.SendEventRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.odpf.proton.raccoon.SendEventRequest other) { + if (other == io.odpf.proton.raccoon.SendEventRequest.getDefaultInstance()) return this; + if (!other.getReqGuid().isEmpty()) { + reqGuid_ = other.reqGuid_; + onChanged(); + } + if (other.hasSentTime()) { + mergeSentTime(other.getSentTime()); + } + if (eventsBuilder_ == null) { + if (!other.events_.isEmpty()) { + if (events_.isEmpty()) { + events_ = other.events_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureEventsIsMutable(); + events_.addAll(other.events_); + } + onChanged(); + } + } else { + if (!other.events_.isEmpty()) { + if (eventsBuilder_.isEmpty()) { + eventsBuilder_.dispose(); + eventsBuilder_ = null; + events_ = other.events_; + bitField0_ = (bitField0_ & ~0x00000001); + eventsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getEventsFieldBuilder() : null; + } else { + eventsBuilder_.addAllMessages(other.events_); + } + } + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.odpf.proton.raccoon.SendEventRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.odpf.proton.raccoon.SendEventRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.lang.Object reqGuid_ = ""; + /** + *
+     * `req_guid` is unique identifier of the request the client is making.
+     * Raccoon uses the identifier to send response of the request. The client can handle the
+     * response accordingly. For example, the client can retry the request in case the response is
+     * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+     * This identifier is necessary because on event-based protocols like WebSocket the response is
+     * returned asynchronously. If there is no identifier, no way the client can tell which response
+     * belongs to which request.
+     * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+     * debug logs with `ReqGUID` keyword.
+     * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @return The reqGuid. + */ + public java.lang.String getReqGuid() { + java.lang.Object ref = reqGuid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + reqGuid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * `req_guid` is unique identifier of the request the client is making.
+     * Raccoon uses the identifier to send response of the request. The client can handle the
+     * response accordingly. For example, the client can retry the request in case the response is
+     * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+     * This identifier is necessary because on event-based protocols like WebSocket the response is
+     * returned asynchronously. If there is no identifier, no way the client can tell which response
+     * belongs to which request.
+     * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+     * debug logs with `ReqGUID` keyword.
+     * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @return The bytes for reqGuid. + */ + public com.google.protobuf.ByteString + getReqGuidBytes() { + java.lang.Object ref = reqGuid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + reqGuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * `req_guid` is unique identifier of the request the client is making.
+     * Raccoon uses the identifier to send response of the request. The client can handle the
+     * response accordingly. For example, the client can retry the request in case the response is
+     * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+     * This identifier is necessary because on event-based protocols like WebSocket the response is
+     * returned asynchronously. If there is no identifier, no way the client can tell which response
+     * belongs to which request.
+     * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+     * debug logs with `ReqGUID` keyword.
+     * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @param value The reqGuid to set. + * @return This builder for chaining. + */ + public Builder setReqGuid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + reqGuid_ = value; + onChanged(); + return this; + } + /** + *
+     * `req_guid` is unique identifier of the request the client is making.
+     * Raccoon uses the identifier to send response of the request. The client can handle the
+     * response accordingly. For example, the client can retry the request in case the response is
+     * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+     * This identifier is necessary because on event-based protocols like WebSocket the response is
+     * returned asynchronously. If there is no identifier, no way the client can tell which response
+     * belongs to which request.
+     * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+     * debug logs with `ReqGUID` keyword.
+     * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @return This builder for chaining. + */ + public Builder clearReqGuid() { + + reqGuid_ = getDefaultInstance().getReqGuid(); + onChanged(); + return this; + } + /** + *
+     * `req_guid` is unique identifier of the request the client is making.
+     * Raccoon uses the identifier to send response of the request. The client can handle the
+     * response accordingly. For example, the client can retry the request in case the response is
+     * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+     * This identifier is necessary because on event-based protocols like WebSocket the response is
+     * returned asynchronously. If there is no identifier, no way the client can tell which response
+     * belongs to which request.
+     * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+     * debug logs with `ReqGUID` keyword.
+     * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @param value The bytes for reqGuid to set. + * @return This builder for chaining. + */ + public Builder setReqGuidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + reqGuid_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp sentTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> sentTimeBuilder_; + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + * @return Whether the sentTime field is set. + */ + public boolean hasSentTime() { + return sentTimeBuilder_ != null || sentTime_ != null; + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + * @return The sentTime. + */ + public com.google.protobuf.Timestamp getSentTime() { + if (sentTimeBuilder_ == null) { + return sentTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : sentTime_; + } else { + return sentTimeBuilder_.getMessage(); + } + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + public Builder setSentTime(com.google.protobuf.Timestamp value) { + if (sentTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sentTime_ = value; + onChanged(); + } else { + sentTimeBuilder_.setMessage(value); + } + + return this; + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + public Builder setSentTime( + com.google.protobuf.Timestamp.Builder builderForValue) { + if (sentTimeBuilder_ == null) { + sentTime_ = builderForValue.build(); + onChanged(); + } else { + sentTimeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + public Builder mergeSentTime(com.google.protobuf.Timestamp value) { + if (sentTimeBuilder_ == null) { + if (sentTime_ != null) { + sentTime_ = + com.google.protobuf.Timestamp.newBuilder(sentTime_).mergeFrom(value).buildPartial(); + } else { + sentTime_ = value; + } + onChanged(); + } else { + sentTimeBuilder_.mergeFrom(value); + } + + return this; + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + public Builder clearSentTime() { + if (sentTimeBuilder_ == null) { + sentTime_ = null; + onChanged(); + } else { + sentTime_ = null; + sentTimeBuilder_ = null; + } + + return this; + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + public com.google.protobuf.Timestamp.Builder getSentTimeBuilder() { + + onChanged(); + return getSentTimeFieldBuilder().getBuilder(); + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + public com.google.protobuf.TimestampOrBuilder getSentTimeOrBuilder() { + if (sentTimeBuilder_ != null) { + return sentTimeBuilder_.getMessageOrBuilder(); + } else { + return sentTime_ == null ? + com.google.protobuf.Timestamp.getDefaultInstance() : sentTime_; + } + } + /** + *
+     * `sent_time` defines the time the request is sent.
+     * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+     * request is sent until the events are published.
+     * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> + getSentTimeFieldBuilder() { + if (sentTimeBuilder_ == null) { + sentTimeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder>( + getSentTime(), + getParentForChildren(), + isClean()); + sentTime_ = null; + } + return sentTimeBuilder_; + } + + private java.util.List events_ = + java.util.Collections.emptyList(); + private void ensureEventsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + events_ = new java.util.ArrayList(events_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + io.odpf.proton.raccoon.Event, io.odpf.proton.raccoon.Event.Builder, io.odpf.proton.raccoon.EventOrBuilder> eventsBuilder_; + + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public java.util.List getEventsList() { + if (eventsBuilder_ == null) { + return java.util.Collections.unmodifiableList(events_); + } else { + return eventsBuilder_.getMessageList(); + } + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public int getEventsCount() { + if (eventsBuilder_ == null) { + return events_.size(); + } else { + return eventsBuilder_.getCount(); + } + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public io.odpf.proton.raccoon.Event getEvents(int index) { + if (eventsBuilder_ == null) { + return events_.get(index); + } else { + return eventsBuilder_.getMessage(index); + } + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder setEvents( + int index, io.odpf.proton.raccoon.Event value) { + if (eventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventsIsMutable(); + events_.set(index, value); + onChanged(); + } else { + eventsBuilder_.setMessage(index, value); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder setEvents( + int index, io.odpf.proton.raccoon.Event.Builder builderForValue) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.set(index, builderForValue.build()); + onChanged(); + } else { + eventsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder addEvents(io.odpf.proton.raccoon.Event value) { + if (eventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventsIsMutable(); + events_.add(value); + onChanged(); + } else { + eventsBuilder_.addMessage(value); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder addEvents( + int index, io.odpf.proton.raccoon.Event value) { + if (eventsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEventsIsMutable(); + events_.add(index, value); + onChanged(); + } else { + eventsBuilder_.addMessage(index, value); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder addEvents( + io.odpf.proton.raccoon.Event.Builder builderForValue) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.add(builderForValue.build()); + onChanged(); + } else { + eventsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder addEvents( + int index, io.odpf.proton.raccoon.Event.Builder builderForValue) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.add(index, builderForValue.build()); + onChanged(); + } else { + eventsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder addAllEvents( + java.lang.Iterable values) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, events_); + onChanged(); + } else { + eventsBuilder_.addAllMessages(values); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder clearEvents() { + if (eventsBuilder_ == null) { + events_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + eventsBuilder_.clear(); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public Builder removeEvents(int index) { + if (eventsBuilder_ == null) { + ensureEventsIsMutable(); + events_.remove(index); + onChanged(); + } else { + eventsBuilder_.remove(index); + } + return this; + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public io.odpf.proton.raccoon.Event.Builder getEventsBuilder( + int index) { + return getEventsFieldBuilder().getBuilder(index); + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public io.odpf.proton.raccoon.EventOrBuilder getEventsOrBuilder( + int index) { + if (eventsBuilder_ == null) { + return events_.get(index); } else { + return eventsBuilder_.getMessageOrBuilder(index); + } + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public java.util.List + getEventsOrBuilderList() { + if (eventsBuilder_ != null) { + return eventsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(events_); + } + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public io.odpf.proton.raccoon.Event.Builder addEventsBuilder() { + return getEventsFieldBuilder().addBuilder( + io.odpf.proton.raccoon.Event.getDefaultInstance()); + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public io.odpf.proton.raccoon.Event.Builder addEventsBuilder( + int index) { + return getEventsFieldBuilder().addBuilder( + index, io.odpf.proton.raccoon.Event.getDefaultInstance()); + } + /** + *
+     * `events` is where the client put all the events wrapped in `Event`.
+     * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+     * the events to optimize the network call. 
+     * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + public java.util.List + getEventsBuilderList() { + return getEventsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + io.odpf.proton.raccoon.Event, io.odpf.proton.raccoon.Event.Builder, io.odpf.proton.raccoon.EventOrBuilder> + getEventsFieldBuilder() { + if (eventsBuilder_ == null) { + eventsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + io.odpf.proton.raccoon.Event, io.odpf.proton.raccoon.Event.Builder, io.odpf.proton.raccoon.EventOrBuilder>( + events_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + events_ = null; + } + return eventsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:odpf.raccoon.v1beta1.SendEventRequest) + } + + // @@protoc_insertion_point(class_scope:odpf.raccoon.v1beta1.SendEventRequest) + private static final io.odpf.proton.raccoon.SendEventRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.odpf.proton.raccoon.SendEventRequest(); + } + + public static io.odpf.proton.raccoon.SendEventRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SendEventRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SendEventRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventRequestOrBuilder.java b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventRequestOrBuilder.java new file mode 100644 index 00000000..626b6a67 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventRequestOrBuilder.java @@ -0,0 +1,132 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +public interface SendEventRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:odpf.raccoon.v1beta1.SendEventRequest) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * `req_guid` is unique identifier of the request the client is making.
+   * Raccoon uses the identifier to send response of the request. The client can handle the
+   * response accordingly. For example, the client can retry the request in case the response is
+   * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+   * This identifier is necessary because on event-based protocols like WebSocket the response is
+   * returned asynchronously. If there is no identifier, no way the client can tell which response
+   * belongs to which request.
+   * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+   * debug logs with `ReqGUID` keyword.
+   * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @return The reqGuid. + */ + java.lang.String getReqGuid(); + /** + *
+   * `req_guid` is unique identifier of the request the client is making.
+   * Raccoon uses the identifier to send response of the request. The client can handle the
+   * response accordingly. For example, the client can retry the request in case the response is
+   * giving `INTERNAL_ERROR` code with "publisher failed" reason.
+   * This identifier is necessary because on event-based protocols like WebSocket the response is
+   * returned asynchronously. If there is no identifier, no way the client can tell which response
+   * belongs to which request.
+   * Apart from sending response, `req_guid` is used to log some informations on 'debug' level. You can search the 
+   * debug logs with `ReqGUID` keyword.
+   * 
+ * + * string req_guid = 1 [json_name = "reqGuid"]; + * @return The bytes for reqGuid. + */ + com.google.protobuf.ByteString + getReqGuidBytes(); + + /** + *
+   * `sent_time` defines the time the request is sent.
+   * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+   * request is sent until the events are published.
+   * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + * @return Whether the sentTime field is set. + */ + boolean hasSentTime(); + /** + *
+   * `sent_time` defines the time the request is sent.
+   * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+   * request is sent until the events are published.
+   * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + * @return The sentTime. + */ + com.google.protobuf.Timestamp getSentTime(); + /** + *
+   * `sent_time` defines the time the request is sent.
+   * `sent_time` is used to calculate various metrics. The main metric uses `sent_time` is duration from the
+   * request is sent until the events are published.
+   * 
+ * + * .google.protobuf.Timestamp sent_time = 2 [json_name = "sentTime"]; + */ + com.google.protobuf.TimestampOrBuilder getSentTimeOrBuilder(); + + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + java.util.List + getEventsList(); + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + io.odpf.proton.raccoon.Event getEvents(int index); + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + int getEventsCount(); + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + java.util.List + getEventsOrBuilderList(); + /** + *
+   * `events` is where the client put all the events wrapped in `Event`.
+   * As mentioned above, the request allows the client to push more than one event. Normally you want to batch
+   * the events to optimize the network call. 
+   * 
+ * + * repeated .odpf.raccoon.v1beta1.Event events = 3 [json_name = "events"]; + */ + io.odpf.proton.raccoon.EventOrBuilder getEventsOrBuilder( + int index); +} diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventResponse.java b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventResponse.java new file mode 100644 index 00000000..f98ce4c1 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventResponse.java @@ -0,0 +1,1304 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +/** + * Protobuf type {@code odpf.raccoon.v1beta1.SendEventResponse} + */ +public final class SendEventResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:odpf.raccoon.v1beta1.SendEventResponse) + SendEventResponseOrBuilder { +private static final long serialVersionUID = 0L; + // Use SendEventResponse.newBuilder() to construct. + private SendEventResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private SendEventResponse() { + status_ = 0; + code_ = 0; + reason_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new SendEventResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private SendEventResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + int rawValue = input.readEnum(); + + status_ = rawValue; + break; + } + case 16: { + int rawValue = input.readEnum(); + + code_ = rawValue; + break; + } + case 24: { + + sentTime_ = input.readInt64(); + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); + + reason_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + data_ = com.google.protobuf.MapField.newMapField( + DataDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000001; + } + com.google.protobuf.MapEntry + data__ = input.readMessage( + DataDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + data_.getMutableMap().put( + data__.getKey(), data__.getValue()); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventResponse_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 5: + return internalGetData(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.odpf.proton.raccoon.SendEventResponse.class, io.odpf.proton.raccoon.SendEventResponse.Builder.class); + } + + public static final int STATUS_FIELD_NUMBER = 1; + private int status_; + /** + *
+   * `status` denotes status of the request.
+   * Only 3 values are valid. `SUCCESS` means the the request is processed
+   * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+   * means Raccoon unable to determine whether the request is success or not.
+   * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @return The enum numeric value on the wire for status. + */ + @java.lang.Override public int getStatusValue() { + return status_; + } + /** + *
+   * `status` denotes status of the request.
+   * Only 3 values are valid. `SUCCESS` means the the request is processed
+   * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+   * means Raccoon unable to determine whether the request is success or not.
+   * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @return The status. + */ + @java.lang.Override public io.odpf.proton.raccoon.Status getStatus() { + @SuppressWarnings("deprecation") + io.odpf.proton.raccoon.Status result = io.odpf.proton.raccoon.Status.valueOf(status_); + return result == null ? io.odpf.proton.raccoon.Status.UNRECOGNIZED : result; + } + + public static final int CODE_FIELD_NUMBER = 2; + private int code_; + /** + *
+   * `code` gives more detail of what happened to the request.
+   * Details of available `code` can be seen below.
+   * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @return The enum numeric value on the wire for code. + */ + @java.lang.Override public int getCodeValue() { + return code_; + } + /** + *
+   * `code` gives more detail of what happened to the request.
+   * Details of available `code` can be seen below.
+   * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @return The code. + */ + @java.lang.Override public io.odpf.proton.raccoon.Code getCode() { + @SuppressWarnings("deprecation") + io.odpf.proton.raccoon.Code result = io.odpf.proton.raccoon.Code.valueOf(code_); + return result == null ? io.odpf.proton.raccoon.Code.UNRECOGNIZED : result; + } + + public static final int SENT_TIME_FIELD_NUMBER = 3; + private long sentTime_; + /** + *
+   * `sent_time` is UNIX timestamp populated by Raccoon by the time the response is sent.
+   * 
+ * + * int64 sent_time = 3 [json_name = "sentTime"]; + * @return The sentTime. + */ + @java.lang.Override + public long getSentTime() { + return sentTime_; + } + + public static final int REASON_FIELD_NUMBER = 4; + private volatile java.lang.Object reason_; + /** + *
+   * `reason` is additional-human readable information to provide more context to `status` and `code`.
+   * There is no predefined structure for this. The value is arbitrary.
+   * 
+ * + * string reason = 4 [json_name = "reason"]; + * @return The reason. + */ + @java.lang.Override + public java.lang.String getReason() { + java.lang.Object ref = reason_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + reason_ = s; + return s; + } + } + /** + *
+   * `reason` is additional-human readable information to provide more context to `status` and `code`.
+   * There is no predefined structure for this. The value is arbitrary.
+   * 
+ * + * string reason = 4 [json_name = "reason"]; + * @return The bytes for reason. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getReasonBytes() { + java.lang.Object ref = reason_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + reason_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATA_FIELD_NUMBER = 5; + private static final class DataDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventResponse_DataEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> data_; + private com.google.protobuf.MapField + internalGetData() { + if (data_ == null) { + return com.google.protobuf.MapField.emptyMapField( + DataDefaultEntryHolder.defaultEntry); + } + return data_; + } + + public int getDataCount() { + return internalGetData().getMap().size(); + } + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + + @java.lang.Override + public boolean containsData( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetData().getMap().containsKey(key); + } + /** + * Use {@link #getDataMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getData() { + return getDataMap(); + } + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + @java.lang.Override + + public java.util.Map getDataMap() { + return internalGetData().getMap(); + } + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + @java.lang.Override + + public java.lang.String getDataOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetData().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + @java.lang.Override + + public java.lang.String getDataOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetData().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (status_ != io.odpf.proton.raccoon.Status.STATUS_UNSPECIFIED.getNumber()) { + output.writeEnum(1, status_); + } + if (code_ != io.odpf.proton.raccoon.Code.CODE_UNSPECIFIED.getNumber()) { + output.writeEnum(2, code_); + } + if (sentTime_ != 0L) { + output.writeInt64(3, sentTime_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(reason_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, reason_); + } + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetData(), + DataDefaultEntryHolder.defaultEntry, + 5); + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (status_ != io.odpf.proton.raccoon.Status.STATUS_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(1, status_); + } + if (code_ != io.odpf.proton.raccoon.Code.CODE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, code_); + } + if (sentTime_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(3, sentTime_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(reason_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, reason_); + } + for (java.util.Map.Entry entry + : internalGetData().getMap().entrySet()) { + com.google.protobuf.MapEntry + data__ = DataDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(5, data__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof io.odpf.proton.raccoon.SendEventResponse)) { + return super.equals(obj); + } + io.odpf.proton.raccoon.SendEventResponse other = (io.odpf.proton.raccoon.SendEventResponse) obj; + + if (status_ != other.status_) return false; + if (code_ != other.code_) return false; + if (getSentTime() + != other.getSentTime()) return false; + if (!getReason() + .equals(other.getReason())) return false; + if (!internalGetData().equals( + other.internalGetData())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + STATUS_FIELD_NUMBER; + hash = (53 * hash) + status_; + hash = (37 * hash) + CODE_FIELD_NUMBER; + hash = (53 * hash) + code_; + hash = (37 * hash) + SENT_TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSentTime()); + hash = (37 * hash) + REASON_FIELD_NUMBER; + hash = (53 * hash) + getReason().hashCode(); + if (!internalGetData().getMap().isEmpty()) { + hash = (37 * hash) + DATA_FIELD_NUMBER; + hash = (53 * hash) + internalGetData().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.SendEventResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static io.odpf.proton.raccoon.SendEventResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.odpf.proton.raccoon.SendEventResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code odpf.raccoon.v1beta1.SendEventResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:odpf.raccoon.v1beta1.SendEventResponse) + io.odpf.proton.raccoon.SendEventResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventResponse_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 5: + return internalGetData(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 5: + return internalGetMutableData(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.odpf.proton.raccoon.SendEventResponse.class, io.odpf.proton.raccoon.SendEventResponse.Builder.class); + } + + // Construct using io.odpf.proton.raccoon.SendEventResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + status_ = 0; + + code_ = 0; + + sentTime_ = 0L; + + reason_ = ""; + + internalGetMutableData().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.odpf.proton.raccoon.EventProto.internal_static_odpf_raccoon_v1beta1_SendEventResponse_descriptor; + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventResponse getDefaultInstanceForType() { + return io.odpf.proton.raccoon.SendEventResponse.getDefaultInstance(); + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventResponse build() { + io.odpf.proton.raccoon.SendEventResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventResponse buildPartial() { + io.odpf.proton.raccoon.SendEventResponse result = new io.odpf.proton.raccoon.SendEventResponse(this); + int from_bitField0_ = bitField0_; + result.status_ = status_; + result.code_ = code_; + result.sentTime_ = sentTime_; + result.reason_ = reason_; + result.data_ = internalGetData(); + result.data_.makeImmutable(); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.odpf.proton.raccoon.SendEventResponse) { + return mergeFrom((io.odpf.proton.raccoon.SendEventResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.odpf.proton.raccoon.SendEventResponse other) { + if (other == io.odpf.proton.raccoon.SendEventResponse.getDefaultInstance()) return this; + if (other.status_ != 0) { + setStatusValue(other.getStatusValue()); + } + if (other.code_ != 0) { + setCodeValue(other.getCodeValue()); + } + if (other.getSentTime() != 0L) { + setSentTime(other.getSentTime()); + } + if (!other.getReason().isEmpty()) { + reason_ = other.reason_; + onChanged(); + } + internalGetMutableData().mergeFrom( + other.internalGetData()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.odpf.proton.raccoon.SendEventResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.odpf.proton.raccoon.SendEventResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private int status_ = 0; + /** + *
+     * `status` denotes status of the request.
+     * Only 3 values are valid. `SUCCESS` means the the request is processed
+     * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+     * means Raccoon unable to determine whether the request is success or not.
+     * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @return The enum numeric value on the wire for status. + */ + @java.lang.Override public int getStatusValue() { + return status_; + } + /** + *
+     * `status` denotes status of the request.
+     * Only 3 values are valid. `SUCCESS` means the the request is processed
+     * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+     * means Raccoon unable to determine whether the request is success or not.
+     * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @param value The enum numeric value on the wire for status to set. + * @return This builder for chaining. + */ + public Builder setStatusValue(int value) { + + status_ = value; + onChanged(); + return this; + } + /** + *
+     * `status` denotes status of the request.
+     * Only 3 values are valid. `SUCCESS` means the the request is processed
+     * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+     * means Raccoon unable to determine whether the request is success or not.
+     * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @return The status. + */ + @java.lang.Override + public io.odpf.proton.raccoon.Status getStatus() { + @SuppressWarnings("deprecation") + io.odpf.proton.raccoon.Status result = io.odpf.proton.raccoon.Status.valueOf(status_); + return result == null ? io.odpf.proton.raccoon.Status.UNRECOGNIZED : result; + } + /** + *
+     * `status` denotes status of the request.
+     * Only 3 values are valid. `SUCCESS` means the the request is processed
+     * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+     * means Raccoon unable to determine whether the request is success or not.
+     * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @param value The status to set. + * @return This builder for chaining. + */ + public Builder setStatus(io.odpf.proton.raccoon.Status value) { + if (value == null) { + throw new NullPointerException(); + } + + status_ = value.getNumber(); + onChanged(); + return this; + } + /** + *
+     * `status` denotes status of the request.
+     * Only 3 values are valid. `SUCCESS` means the the request is processed
+     * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+     * means Raccoon unable to determine whether the request is success or not.
+     * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @return This builder for chaining. + */ + public Builder clearStatus() { + + status_ = 0; + onChanged(); + return this; + } + + private int code_ = 0; + /** + *
+     * `code` gives more detail of what happened to the request.
+     * Details of available `code` can be seen below.
+     * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @return The enum numeric value on the wire for code. + */ + @java.lang.Override public int getCodeValue() { + return code_; + } + /** + *
+     * `code` gives more detail of what happened to the request.
+     * Details of available `code` can be seen below.
+     * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @param value The enum numeric value on the wire for code to set. + * @return This builder for chaining. + */ + public Builder setCodeValue(int value) { + + code_ = value; + onChanged(); + return this; + } + /** + *
+     * `code` gives more detail of what happened to the request.
+     * Details of available `code` can be seen below.
+     * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @return The code. + */ + @java.lang.Override + public io.odpf.proton.raccoon.Code getCode() { + @SuppressWarnings("deprecation") + io.odpf.proton.raccoon.Code result = io.odpf.proton.raccoon.Code.valueOf(code_); + return result == null ? io.odpf.proton.raccoon.Code.UNRECOGNIZED : result; + } + /** + *
+     * `code` gives more detail of what happened to the request.
+     * Details of available `code` can be seen below.
+     * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @param value The code to set. + * @return This builder for chaining. + */ + public Builder setCode(io.odpf.proton.raccoon.Code value) { + if (value == null) { + throw new NullPointerException(); + } + + code_ = value.getNumber(); + onChanged(); + return this; + } + /** + *
+     * `code` gives more detail of what happened to the request.
+     * Details of available `code` can be seen below.
+     * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @return This builder for chaining. + */ + public Builder clearCode() { + + code_ = 0; + onChanged(); + return this; + } + + private long sentTime_ ; + /** + *
+     * `sent_time` is UNIX timestamp populated by Raccoon by the time the response is sent.
+     * 
+ * + * int64 sent_time = 3 [json_name = "sentTime"]; + * @return The sentTime. + */ + @java.lang.Override + public long getSentTime() { + return sentTime_; + } + /** + *
+     * `sent_time` is UNIX timestamp populated by Raccoon by the time the response is sent.
+     * 
+ * + * int64 sent_time = 3 [json_name = "sentTime"]; + * @param value The sentTime to set. + * @return This builder for chaining. + */ + public Builder setSentTime(long value) { + + sentTime_ = value; + onChanged(); + return this; + } + /** + *
+     * `sent_time` is UNIX timestamp populated by Raccoon by the time the response is sent.
+     * 
+ * + * int64 sent_time = 3 [json_name = "sentTime"]; + * @return This builder for chaining. + */ + public Builder clearSentTime() { + + sentTime_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object reason_ = ""; + /** + *
+     * `reason` is additional-human readable information to provide more context to `status` and `code`.
+     * There is no predefined structure for this. The value is arbitrary.
+     * 
+ * + * string reason = 4 [json_name = "reason"]; + * @return The reason. + */ + public java.lang.String getReason() { + java.lang.Object ref = reason_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + reason_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + *
+     * `reason` is additional-human readable information to provide more context to `status` and `code`.
+     * There is no predefined structure for this. The value is arbitrary.
+     * 
+ * + * string reason = 4 [json_name = "reason"]; + * @return The bytes for reason. + */ + public com.google.protobuf.ByteString + getReasonBytes() { + java.lang.Object ref = reason_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + reason_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+     * `reason` is additional-human readable information to provide more context to `status` and `code`.
+     * There is no predefined structure for this. The value is arbitrary.
+     * 
+ * + * string reason = 4 [json_name = "reason"]; + * @param value The reason to set. + * @return This builder for chaining. + */ + public Builder setReason( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + reason_ = value; + onChanged(); + return this; + } + /** + *
+     * `reason` is additional-human readable information to provide more context to `status` and `code`.
+     * There is no predefined structure for this. The value is arbitrary.
+     * 
+ * + * string reason = 4 [json_name = "reason"]; + * @return This builder for chaining. + */ + public Builder clearReason() { + + reason_ = getDefaultInstance().getReason(); + onChanged(); + return this; + } + /** + *
+     * `reason` is additional-human readable information to provide more context to `status` and `code`.
+     * There is no predefined structure for this. The value is arbitrary.
+     * 
+ * + * string reason = 4 [json_name = "reason"]; + * @param value The bytes for reason to set. + * @return This builder for chaining. + */ + public Builder setReasonBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + reason_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> data_; + private com.google.protobuf.MapField + internalGetData() { + if (data_ == null) { + return com.google.protobuf.MapField.emptyMapField( + DataDefaultEntryHolder.defaultEntry); + } + return data_; + } + private com.google.protobuf.MapField + internalGetMutableData() { + onChanged();; + if (data_ == null) { + data_ = com.google.protobuf.MapField.newMapField( + DataDefaultEntryHolder.defaultEntry); + } + if (!data_.isMutable()) { + data_ = data_.copy(); + } + return data_; + } + + public int getDataCount() { + return internalGetData().getMap().size(); + } + /** + *
+     * `data` is arbitrary extra metadata.
+     * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+     * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+     * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + + @java.lang.Override + public boolean containsData( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetData().getMap().containsKey(key); + } + /** + * Use {@link #getDataMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getData() { + return getDataMap(); + } + /** + *
+     * `data` is arbitrary extra metadata.
+     * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+     * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+     * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + @java.lang.Override + + public java.util.Map getDataMap() { + return internalGetData().getMap(); + } + /** + *
+     * `data` is arbitrary extra metadata.
+     * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+     * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+     * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + @java.lang.Override + + public java.lang.String getDataOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetData().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + *
+     * `data` is arbitrary extra metadata.
+     * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+     * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+     * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + @java.lang.Override + + public java.lang.String getDataOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetData().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearData() { + internalGetMutableData().getMutableMap() + .clear(); + return this; + } + /** + *
+     * `data` is arbitrary extra metadata.
+     * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+     * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+     * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + + public Builder removeData( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + internalGetMutableData().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableData() { + return internalGetMutableData().getMutableMap(); + } + /** + *
+     * `data` is arbitrary extra metadata.
+     * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+     * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+     * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + public Builder putData( + java.lang.String key, + java.lang.String value) { + if (key == null) { throw new NullPointerException("map key"); } + if (value == null) { + throw new NullPointerException("map value"); +} + + internalGetMutableData().getMutableMap() + .put(key, value); + return this; + } + /** + *
+     * `data` is arbitrary extra metadata.
+     * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+     * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+     * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + + public Builder putAllData( + java.util.Map values) { + internalGetMutableData().getMutableMap() + .putAll(values); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:odpf.raccoon.v1beta1.SendEventResponse) + } + + // @@protoc_insertion_point(class_scope:odpf.raccoon.v1beta1.SendEventResponse) + private static final io.odpf.proton.raccoon.SendEventResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.odpf.proton.raccoon.SendEventResponse(); + } + + public static io.odpf.proton.raccoon.SendEventResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SendEventResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new SendEventResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public io.odpf.proton.raccoon.SendEventResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventResponseOrBuilder.java b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventResponseOrBuilder.java new file mode 100644 index 00000000..47f33fe1 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/SendEventResponseOrBuilder.java @@ -0,0 +1,151 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +public interface SendEventResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:odpf.raccoon.v1beta1.SendEventResponse) + com.google.protobuf.MessageOrBuilder { + + /** + *
+   * `status` denotes status of the request.
+   * Only 3 values are valid. `SUCCESS` means the the request is processed
+   * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+   * means Raccoon unable to determine whether the request is success or not.
+   * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @return The enum numeric value on the wire for status. + */ + int getStatusValue(); + /** + *
+   * `status` denotes status of the request.
+   * Only 3 values are valid. `SUCCESS` means the the request is processed
+   * successfully. `ERROR` means the request failed to be processed. `UNKNOWN_STATUS` 
+   * means Raccoon unable to determine whether the request is success or not.
+   * 
+ * + * .odpf.raccoon.v1beta1.Status status = 1 [json_name = "status"]; + * @return The status. + */ + io.odpf.proton.raccoon.Status getStatus(); + + /** + *
+   * `code` gives more detail of what happened to the request.
+   * Details of available `code` can be seen below.
+   * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @return The enum numeric value on the wire for code. + */ + int getCodeValue(); + /** + *
+   * `code` gives more detail of what happened to the request.
+   * Details of available `code` can be seen below.
+   * 
+ * + * .odpf.raccoon.v1beta1.Code code = 2 [json_name = "code"]; + * @return The code. + */ + io.odpf.proton.raccoon.Code getCode(); + + /** + *
+   * `sent_time` is UNIX timestamp populated by Raccoon by the time the response is sent.
+   * 
+ * + * int64 sent_time = 3 [json_name = "sentTime"]; + * @return The sentTime. + */ + long getSentTime(); + + /** + *
+   * `reason` is additional-human readable information to provide more context to `status` and `code`.
+   * There is no predefined structure for this. The value is arbitrary.
+   * 
+ * + * string reason = 4 [json_name = "reason"]; + * @return The reason. + */ + java.lang.String getReason(); + /** + *
+   * `reason` is additional-human readable information to provide more context to `status` and `code`.
+   * There is no predefined structure for this. The value is arbitrary.
+   * 
+ * + * string reason = 4 [json_name = "reason"]; + * @return The bytes for reason. + */ + com.google.protobuf.ByteString + getReasonBytes(); + + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + int getDataCount(); + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + boolean containsData( + java.lang.String key); + /** + * Use {@link #getDataMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getData(); + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + java.util.Map + getDataMap(); + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + + java.lang.String getDataOrDefault( + java.lang.String key, + java.lang.String defaultValue); + /** + *
+   * `data` is arbitrary extra metadata.
+   * Arbitrary key-value makes the field flexible for future changes. `req_guid` is also sent as part
+   * of `data`. The client may fetch req_guid as key to get the `req_guid` value.
+   * 
+ * + * map<string, string> data = 5 [json_name = "data"]; + */ + + java.lang.String getDataOrThrow( + java.lang.String key); +} diff --git a/clients/java/src/main/java/io/odpf/proton/raccoon/Status.java b/clients/java/src/main/java/io/odpf/proton/raccoon/Status.java new file mode 100644 index 00000000..1e75c0dc --- /dev/null +++ b/clients/java/src/main/java/io/odpf/proton/raccoon/Status.java @@ -0,0 +1,122 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: .temp/odpf/raccoon/v1beta1/raccoon.proto + +package io.odpf.proton.raccoon; + +/** + * Protobuf enum {@code odpf.raccoon.v1beta1.Status} + */ +public enum Status + implements com.google.protobuf.ProtocolMessageEnum { + /** + * STATUS_UNSPECIFIED = 0; + */ + STATUS_UNSPECIFIED(0), + /** + * STATUS_SUCCESS = 1; + */ + STATUS_SUCCESS(1), + /** + * STATUS_ERROR = 2; + */ + STATUS_ERROR(2), + UNRECOGNIZED(-1), + ; + + /** + * STATUS_UNSPECIFIED = 0; + */ + public static final int STATUS_UNSPECIFIED_VALUE = 0; + /** + * STATUS_SUCCESS = 1; + */ + public static final int STATUS_SUCCESS_VALUE = 1; + /** + * STATUS_ERROR = 2; + */ + public static final int STATUS_ERROR_VALUE = 2; + + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Status valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Status forNumber(int value) { + switch (value) { + case 0: return STATUS_UNSPECIFIED; + case 1: return STATUS_SUCCESS; + case 2: return STATUS_ERROR; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + Status> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Status findValueByNumber(int number) { + return Status.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return io.odpf.proton.raccoon.EventProto.getDescriptor().getEnumTypes().get(0); + } + + private static final Status[] VALUES = values(); + + public static Status valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Status(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:odpf.raccoon.v1beta1.Status) +} + diff --git a/clients/java/src/main/java/io/odpf/raccoon/client/RaccoonClient.java b/clients/java/src/main/java/io/odpf/raccoon/client/RaccoonClient.java new file mode 100644 index 00000000..f14b816b --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/client/RaccoonClient.java @@ -0,0 +1,17 @@ +package io.odpf.raccoon.client; + +import io.odpf.raccoon.model.Event; +import io.odpf.raccoon.model.Response; + +/** + * An interface for the raccoon clients. + */ +public interface RaccoonClient { + /** + * Sends a request to raccoon with the message provided. + * + * @param events The raccoon event message array. + * @return {@link Response} The raccoon response. + */ + Response send(Event[] events); +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/client/RaccoonClientFactory.java b/clients/java/src/main/java/io/odpf/raccoon/client/RaccoonClientFactory.java new file mode 100644 index 00000000..81f08656 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/client/RaccoonClientFactory.java @@ -0,0 +1,18 @@ +package io.odpf.raccoon.client; + +import lombok.NonNull; + +/** + * Factory for raccoon client. + */ +public class RaccoonClientFactory { + /** + * Creates the new Rest client for the raccoon. + * + * @param restConfig The rest config options. + * @return RestClient The rest client. + */ + public static RaccoonClient getRestClient(@NonNull RestConfig restConfig) { + return new RestClient(restConfig); + } +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/client/RestClient.java b/clients/java/src/main/java/io/odpf/raccoon/client/RestClient.java new file mode 100644 index 00000000..f78bfbe8 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/client/RestClient.java @@ -0,0 +1,142 @@ +package io.odpf.raccoon.client; + +import com.google.api.client.http.HttpStatusCodes; +import com.google.common.io.ByteStreams; +import com.google.protobuf.ByteString; +import io.odpf.proton.raccoon.Event.Builder; +import io.odpf.proton.raccoon.SendEventRequest; +import io.odpf.proton.raccoon.SendEventResponse; +import io.odpf.raccoon.model.Event; +import io.odpf.raccoon.model.Response; +import io.odpf.raccoon.wire.JsonWire; +import org.apache.http.HttpResponse; +import org.apache.http.client.ServiceUnavailableRetryStrategy; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.protocol.HttpContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.UUID; + +/** + * Class for the http client implementation. + */ + class RestClient implements RaccoonClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(RestClient.class); + + private final RestConfig restConfig; + + /** + * @param restConfig The rest config options. + */ + RestClient(RestConfig restConfig) { + this.restConfig = restConfig; + this.restConfig.setHttpClient(this.getHttpClient()); + } + + /** + * Send creates a batch request, produces a request guid, and sends an HTTP + * request. + * + * @param events The raccoon message array. + * @return {@link Response} The response for the given raccoon request. + */ + @Override + public Response send(Event[] events) { + String reqGuid = UUID.randomUUID().toString(); + CloseableHttpResponse response = null; + String errorMessage; + try { + LOGGER.info("send: started request, url:{}, req-id: {}", this.restConfig.getUrl(), reqGuid); + SendEventRequest.Builder builder = SendEventRequest.newBuilder(); + builder.setReqGuid(reqGuid); + + for (Event e : events) { + Builder protoEvents = io.odpf.proton.raccoon.Event.newBuilder(); + protoEvents.setType(e.getType()); + protoEvents.setEventBytes(ByteString.copyFrom(this.restConfig.getSerializer().serialize(e.getData()))); + + builder.addEvents(protoEvents.build()); + } + + // wire request. + SendEventRequest postRequest = builder.build(); + + HttpPost httPost = new HttpPost(restConfig.getUrl()); + httPost.addHeader("Content-Type", this.restConfig.getMarshaler().getContentType()); + httPost.setEntity(new ByteArrayEntity(this.restConfig.getMarshaler().marshal(postRequest))); + + this.restConfig.getHeaders().forEach(httPost::addHeader); + + response = this.restConfig.getHttpClient().execute(httPost); + SendEventResponse eventResponse = (SendEventResponse) this.restConfig.getMarshaler().unmarshal( + ByteStreams.toByteArray(response.getEntity() + .getContent()), + this.restConfig.getMarshaler() instanceof JsonWire ? SendEventResponse.newBuilder() + : SendEventResponse.parser()); + + return Response.builder().isSuccess(true) + .reqGuid(reqGuid) + .status(eventResponse.getStatusValue()) + .code(eventResponse.getCodeValue()) + .sentTime(eventResponse.getSentTime()) + .data(eventResponse.getDataMap()) + .build(); + + } catch (Exception ex) { + LOGGER.error(ex.getMessage()); + errorMessage = ex.getMessage(); + } finally { + if (response != null) { + try { + response.close(); + } catch (IOException e) { + LOGGER.error("send: exception when closing httpclient", e); + errorMessage = e.getMessage(); + } + } + LOGGER.info("send: ended request, url:{}, req-id: {}", this.restConfig.getUrl(), reqGuid); + } + + return Response.builder() + .isSuccess(false) + .reqGuid(reqGuid) + .errorMessage(errorMessage) + .build(); + } + + /** + * Creates the new HTTP client and set the retry handler with the provided settings. + * + * @return The new HTTP client. + */ + private CloseableHttpClient getHttpClient() { + + return HttpClients + .custom() + .setRetryHandler((exception, executionCount, context) -> executionCount < restConfig.getRetryMax()) + .setServiceUnavailableRetryStrategy(new ServiceUnavailableRetryStrategy() { + + @Override + public boolean retryRequest(HttpResponse response, int executionCount, HttpContext context) { + LOGGER.warn("Retrying the http request, retry-count:{}, response-code:{}", executionCount, + response.getStatusLine().getStatusCode()); + return executionCount < restConfig.getRetryMax() + && response.getStatusLine().getStatusCode() != HttpStatusCodes.STATUS_CODE_OK; + } + + @Override + public long getRetryInterval() { + return restConfig.getRetryWait(); + } + + }) + .build(); + } +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/client/RestConfig.java b/clients/java/src/main/java/io/odpf/raccoon/client/RestConfig.java new file mode 100644 index 00000000..932f045e --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/client/RestConfig.java @@ -0,0 +1,73 @@ +package io.odpf.raccoon.client; + +import io.odpf.raccoon.serializer.JsonSerializer; +import io.odpf.raccoon.serializer.Serializer; +import io.odpf.raccoon.wire.JsonWire; +import io.odpf.raccoon.wire.WireMarshaler; +import lombok.Builder; +import lombok.Getter; +import lombok.Setter; +import lombok.Singular; +import org.apache.http.impl.client.CloseableHttpClient; + +import java.util.Map; + +@Getter +@Setter +@Builder(toBuilder = true) + +/* + * Rest config options for the Raccoon http request. + */ +public class RestConfig { + /** + * The default max retry attempts. + */ + private static final int MAX_RETRY = 3; + + /** + * The default delay between retries. + */ + private static final int RETRY_WAIT_MILISECONDS = 1000; + + /** + * The raccoon http endpoint to make the request. + */ + @Builder.Default + private String url = "http://localhost:8080/api/v1/events"; + + /** + * The max retry attempts to be made on failed requests. + */ + @Builder.Default + private Integer retryMax = MAX_RETRY; + + /** + * The sleep time between the retry requests in miliseconds. + */ + @Builder.Default + private long retryWait = RETRY_WAIT_MILISECONDS; + + /** + * The serializer for the raccoon batch request. + */ + @Builder.Default + private Serializer serializer = new JsonSerializer(); + + /** + * The marshaler for the wire request made to the raccoon. + */ + @Builder.Default + private WireMarshaler marshaler = new JsonWire(); + + /** + * The http request headers. + */ + @Singular + private Map headers; + + /** + * The http client. + */ + private CloseableHttpClient httpClient; +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/exception/DeserializationException.java b/clients/java/src/main/java/io/odpf/raccoon/exception/DeserializationException.java new file mode 100644 index 00000000..92bc622e --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/exception/DeserializationException.java @@ -0,0 +1,16 @@ +package io.odpf.raccoon.exception; + +/** + * Exception thrown when the deserialization process fails. + */ +public class DeserializationException extends RuntimeException { + /** + * Constructs a new {@link DeserializationException} with specified detail + * message. + * + * @param msg The error message. + */ + public DeserializationException(final String msg) { + super(msg); + } +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/exception/SerializationException.java b/clients/java/src/main/java/io/odpf/raccoon/exception/SerializationException.java new file mode 100644 index 00000000..8f3d600d --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/exception/SerializationException.java @@ -0,0 +1,16 @@ +package io.odpf.raccoon.exception; + +/** + * Exception thrown when the serialization process fails. + */ +public class SerializationException extends RuntimeException { + /** + * Constructs a new {@link SerializationException} with specified detail + * message. + * + * @param msg The error message. + */ + public SerializationException(final String msg) { + super(msg); + } +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/model/Event.java b/clients/java/src/main/java/io/odpf/raccoon/model/Event.java new file mode 100644 index 00000000..cbf4f551 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/model/Event.java @@ -0,0 +1,23 @@ +package io.odpf.raccoon.model; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@AllArgsConstructor +@Data + +/* + * Class holds the raccoon event, and it's type name. + */ +public class Event { + + /** + * The event type name. + */ + private String type; + + /** + * The event batch. + */ + private Object data; +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/model/Response.java b/clients/java/src/main/java/io/odpf/raccoon/model/Response.java new file mode 100644 index 00000000..2481f4b7 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/model/Response.java @@ -0,0 +1,57 @@ +package io.odpf.raccoon.model; + +import java.util.Map; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Data +@Builder(toBuilder = true) + +/* + * Response holds the information about the request. + */ +public class Response { + + /** + * The status of the raccoon request. + */ + private boolean isSuccess; + + /** + * The request guid of the request. + */ + private String reqGuid; + + /** + * The error message which gets populated on the failed requests. + */ + private String errorMessage; + + /** + * The {@link ResponseStatus} denotes status of the request. + */ + private int status; + + /** + * The {@link ResponseCode} gives more detail of what happened to the request. + */ + private int code; + + /** + * The sentTime is UNIX timestamp populated by Raccoon by the time the response + * is + * sent. + */ + private long sentTime; + + /** + * Data is arbitrary extra metadata. + * The data map will contain the "req_guid" key + */ + private Map data; +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/model/ResponseCode.java b/clients/java/src/main/java/io/odpf/raccoon/model/ResponseCode.java new file mode 100644 index 00000000..00f254fb --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/model/ResponseCode.java @@ -0,0 +1,36 @@ +package io.odpf.raccoon.model; + +public class ResponseCode { + /* + * `CODE_UNSPECIFIED` indicates no appropriate/existing code can describe it. + */ + public static final int CODE_UNSPECIFIED = 0; + + /* + * `OK` indicates the request is processed successfully. + */ + public static final int CODE_OK = 1; + + /* + * `BAD_REQUEST` indicates there is something wrong with the request. + */ + public static final int CODE_BAD_REQUEST = 2; + + /* + * `INTERNAL_ERROR` indicates that Raccoon encountered an unexpected condition + * that prevented it from fulfilling the request. + */ + public static final int CODE_INTERNAL_ERROR = 3; + + /* + * `MAX_CONNECTION_LIMIT_REACHED` indicates that Raccoon is unable to accepts + * new connection due to max connection is reached. + */ + + public static final int CODE_MAX_CONNECTION_LIMIT_REACHED = 4; + + /* + * `MAX_USER_LIMIT_REACHED` indicates that existing connection with the same ID. + */ + public static final int CODE_MAX_USER_LIMIT_REACHED = 5; +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/model/ResponseStatus.java b/clients/java/src/main/java/io/odpf/raccoon/model/ResponseStatus.java new file mode 100644 index 00000000..5a4be642 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/model/ResponseStatus.java @@ -0,0 +1,18 @@ +package io.odpf.raccoon.model; + +public class ResponseStatus { + /* + * `UNSPECIFIED` indicates if request is failed for the unknown reasons. + */ + public static final int STATUS_UNSPECIFIED = 0; + + /* + * 'SUCCESS' indicates if the request is successful. + */ + public static final int STATUS_SUCCESS = 1; + + /* + * 'ERROR' indicates if the request is failed. + */ + public static final int STATUS_ERROR = 2; +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/serializer/JsonSerializer.java b/clients/java/src/main/java/io/odpf/raccoon/serializer/JsonSerializer.java new file mode 100644 index 00000000..9f580299 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/serializer/JsonSerializer.java @@ -0,0 +1,46 @@ +package io.odpf.raccoon.serializer; + +import com.google.gson.Gson; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.MessageOrBuilder; +import com.google.protobuf.util.JsonFormat; +import io.odpf.raccoon.exception.SerializationException; + +/** + Json class to convert raccoon messages. +**/ +public class JsonSerializer implements Serializer { + + private final Gson gson; + + /** + * Initializes the gson instance. + */ + public JsonSerializer() { + this.gson = new Gson(); + } + + /** + * Json serializer for the raccoon messages. + * + * @see io.odpf.raccoon.serializer.Serializer#serialize(java.lang.Object) + * @param any is the object to be serialized. + * @return returns the json bytes. + **/ + @Override + public byte[] serialize(Object any) throws SerializationException { + if (any instanceof MessageOrBuilder) { + try { + return JsonFormat.printer() + .omittingInsignificantWhitespace() + .preservingProtoFieldNames() + .print((MessageOrBuilder) any) + .getBytes(); + } catch (InvalidProtocolBufferException e) { + throw new SerializationException(e.getMessage()); + } + } + + return this.gson.toJson(any).getBytes(); + } +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/serializer/ProtoSerializer.java b/clients/java/src/main/java/io/odpf/raccoon/serializer/ProtoSerializer.java new file mode 100644 index 00000000..c61bbd54 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/serializer/ProtoSerializer.java @@ -0,0 +1,23 @@ +package io.odpf.raccoon.serializer; + +import com.google.protobuf.GeneratedMessageV3; +import io.odpf.raccoon.exception.SerializationException; + +public class ProtoSerializer implements Serializer { + + /** + * Converts a proto object to the byte array. + * + * @param any proto object to be serialized. + * @return the proto byte array. + * @throws SerializationException Throws exceptions if the object is non-proto. + */ + @Override + public byte[] serialize(Object any) throws SerializationException { + if (any instanceof GeneratedMessageV3) { + return ((GeneratedMessageV3) any).toByteArray(); + } + + throw new SerializationException("Error: unable to serialize non proto object"); + } +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/serializer/Serializer.java b/clients/java/src/main/java/io/odpf/raccoon/serializer/Serializer.java new file mode 100644 index 00000000..596342a1 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/serializer/Serializer.java @@ -0,0 +1,17 @@ +package io.odpf.raccoon.serializer; + +import io.odpf.raccoon.exception.SerializationException; + +/* + Interface serializer defines a conversion for raccoon message to byte sequence. +*/ +public interface Serializer { + /** + * Serialize the given object into the byte array. + * + * @param any object to be serialized. + * @return the serialized byte array. + * @throws SerializationException if the object fail to serialize. + */ + byte[] serialize(Object any) throws SerializationException; +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/wire/JsonWire.java b/clients/java/src/main/java/io/odpf/raccoon/wire/JsonWire.java new file mode 100644 index 00000000..fbd81408 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/wire/JsonWire.java @@ -0,0 +1,80 @@ +package io.odpf.raccoon.wire; + +import com.google.gson.Gson; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.Message; +import com.google.protobuf.MessageOrBuilder; +import com.google.protobuf.util.JsonFormat; +import io.odpf.raccoon.exception.DeserializationException; +import io.odpf.raccoon.exception.SerializationException; + +/** + * Json class to convert raccoon messages to/from the proto3. + */ +public class JsonWire implements WireMarshaler { + + private final Gson gson; + + public JsonWire() { + this.gson = new Gson(); + } + + /** + * Converts a raccoon message to the json. + * + * @param any object to be marshaled. + * @return the marshal byte array. + * @throws SerializationException Throws exceptions if fail to serialize. + */ + @Override + public byte[] marshal(Object any) throws SerializationException { + try { + if (any instanceof MessageOrBuilder) { + return JsonFormat.printer() + .omittingInsignificantWhitespace() + .preservingProtoFieldNames() + .print((MessageOrBuilder) any) + .getBytes(); + } + + return this.gson.toJson(any).getBytes(); + + } catch (InvalidProtocolBufferException e) { + throw new SerializationException(e.getMessage()); + } + } + + /** + * Converts the json bytes back into the object. + * + * @param any object to be unmarshal. + * @param type object to be used for unmarshal. + * @return the unmarshal object. + * @throws DeserializationException Throws exceptions if fail to deserialize. + */ + @Override + public Object unmarshal(byte[] any, Object type) throws DeserializationException { + try { + if (type instanceof Message.Builder) { + Message.Builder builder = (Message.Builder) type; + JsonFormat.parser().merge(new String(any), builder); + return builder.build(); + } + + return this.gson.fromJson(new String(any), type.getClass()); + } catch (InvalidProtocolBufferException e) { + throw new DeserializationException(e.getMessage()); + } + } + + /** + * Wire content type for the json marshaled request. + * + * @return the content type. + */ + @Override + public String getContentType() { + return "application/json"; + } + +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/wire/ProtoWire.java b/clients/java/src/main/java/io/odpf/raccoon/wire/ProtoWire.java new file mode 100644 index 00000000..a8860beb --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/wire/ProtoWire.java @@ -0,0 +1,61 @@ +package io.odpf.raccoon.wire; + +import com.google.protobuf.GeneratedMessageV3; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.Parser; +import io.odpf.raccoon.exception.DeserializationException; +import io.odpf.raccoon.exception.SerializationException; + +/** + * Proto class to convert raccoon messages to/from the proto3. + */ +public class ProtoWire implements WireMarshaler { + + /** + * Converts a raccoon request to the proto. + * + * @param any proto object to be marshaled. + * @return the marshal byte array. + * @throws SerializationException Throws when the serialization fails. + */ + @Override + public byte[] marshal(Object any) throws SerializationException { + if (any instanceof GeneratedMessageV3) { + return ((GeneratedMessageV3) any).toByteArray(); + } + + throw new SerializationException("unable to serialize the non proto message"); + } + + /** + * Converts the raccoon request proto bytes back into the object. + * + * @param any proto object to be unmarshal. + * @param type prototype to be used for unmarshal. + * @return the unmarshalled object. + * @throws DeserializationException Throws when the deserialization fails. + */ + @Override + public Object unmarshal(byte[] any, Object type) throws DeserializationException { + try { + if (type instanceof Parser) { + return ((Parser) type).parseFrom(any); + } + } catch (InvalidProtocolBufferException e) { + throw new DeserializationException(e.getMessage()); + } + + throw new DeserializationException("unable to deserialize using the non proto parser"); + } + + /** + * Wire content type for the proto marshaled request. + * + * @return the content type. + */ + @Override + public String getContentType() { + return "application/proto"; + } + +} diff --git a/clients/java/src/main/java/io/odpf/raccoon/wire/WireMarshaler.java b/clients/java/src/main/java/io/odpf/raccoon/wire/WireMarshaler.java new file mode 100644 index 00000000..e3eb4da2 --- /dev/null +++ b/clients/java/src/main/java/io/odpf/raccoon/wire/WireMarshaler.java @@ -0,0 +1,35 @@ +package io.odpf.raccoon.wire; + +import io.odpf.raccoon.exception.DeserializationException; +import io.odpf.raccoon.exception.SerializationException; + +/** + * An interface for marshaling/unmarshalling the wire requests. + */ +public interface WireMarshaler { + /** + * Marshal the given object into the byte array. + * + * @param any serializable object. + * @return the byte array. + * @throws SerializationException throw when the serialization fails. + */ + byte[] marshal(Object any) throws SerializationException; + + /** + * Unmarshal the given byte array into the object. + * + * @param any serializable byte array. + * @param type the type to be + * @return The object un-marshalled from the byte array. + * @throws DeserializationException throw when the deserialization fails. + */ + Object unmarshal(byte[] any, Object type) throws DeserializationException; + + /** + * Content type of the wire request. + * + * @return the content type. + */ + String getContentType(); +} diff --git a/clients/java/src/test/java/buf.gen.yaml b/clients/java/src/test/java/buf.gen.yaml new file mode 100644 index 00000000..9b19a023 --- /dev/null +++ b/clients/java/src/test/java/buf.gen.yaml @@ -0,0 +1,4 @@ +version: v1 +plugins: + - remote: buf.build/protocolbuffers/plugins/java:v3.19.1-1 + out: . \ No newline at end of file diff --git a/clients/java/src/test/java/io/odpf/raccoon/RestClientTest.java b/clients/java/src/test/java/io/odpf/raccoon/RestClientTest.java new file mode 100644 index 00000000..399899c6 --- /dev/null +++ b/clients/java/src/test/java/io/odpf/raccoon/RestClientTest.java @@ -0,0 +1,169 @@ +package io.odpf.raccoon; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import com.google.protobuf.Timestamp; +import com.google.protobuf.util.JsonFormat; +import io.odpf.proton.raccoon.SendEventResponse; +import io.odpf.raccoon.client.RaccoonClient; +import io.odpf.raccoon.client.RaccoonClientFactory; +import io.odpf.raccoon.client.RestConfig; +import io.odpf.raccoon.model.Event; +import io.odpf.raccoon.model.Response; +import io.odpf.raccoon.model.ResponseCode; +import io.odpf.raccoon.model.ResponseStatus; +import io.odpf.raccoon.serializer.JsonSerializer; +import io.odpf.raccoon.serializer.ProtoSerializer; +import io.odpf.raccoon.wire.JsonWire; +import io.odpf.raccoon.wire.ProtoWire; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import sample.PageEventProto; + +import java.util.HashMap; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; + +public class RestClientTest { + + @Rule + public WireMockRule service = new WireMockRule(8082); + + @Test + public void testProtoSend() throws Exception { + + String reqGuid = UUID.randomUUID().toString(); + service.stubFor( + post("/api/v1/events") + .withHeader("Content-Type", containing("proto")) + .willReturn(ok() + .withHeader("Content-Type", "application/proto") + .withBody(getProtoResponse(reqGuid)))); + + RestConfig config = RestConfig.builder() + .url(service.url("/api/v1/events")) + .header("x-connection-id", "123") + .serializer(new ProtoSerializer()) + .marshaler(new ProtoWire()).build(); + + RaccoonClient restClient = RaccoonClientFactory.getRestClient(config); + + PageEventProto.PageEvent pageEvent = getPageEvent(reqGuid); + + Response response = restClient.send( + new Event[] { + new Event("page", pageEvent) + }); + + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals(response.getCode(), ResponseCode.CODE_OK); + Assert.assertEquals(response.getStatus(), ResponseStatus.STATUS_SUCCESS); + Assert.assertTrue(response.getData().containsKey("req_guid")); + Assert.assertNull(response.getErrorMessage()); + Assert.assertNotNull(response.getReqGuid()); + } + + @Test + public void testJsonSend() throws Exception { + String reqGuid = UUID.randomUUID().toString(); + service.stubFor( + post("/api/v1/events") + .withHeader("Content-Type", containing("json")) + .willReturn(ok() + .withHeader("Content-Type", "application/json") + .withBody(getJsonResponse(reqGuid)))); + + RestConfig config = RestConfig.builder() + .url(service.url("/api/v1/events")) + .header("x-connection-id", "123") + .serializer(new JsonSerializer()) + .marshaler(new JsonWire()).build(); + + RaccoonClient restClient = RaccoonClientFactory.getRestClient(config); + + PageEventProto.PageEvent pageEvent = getPageEvent(reqGuid); + + Response response = restClient.send( + new Event[] { + new Event("page", pageEvent) + }); + + Assert.assertTrue(response.isSuccess()); + Assert.assertEquals(response.getCode(), ResponseCode.CODE_OK); + Assert.assertEquals(response.getStatus(), ResponseStatus.STATUS_SUCCESS); + Assert.assertTrue(response.getData().containsKey("req_guid")); + Assert.assertNull(response.getErrorMessage()); + Assert.assertNotNull(response.getReqGuid()); + } + + @Test + public void testSendServiceUnavailable() { + String reqGuid = UUID.randomUUID().toString(); + service.stubFor( + post("/api/v1/events") + .withHeader("Content-Type", containing("json")) + .willReturn(serviceUnavailable() + .withHeader("Content-Type", "application/json"))); + + RestConfig config = RestConfig.builder() + .url(service.url("/api/v1/events")) + .header("x-connection-id", "123") + .serializer(new JsonSerializer()) + .marshaler(new JsonWire()).build(); + + RaccoonClient restClient = RaccoonClientFactory.getRestClient(config); + + PageEventProto.PageEvent pageEvent = getPageEvent(reqGuid); + + Response response = restClient.send( + new Event[] { + new Event("page", pageEvent) + }); + + Assert.assertFalse(response.isSuccess()); + Assert.assertNull(response.getData()); + Assert.assertNotNull(response.getErrorMessage()); + Assert.assertNotNull(response.getReqGuid()); + } + + private static PageEventProto.PageEvent getPageEvent(String reqGuid) { + return PageEventProto.PageEvent.newBuilder() + .setEventGuid(reqGuid) + .setEventName("clicked") + .setSentTime(Timestamp.newBuilder().build()) + .build(); + } + + private static String getJsonResponse(String reqGuid) throws Exception { + HashMap data = new HashMap<>(); + data.put("req_guid", reqGuid); + + SendEventResponse sendEventResponse = SendEventResponse.newBuilder() + .setStatus(io.odpf.proton.raccoon.Status.STATUS_SUCCESS) + .setCode(io.odpf.proton.raccoon.Code.CODE_OK) + .setSentTime(TimeUnit.DAYS.toDays(1)) + .putAllData(data) + .build(); + + return JsonFormat.printer() + .omittingInsignificantWhitespace() + .preservingProtoFieldNames() + .print(sendEventResponse); + } + + private static byte[] getProtoResponse(String reqGuid) { + HashMap data = new HashMap<>(); + data.put("req_guid", reqGuid); + + SendEventResponse sendEventResponse = SendEventResponse.newBuilder() + .setStatus(io.odpf.proton.raccoon.Status.STATUS_SUCCESS) + .setCode(io.odpf.proton.raccoon.Code.CODE_OK) + .setSentTime(TimeUnit.DAYS.toDays(1)) + .putAllData(data) + .build(); + + return sendEventResponse.toByteArray(); + } +} diff --git a/clients/java/src/test/java/io/odpf/raccoon/serializer/JsonSerializerTest.java b/clients/java/src/test/java/io/odpf/raccoon/serializer/JsonSerializerTest.java new file mode 100644 index 00000000..7f7ab350 --- /dev/null +++ b/clients/java/src/test/java/io/odpf/raccoon/serializer/JsonSerializerTest.java @@ -0,0 +1,37 @@ +package io.odpf.raccoon.serializer; + +import com.google.protobuf.Timestamp; +import com.google.protobuf.util.JsonFormat; + +import sample.PageEventProto; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; + +public class JsonSerializerTest { + + @Test + public void testSerialize() throws Exception { + // Arrange + Serializer serializer = new JsonSerializer(); + + // Act + PageEventProto.PageEvent pageEvent = PageEventProto.PageEvent.newBuilder() + .setEventGuid(UUID.randomUUID().toString()) + .setEventName("clicked") + .setSentTime(Timestamp.newBuilder().build()) + .build(); + + byte[] actualBytes = serializer.serialize(pageEvent); + + PageEventProto.PageEvent.Builder builder = PageEventProto.PageEvent.newBuilder(); + JsonFormat.parser().merge(new String(actualBytes), builder); + PageEventProto.PageEvent actual = builder.build(); + + // Assert + Assert.assertEquals(pageEvent.getEventGuid(), actual.getEventGuid()); + Assert.assertEquals(pageEvent.getEventName(), actual.getEventName()); + } +} diff --git a/clients/java/src/test/java/io/odpf/raccoon/serializer/ProtoSerializerTest.java b/clients/java/src/test/java/io/odpf/raccoon/serializer/ProtoSerializerTest.java new file mode 100644 index 00000000..e0e33130 --- /dev/null +++ b/clients/java/src/test/java/io/odpf/raccoon/serializer/ProtoSerializerTest.java @@ -0,0 +1,34 @@ +package io.odpf.raccoon.serializer; + +import com.google.protobuf.Timestamp; + +import sample.PageEventProto; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; + +public class ProtoSerializerTest { + + @Test + public void testSerialize() throws Exception { + // Arrange + Serializer serializer = new ProtoSerializer(); + + // Act + PageEventProto.PageEvent pageEvent = PageEventProto.PageEvent.newBuilder() + .setEventGuid(UUID.randomUUID().toString()) + .setEventName("clicked") + .setSentTime(Timestamp.newBuilder().build()) + .build(); + + byte[] pageBytes = serializer.serialize(pageEvent); + + PageEventProto.PageEvent actual = PageEventProto.PageEvent.parser().parseFrom(pageBytes); + + // Assert + Assert.assertEquals(pageEvent.getEventGuid(), actual.getEventGuid()); + Assert.assertEquals(pageEvent.getEventName(), actual.getEventName()); + } +} diff --git a/clients/java/src/test/java/io/odpf/raccoon/wire/JsonWireTest.java b/clients/java/src/test/java/io/odpf/raccoon/wire/JsonWireTest.java new file mode 100644 index 00000000..957d3376 --- /dev/null +++ b/clients/java/src/test/java/io/odpf/raccoon/wire/JsonWireTest.java @@ -0,0 +1,83 @@ +package io.odpf.raccoon.wire; + +import com.google.protobuf.Timestamp; +import com.google.protobuf.util.JsonFormat; +import io.odpf.proton.raccoon.Event; +import io.odpf.proton.raccoon.SendEventRequest; +import sample.PageEventProto; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; + +public class JsonWireTest { + private final WireMarshaler marshaler; + + public JsonWireTest() { + this.marshaler = new JsonWire(); + } + + @Test + public void testMarshal() throws Exception { + // arrange + PageEventProto.PageEvent pageEvent = PageEventProto.PageEvent.newBuilder() + .setEventGuid(UUID.randomUUID().toString()) + .setEventName("clicked") + .setSentTime(Timestamp.newBuilder().build()) + .build(); + + SendEventRequest sendEventRequest = SendEventRequest.newBuilder() + .setReqGuid(UUID.randomUUID().toString()) + .addEvents( + Event.newBuilder() + .setType("page-event") + .setEventBytes(pageEvent.toByteString()) + .build()) + .build(); + + // act + byte[] requestBytes = this.marshaler.marshal(sendEventRequest); + SendEventRequest.Builder actual = SendEventRequest.newBuilder(); + JsonFormat.parser().merge(new String(requestBytes), actual); + + // assert + Assert.assertEquals(sendEventRequest.getReqGuid(), actual.getReqGuid()); + Assert.assertEquals(sendEventRequest.getEventsCount(), actual.getEventsCount()); + Assert.assertEquals(sendEventRequest.getEvents(0).getEventBytes(), actual.getEvents(0).getEventBytes()); + } + + @Test + public void testUnmarshal() throws Exception { + // arrange + PageEventProto.PageEvent pageEvent = PageEventProto.PageEvent.newBuilder() + .setEventGuid(UUID.randomUUID().toString()) + .setEventName("clicked") + .setSentTime(Timestamp.newBuilder().build()) + .build(); + + SendEventRequest sendEventRequest = SendEventRequest.newBuilder() + .setReqGuid(UUID.randomUUID().toString()) + .addEvents( + Event.newBuilder() + .setType("page-event") + .setEventBytes(pageEvent.toByteString()) + .build()) + .build(); + + // act + byte[] requestBytes = this.marshaler.marshal(sendEventRequest); + SendEventRequest actual = (SendEventRequest) this.marshaler.unmarshal(requestBytes, + SendEventRequest.newBuilder()); + + // assert + Assert.assertEquals(sendEventRequest.getReqGuid(), actual.getReqGuid()); + Assert.assertEquals(sendEventRequest.getEventsCount(), actual.getEventsCount()); + Assert.assertEquals(sendEventRequest.getEvents(0).getEventBytes(), actual.getEvents(0).getEventBytes()); + } + + @Test + public void testGetContentType() { + Assert.assertEquals("application/json", this.marshaler.getContentType()); + } +} diff --git a/clients/java/src/test/java/io/odpf/raccoon/wire/ProtoWireTest.java b/clients/java/src/test/java/io/odpf/raccoon/wire/ProtoWireTest.java new file mode 100644 index 00000000..07ad42bc --- /dev/null +++ b/clients/java/src/test/java/io/odpf/raccoon/wire/ProtoWireTest.java @@ -0,0 +1,81 @@ +package io.odpf.raccoon.wire; + +import com.google.protobuf.Timestamp; +import io.odpf.proton.raccoon.Event; +import io.odpf.proton.raccoon.SendEventRequest; +import sample.PageEventProto; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.UUID; + +public class ProtoWireTest { + private final WireMarshaler marshaler; + + public ProtoWireTest() { + this.marshaler = new ProtoWire(); + } + + @Test + public void testMarshal() throws Exception { + // arrange + PageEventProto.PageEvent pageEvent = PageEventProto.PageEvent.newBuilder() + .setEventGuid(UUID.randomUUID().toString()) + .setEventName("clicked") + .setSentTime(Timestamp.newBuilder().build()) + .build(); + + SendEventRequest sendEventRequest = SendEventRequest.newBuilder() + .setReqGuid(UUID.randomUUID().toString()) + .addEvents( + Event.newBuilder() + .setType("page-event") + .setEventBytes(pageEvent.toByteString()) + .build()) + .build(); + + // act + byte[] requestBytes = this.marshaler.marshal(sendEventRequest); + SendEventRequest actual = SendEventRequest.parseFrom(requestBytes); + + // assert + Assert.assertEquals(sendEventRequest.getReqGuid(), actual.getReqGuid()); + Assert.assertEquals(sendEventRequest.getEventsCount(), actual.getEventsCount()); + Assert.assertEquals(sendEventRequest.getEvents(0).getEventBytes(), actual.getEvents(0).getEventBytes()); + } + + @Test + public void testUnmarshal() throws Exception { + // arrange + PageEventProto.PageEvent pageEvent = PageEventProto.PageEvent.newBuilder() + .setEventGuid(UUID.randomUUID().toString()) + .setEventName("clicked") + .setSentTime(Timestamp.newBuilder().build()) + .build(); + + SendEventRequest sendEventRequest = SendEventRequest.newBuilder() + .setReqGuid(UUID.randomUUID().toString()) + .addEvents( + Event.newBuilder() + .setType("page-event") + .setEventBytes(pageEvent.toByteString()) + .build()) + .build(); + + // act + byte[] requestBytes = this.marshaler.marshal(sendEventRequest); + SendEventRequest actual = (SendEventRequest) this.marshaler.unmarshal(requestBytes, + SendEventRequest.parser()); + + // assert + Assert.assertEquals(sendEventRequest.getReqGuid(), actual.getReqGuid()); + Assert.assertEquals(sendEventRequest.getEventsCount(), actual.getEventsCount()); + Assert.assertEquals(sendEventRequest.getEvents(0).getEventBytes(), actual.getEvents(0).getEventBytes()); + } + + @Test + public void testGetContentType() { + Assert.assertEquals("application/proto", this.marshaler.getContentType()); + } +} diff --git a/clients/java/src/test/java/sample.proto b/clients/java/src/test/java/sample.proto new file mode 100644 index 00000000..957771d8 --- /dev/null +++ b/clients/java/src/test/java/sample.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +import "google/protobuf/timestamp.proto"; +option java_outer_classname = "PageEventProto"; +option java_package = "sample"; + +message PageEvent { + string event_guid = 1; + string event_name = 2; + google.protobuf.Timestamp sent_time = 3; +} \ No newline at end of file diff --git a/clients/java/src/test/java/sample/PageEventProto.java b/clients/java/src/test/java/sample/PageEventProto.java new file mode 100644 index 00000000..a58d0449 --- /dev/null +++ b/clients/java/src/test/java/sample/PageEventProto.java @@ -0,0 +1,974 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: sample.proto + +package sample; + +public final class PageEventProto { + private PageEventProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface PageEventOrBuilder extends + // @@protoc_insertion_point(interface_extends:PageEvent) + com.google.protobuf.MessageOrBuilder { + + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @return The eventGuid. + */ + java.lang.String getEventGuid(); + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @return The bytes for eventGuid. + */ + com.google.protobuf.ByteString + getEventGuidBytes(); + + /** + * string event_name = 2 [json_name = "eventName"]; + * @return The eventName. + */ + java.lang.String getEventName(); + /** + * string event_name = 2 [json_name = "eventName"]; + * @return The bytes for eventName. + */ + com.google.protobuf.ByteString + getEventNameBytes(); + + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + * @return Whether the sentTime field is set. + */ + boolean hasSentTime(); + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + * @return The sentTime. + */ + com.google.protobuf.Timestamp getSentTime(); + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + com.google.protobuf.TimestampOrBuilder getSentTimeOrBuilder(); + } + /** + * Protobuf type {@code PageEvent} + */ + public static final class PageEvent extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:PageEvent) + PageEventOrBuilder { + private static final long serialVersionUID = 0L; + // Use PageEvent.newBuilder() to construct. + private PageEvent(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private PageEvent() { + eventGuid_ = ""; + eventName_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new PageEvent(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private PageEvent( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + eventGuid_ = s; + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + eventName_ = s; + break; + } + case 26: { + com.google.protobuf.Timestamp.Builder subBuilder = null; + if (sentTime_ != null) { + subBuilder = sentTime_.toBuilder(); + } + sentTime_ = input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(sentTime_); + sentTime_ = subBuilder.buildPartial(); + } + + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return sample.PageEventProto.internal_static_PageEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return sample.PageEventProto.internal_static_PageEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + sample.PageEventProto.PageEvent.class, sample.PageEventProto.PageEvent.Builder.class); + } + + public static final int EVENT_GUID_FIELD_NUMBER = 1; + private volatile java.lang.Object eventGuid_; + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @return The eventGuid. + */ + @java.lang.Override + public java.lang.String getEventGuid() { + java.lang.Object ref = eventGuid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventGuid_ = s; + return s; + } + } + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @return The bytes for eventGuid. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getEventGuidBytes() { + java.lang.Object ref = eventGuid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventGuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EVENT_NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object eventName_; + /** + * string event_name = 2 [json_name = "eventName"]; + * @return The eventName. + */ + @java.lang.Override + public java.lang.String getEventName() { + java.lang.Object ref = eventName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventName_ = s; + return s; + } + } + /** + * string event_name = 2 [json_name = "eventName"]; + * @return The bytes for eventName. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getEventNameBytes() { + java.lang.Object ref = eventName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SENT_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp sentTime_; + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + * @return Whether the sentTime field is set. + */ + @java.lang.Override + public boolean hasSentTime() { + return sentTime_ != null; + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + * @return The sentTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSentTime() { + return sentTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : sentTime_; + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSentTimeOrBuilder() { + return getSentTime(); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(eventGuid_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, eventGuid_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(eventName_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, eventName_); + } + if (sentTime_ != null) { + output.writeMessage(3, getSentTime()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(eventGuid_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, eventGuid_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(eventName_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, eventName_); + } + if (sentTime_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, getSentTime()); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof sample.PageEventProto.PageEvent)) { + return super.equals(obj); + } + sample.PageEventProto.PageEvent other = (sample.PageEventProto.PageEvent) obj; + + if (!getEventGuid() + .equals(other.getEventGuid())) return false; + if (!getEventName() + .equals(other.getEventName())) return false; + if (hasSentTime() != other.hasSentTime()) return false; + if (hasSentTime()) { + if (!getSentTime() + .equals(other.getSentTime())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + EVENT_GUID_FIELD_NUMBER; + hash = (53 * hash) + getEventGuid().hashCode(); + hash = (37 * hash) + EVENT_NAME_FIELD_NUMBER; + hash = (53 * hash) + getEventName().hashCode(); + if (hasSentTime()) { + hash = (37 * hash) + SENT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSentTime().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static sample.PageEventProto.PageEvent parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static sample.PageEventProto.PageEvent parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static sample.PageEventProto.PageEvent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static sample.PageEventProto.PageEvent parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static sample.PageEventProto.PageEvent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static sample.PageEventProto.PageEvent parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static sample.PageEventProto.PageEvent parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static sample.PageEventProto.PageEvent parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static sample.PageEventProto.PageEvent parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static sample.PageEventProto.PageEvent parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static sample.PageEventProto.PageEvent parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static sample.PageEventProto.PageEvent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(sample.PageEventProto.PageEvent prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code PageEvent} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:PageEvent) + sample.PageEventProto.PageEventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return sample.PageEventProto.internal_static_PageEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return sample.PageEventProto.internal_static_PageEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + sample.PageEventProto.PageEvent.class, sample.PageEventProto.PageEvent.Builder.class); + } + + // Construct using sample.PageEventProto.PageEvent.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + eventGuid_ = ""; + + eventName_ = ""; + + if (sentTimeBuilder_ == null) { + sentTime_ = null; + } else { + sentTime_ = null; + sentTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return sample.PageEventProto.internal_static_PageEvent_descriptor; + } + + @java.lang.Override + public sample.PageEventProto.PageEvent getDefaultInstanceForType() { + return sample.PageEventProto.PageEvent.getDefaultInstance(); + } + + @java.lang.Override + public sample.PageEventProto.PageEvent build() { + sample.PageEventProto.PageEvent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public sample.PageEventProto.PageEvent buildPartial() { + sample.PageEventProto.PageEvent result = new sample.PageEventProto.PageEvent(this); + result.eventGuid_ = eventGuid_; + result.eventName_ = eventName_; + if (sentTimeBuilder_ == null) { + result.sentTime_ = sentTime_; + } else { + result.sentTime_ = sentTimeBuilder_.build(); + } + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof sample.PageEventProto.PageEvent) { + return mergeFrom((sample.PageEventProto.PageEvent)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(sample.PageEventProto.PageEvent other) { + if (other == sample.PageEventProto.PageEvent.getDefaultInstance()) return this; + if (!other.getEventGuid().isEmpty()) { + eventGuid_ = other.eventGuid_; + onChanged(); + } + if (!other.getEventName().isEmpty()) { + eventName_ = other.eventName_; + onChanged(); + } + if (other.hasSentTime()) { + mergeSentTime(other.getSentTime()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + sample.PageEventProto.PageEvent parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (sample.PageEventProto.PageEvent) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object eventGuid_ = ""; + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @return The eventGuid. + */ + public java.lang.String getEventGuid() { + java.lang.Object ref = eventGuid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventGuid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @return The bytes for eventGuid. + */ + public com.google.protobuf.ByteString + getEventGuidBytes() { + java.lang.Object ref = eventGuid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventGuid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @param value The eventGuid to set. + * @return This builder for chaining. + */ + public Builder setEventGuid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + eventGuid_ = value; + onChanged(); + return this; + } + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @return This builder for chaining. + */ + public Builder clearEventGuid() { + + eventGuid_ = getDefaultInstance().getEventGuid(); + onChanged(); + return this; + } + /** + * string event_guid = 1 [json_name = "eventGuid"]; + * @param value The bytes for eventGuid to set. + * @return This builder for chaining. + */ + public Builder setEventGuidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + eventGuid_ = value; + onChanged(); + return this; + } + + private java.lang.Object eventName_ = ""; + /** + * string event_name = 2 [json_name = "eventName"]; + * @return The eventName. + */ + public java.lang.String getEventName() { + java.lang.Object ref = eventName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + eventName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string event_name = 2 [json_name = "eventName"]; + * @return The bytes for eventName. + */ + public com.google.protobuf.ByteString + getEventNameBytes() { + java.lang.Object ref = eventName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + eventName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string event_name = 2 [json_name = "eventName"]; + * @param value The eventName to set. + * @return This builder for chaining. + */ + public Builder setEventName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + eventName_ = value; + onChanged(); + return this; + } + /** + * string event_name = 2 [json_name = "eventName"]; + * @return This builder for chaining. + */ + public Builder clearEventName() { + + eventName_ = getDefaultInstance().getEventName(); + onChanged(); + return this; + } + /** + * string event_name = 2 [json_name = "eventName"]; + * @param value The bytes for eventName to set. + * @return This builder for chaining. + */ + public Builder setEventNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + eventName_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp sentTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> sentTimeBuilder_; + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + * @return Whether the sentTime field is set. + */ + public boolean hasSentTime() { + return sentTimeBuilder_ != null || sentTime_ != null; + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + * @return The sentTime. + */ + public com.google.protobuf.Timestamp getSentTime() { + if (sentTimeBuilder_ == null) { + return sentTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : sentTime_; + } else { + return sentTimeBuilder_.getMessage(); + } + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + public Builder setSentTime(com.google.protobuf.Timestamp value) { + if (sentTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sentTime_ = value; + onChanged(); + } else { + sentTimeBuilder_.setMessage(value); + } + + return this; + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + public Builder setSentTime( + com.google.protobuf.Timestamp.Builder builderForValue) { + if (sentTimeBuilder_ == null) { + sentTime_ = builderForValue.build(); + onChanged(); + } else { + sentTimeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + public Builder mergeSentTime(com.google.protobuf.Timestamp value) { + if (sentTimeBuilder_ == null) { + if (sentTime_ != null) { + sentTime_ = + com.google.protobuf.Timestamp.newBuilder(sentTime_).mergeFrom(value).buildPartial(); + } else { + sentTime_ = value; + } + onChanged(); + } else { + sentTimeBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + public Builder clearSentTime() { + if (sentTimeBuilder_ == null) { + sentTime_ = null; + onChanged(); + } else { + sentTime_ = null; + sentTimeBuilder_ = null; + } + + return this; + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + public com.google.protobuf.Timestamp.Builder getSentTimeBuilder() { + + onChanged(); + return getSentTimeFieldBuilder().getBuilder(); + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + public com.google.protobuf.TimestampOrBuilder getSentTimeOrBuilder() { + if (sentTimeBuilder_ != null) { + return sentTimeBuilder_.getMessageOrBuilder(); + } else { + return sentTime_ == null ? + com.google.protobuf.Timestamp.getDefaultInstance() : sentTime_; + } + } + /** + * .google.protobuf.Timestamp sent_time = 3 [json_name = "sentTime"]; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder> + getSentTimeFieldBuilder() { + if (sentTimeBuilder_ == null) { + sentTimeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, com.google.protobuf.Timestamp.Builder, com.google.protobuf.TimestampOrBuilder>( + getSentTime(), + getParentForChildren(), + isClean()); + sentTime_ = null; + } + return sentTimeBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:PageEvent) + } + + // @@protoc_insertion_point(class_scope:PageEvent) + private static final sample.PageEventProto.PageEvent DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new sample.PageEventProto.PageEvent(); + } + + public static sample.PageEventProto.PageEvent getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PageEvent parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PageEvent(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public sample.PageEventProto.PageEvent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_PageEvent_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_PageEvent_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\014sample.proto\032\037google/protobuf/timestam" + + "p.proto\"\202\001\n\tPageEvent\022\035\n\nevent_guid\030\001 \001(" + + "\tR\teventGuid\022\035\n\nevent_name\030\002 \001(\tR\teventN" + + "ame\0227\n\tsent_time\030\003 \001(\0132\032.google.protobuf" + + ".TimestampR\010sentTimeB\030\n\006sampleB\016PageEven" + + "tProtob\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_PageEvent_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_PageEvent_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_PageEvent_descriptor, + new java.lang.String[] { "EventGuid", "EventName", "SentTime", }); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +}