dapr / dapr/java-sdk

Allow registration of a path prefix for sidecar target app on DaprContainer

Offen
#1,222 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
300
Forks
230
Ø Merge
5 T. 1 Std.
Gemergte PRs (30 T.)
5

Beschreibung

## Context

I recently pushed changes to @salaboy's Pizza demo application (see https://github.com/salaboy/pizza/pull/13) to demonstrate how to ease local testing of component dependencies.

Typically, the `Store` component relies on 2 other ones: `Kitchen` and `Delivery` that are expected to be reached via a mesh of sidecars like illustrated below:

![Image](https://github.com/user-attachments/assets/855ca992-ef54-476e-a9fb-8e1f01de9ae1)

In a local development situation, I succeeded - thanks to [this PR on java-sdk](https://github.com/dapr/java-sdk/pull/1210) - in replacing the remote dependencies with local mocks powered by [Microcks](https://microcks.io):

![Image](https://github.com/user-attachments/assets/c7845679-e9fc-4059-8f1c-0c9a8a64d681)

Microcks has a Testcontainers integration, is lightweight and provides mocks + contract-testing for REST, gRPC, GraphQL, Kafka and others, it's an ideal companion for local-testing complex applications made with Dapr.

Even if the above scenario is working well for simple REST services, I'd like to be able to also test this other scenario where the local Dapr sidecar would connect to a sidecars mesh to test/validate advanced Dapr features (security, rate limiting, retries, ...):

![Image](https://github.com/user-attachments/assets/9e7cf01c-2665-485d-85ec-d45945049aeb)

Unfortunately, as of today, the above topology cannot be executed. As Microcks is providing simulations for many mocks, the different endpoints it manages are exposed using different subpaths (typically something like `http://microcks:8080/rest//`) and I didn't find a way to provide subpath or path prefix to the `DaprContainer` when connecting it to the local application.

## Describe the proposal

I'd like to have the ability to do something like:

```java
// Start a sidecar and connect it to the simulation provided by
// microcks on http://microcks:8080/rest/Pizza Kitchen/1.0.0
kitchenContainer = new DaprContainer("daprio/daprd")
.withAppName("kitchen-service")
.withAppPort(8080)
.withAppChannelAddress("microcks")
.withAppPathPrefix("/rest/Pizza Kitchen/1.0.0")
.withNetwork(network);

// Start a sidecar and connect it to the simulation provided by
// microcks on http://microcks:8080/rest/Pizza Delivery/1.0.0
deliveryContainer = new DaprContainer("daprio/daprd")
.withAppName("delivery-service")
.withAppPort(8080)
.withAppChannelAddress("microcks")
.withAppPathPrefix("/rest/Pizza Delivery/1.0.0")
.withNetwork(network);
```

I had a quick look at https://docs.dapr.io/concepts/dapr-services/sidecar/ and it seems like this would also require creating a new flag on the sidecar to enable adding this path prefix.

What do you think of this use-case?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem Einstiegspunkt DaprContainer und der verknüpften Dokumentation zum Dapr-Sidecar, um zu verstehen, wie die Adresse der Zielanwendung konfiguriert wird. Bestätige, wie ein Pfadpräfix durch das Sidecar übergeben werden könnte, und überprüfe anschließend, dass die vorgeschlagene Microcks-Topologie mit der gezeigten Verwendung von withAppPathPrefix funktioniert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
testing
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.