diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a2dca94..9e46eafe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,27 @@ # Changelog All notable changes to this project will be documented in this file. -## [5.4.0] - 2024-05-23 +## [Unreleased] + +## [5.4.2] - 2024-10-16 +### Added +- Support custom headers. [EventStoreDB-Client-Java#289](https://github.com/EventStore/EventStoreDB-Client-Java/pull/289) + +### Changed +- Extract tracing metadata from Event. [EventStoreDB-Client-Java#284](https://github.com/EventStore/EventStoreDB-Client-Java/pull/284) +## [5.4.1] - 2024-07-16 +### Changed +- Add user certificates and otel samples. [EventStoreDB-Client-Java#274](https://github.com/EventStore/EventStoreDB-Client-Java/pull/274) +- Support different runtime environments out-of-the-box. [EventStoreDB-Client-Java#279](https://github.com/EventStore/EventStoreDB-Client-Java/pull/279) +- Remove expectation oriented tests. [EventStoreDB-Client-Java#279](https://github.com/EventStore/EventStoreDB-Client-Java/pull/279) +- Fixed bug in the ClientTelemetry whereby injection logic forces all events to have JSON content type. [EventStoreDB-Client-Java#281](https://github.com/EventStore/EventStoreDB-Client-Java/pull/281) + +### Fixed +- Use connection string in user certificate sample. [EventStoreDB-Client-Java#276](https://github.com/EventStore/EventStoreDB-Client-Java/pull/276) +- Fix connection service skipping discovery interval sleeps. [EventStoreDB-Client-Java#278](https://github.com/EventStore/EventStoreDB-Client-Java/pull/278) + +## [5.4.0] - 2024-05-23 ### Added - new connection settings to provide an x.509 certificate for user authentication. [EventStoreDB-Client-Java#266](https://github.com/EventStore/EventStoreDB-Client-Java/pull/266) diff --git a/db-client-java/build.gradle b/db-client-java/build.gradle index c7ec2cfb..fc822dd7 100644 --- a/db-client-java/build.gradle +++ b/db-client-java/build.gradle @@ -19,7 +19,7 @@ tasks.withType(JavaCompile) { } group = 'com.eventstore' -version = '5.4.1' +version = '5.4.2' java { withJavadocJar() diff --git a/db-client-java/src/main/java/com/eventstore/dbclient/ConnectionMetadata.java b/db-client-java/src/main/java/com/eventstore/dbclient/ConnectionMetadata.java index 08b303c3..23b9d6d8 100644 --- a/db-client-java/src/main/java/com/eventstore/dbclient/ConnectionMetadata.java +++ b/db-client-java/src/main/java/com/eventstore/dbclient/ConnectionMetadata.java @@ -2,6 +2,8 @@ import io.grpc.Metadata; +import java.util.Map; + class ConnectionMetadata { private Metadata metadata; @@ -27,6 +29,13 @@ public ConnectionMetadata requiresLeader() { return this; } + public ConnectionMetadata headers(Map headers) { + for (Map.Entry entry : headers.entrySet()) + this.metadata.put(Metadata.Key.of(entry.getKey(), Metadata.ASCII_STRING_MARSHALLER), entry.getValue()); + + return this; + } + public Metadata build() { return this.metadata; } diff --git a/db-client-java/src/main/java/com/eventstore/dbclient/GrpcUtils.java b/db-client-java/src/main/java/com/eventstore/dbclient/GrpcUtils.java index a61d2072..08111bdb 100644 --- a/db-client-java/src/main/java/com/eventstore/dbclient/GrpcUtils.java +++ b/db-client-java/src/main/java/com/eventstore/dbclient/GrpcUtils.java @@ -150,6 +150,8 @@ static public , O> S configureStub(S stub, EventS metadata.requiresLeader(); } + metadata.headers(options.getHeaders()); + return finalStub.withInterceptors(MetadataUtils.newAttachHeadersInterceptor(metadata.build())); } } \ No newline at end of file diff --git a/db-client-java/src/main/java/com/eventstore/dbclient/OptionsBase.java b/db-client-java/src/main/java/com/eventstore/dbclient/OptionsBase.java index 08c0d316..97536c4a 100644 --- a/db-client-java/src/main/java/com/eventstore/dbclient/OptionsBase.java +++ b/db-client-java/src/main/java/com/eventstore/dbclient/OptionsBase.java @@ -1,10 +1,14 @@ package com.eventstore.dbclient; +import java.util.HashMap; +import java.util.Map; + class OptionsBase { private Long deadline; private final OperationKind kind; private UserCredentials credentials; private boolean requiresLeader; + private Map headers = new HashMap<>(); protected OptionsBase() { this(OperationKind.Regular); @@ -83,6 +87,15 @@ public T deadline(long durationInMs) { return (T)this; } + /** + * Adds a custom HTTP header that will be added to the request. + */ + @SuppressWarnings("unchecked") + public T header(String key, String value) { + headers.put(key, value); + return (T)this; + } + Long getDeadline() { return deadline; } @@ -98,4 +111,8 @@ boolean isLeaderRequired() { UserCredentials getCredentials() { return this.credentials; } + + Map getHeaders() { + return this.headers; + } } \ No newline at end of file