Skip to content

Commit

Permalink
style: Configure Spotless formatter (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush008 committed Jul 16, 2024
1 parent 25e3b5a commit 686d0bd
Show file tree
Hide file tree
Showing 30 changed files with 5,409 additions and 5,488 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img height="120" src="https://github.com/qdrant/qdrant/raw/master/docs/logo.svg" alt="Qdrant">
<img height="120" src="https://github.com/qdrant/qdrant/raw/master/docs/logo.svg" alt="Qdrant">
&nbsp;
<img height="150" width="100" src="./resources/java-logo-small.svg" alt="Java">

Expand Down Expand Up @@ -34,22 +34,25 @@ To install the library, add the following lines to your build config file.
<dependency>
<groupId>io.qdrant</groupId>
<artifactId>client</artifactId>
<version>1.9.0</version>
<version>1.10.0</version>
</dependency>
```

#### SBT

```sbt
libraryDependencies += "io.qdrant" % "client" % "1.9.0"
libraryDependencies += "io.qdrant" % "client" % "1.10.0"
```

#### Gradle

```gradle
implementation 'io.qdrant:client:1.9.0'
implementation 'io.qdrant:client:1.10.0'
```

> [!NOTE]
> Please make sure to include all necessary dependencies listed [here](https://central.sonatype.com/artifact/io.qdrant/client/dependencies) in your project.
## 📖 Documentation

- [JavaDoc Reference](https://qdrant.github.io/java-client/)
Expand All @@ -65,7 +68,8 @@ A client can be instantiated with
QdrantClient client =
new QdrantClient(QdrantGrpcClient.newBuilder("localhost").build());
```
which creates a client that will connect to Qdrant on https://localhost:6334.

which creates a client that will connect to Qdrant on <https://localhost:6334>.

Internally, the high level client uses a low level gRPC client to interact with
Qdrant. Additional constructor overloads provide more control over how the gRPC
Expand Down
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ plugins {
id 'com.google.protobuf' version '0.9.4'
id 'net.ltgt.errorprone' version '3.1.0'
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
id 'com.diffplug.spotless' version '6.22.0'
}

group = 'io.qdrant'
Expand Down Expand Up @@ -250,3 +251,16 @@ signing {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign publishing.publications.mavenJava
}

spotless {
java {
target 'src/*/java/**/*.java'
importOrder()
removeUnusedImports()
cleanthat()
googleJavaFormat()
formatAnnotations()
}
}

compileJava.dependsOn 'spotlessApply'
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ qdrantProtosVersion=v1.10.0
qdrantVersion=v1.10.0

# The version of the client to generate
packageVersion=1.10.0
packageVersion=1.10.0

## Extension of the default memory config for the spotless formatter plugin
org.gradle.jvmargs= -Xmx2000m "-XX:MaxMetaspaceSize=1000m"
48 changes: 24 additions & 24 deletions src/main/java/io/qdrant/client/ApiKeyCredentials.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package io.qdrant.client;

import java.util.concurrent.Executor;

import io.grpc.CallCredentials;
import io.grpc.Metadata;
import io.grpc.Status;
import java.util.concurrent.Executor;

/**
* API key authentication credentials
*/
/** API key authentication credentials */
public class ApiKeyCredentials extends CallCredentials {
private final String apiKey;
private final String apiKey;

/**
* Instantiates a new instance of {@link ApiKeyCredentials}
* @param apiKey The API key to use for authentication
*/
public ApiKeyCredentials(String apiKey) {
this.apiKey = apiKey;
}
/**
* Instantiates a new instance of {@link ApiKeyCredentials}
*
* @param apiKey The API key to use for authentication
*/
public ApiKeyCredentials(String apiKey) {
this.apiKey = apiKey;
}

@Override
public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier) {
appExecutor.execute(() -> {
try {
Metadata headers = new Metadata();
headers.put(Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER), apiKey);
applier.apply(headers);
} catch (Throwable e) {
applier.fail(Status.UNAUTHENTICATED.withCause(e));
}
@Override
public void applyRequestMetadata(
RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier) {
appExecutor.execute(
() -> {
try {
Metadata headers = new Metadata();
headers.put(Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER), apiKey);
applier.apply(headers);
} catch (Throwable e) {
applier.fail(Status.UNAUTHENTICATED.withCause(e));
}
});
}
}
}
Loading

0 comments on commit 686d0bd

Please sign in to comment.