Skip to content

diagrid-labs/dapr-a2a

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dapr-a2a

Sample project for adding Dapr to A2A samples.

Source: https://github.com/a2aproject/a2a-samples/tree/main/samples/java/custom_java_impl

1. Run Sentry

cd $HOME/.dapr
./sentry --issuer-credentials $HOME/.dapr/certs --trust-domain localhost --healthz-port 8090 --config config.yaml

2. Run Server Sidecar

export DAPR_TRUST_ANCHORS=`cat $HOME/.dapr/certs/ca.crt`
export DAPR_CERT_CHAIN=`cat $HOME/.dapr/certs/issuer.crt`
export DAPR_CERT_KEY=`cat $HOME/.dapr/certs/issuer.key`
export NAMESPACE=default

daprd \
  --app-id server \
  --app-port 8080 \
  --app-protocol http \
  --enable-app-health-check \
  --app-health-check-path "/.well-known/agent-card.json" \
  --app-health-probe-interval 30 \
  --app-health-probe-timeout 200 \
  --app-health-threshold 2 \
  --dapr-http-port 3501 \
  --dapr-grpc-port 4000 \
  --config resources/server-config.yaml \
  --log-level debug \
  --metrics-port 9191 \
  --enable-mtls \
  --sentry-address localhost:50001 \
  --mode standalone

3. Run Server

export OPENAI_BASE_URL="https://api.openai.com"
export OPENAI_CHAT_MODEL="gpt-4o"

java -jar target/a2a-server-0.0.1-SNAPSHOT.jar

4. Run Client Dapr Sidecar

export DAPR_TRUST_ANCHORS=`cat $HOME/.dapr/certs/ca.crt`
export DAPR_CERT_CHAIN=`cat $HOME/.dapr/certs/issuer.crt`
export DAPR_CERT_KEY=`cat $HOME/.dapr/certs/issuer.key`
export NAMESPACE=default

daprd \
  --app-id client \
  --dapr-http-port 3502 \
  --dapr-grpc-port 4002 \
  --config resources/client-config.yaml \
  --resources-path resources \
  --log-level debug \
  --metrics-port 9192 \
  --enable-mtls=true \
  --sentry-address localhost:50001 \
  --mode standalone

5. Modify Client to Use Dapr

Change the client URL to use Dapr sidecar:

git diff src/main/java/com/google/a2a/client/A2AClientExample.java

-        A2AClient client = new A2AClient("http://localhost:8080");
+        A2AClient client = new A2AClient("http://localhost:3502/v1.0/invoke/server/method/");

6. Run Client

java -jar target/a2a-client-0.0.1-SNAPSHOT.jar

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published