| My Tech Radar | Building Reliable Microservices made easy | Lets meet New champion `Dapr.io `

Lets build quick start POC for Dapr.io and happy learning with me

Vaibhav H Patil
4 min readJan 27, 2024

“We have what we need, if we use what we have.”
— Edgar Cahn

Why Dapr selected?

https://blog.dapr.io/posts/2024/03/10/new-dapr-slide-deck-for-your-presentations/

This is true distrusted application runtime support multiple languages and hides complexity of managing distributed application can work as side car pattern — service mesh and Dapr provides integrated APIs for communication, state, and workflow.

Dapr leverages industry best practices for security, resiliency, and observability, so you can focus on your code.

Refer https://techcommunity.microsoft.com/t5/azure-developer-community-blog/open-at-microsoft-dapr/ba-p/3857064

Who using Dapr? and which use cases can support ?

Born at Microsoft in 2019 as an incubations project, it was donated to the Cloud Native Computing Foundation in 2021 and is now a highly successful open-source project.

Used by leading enterprise client https://dapr.io/testimonials/

Integration ,resilience, saleable system use case easily managed by Dapr.

Now lets build quick start POC

Pre-Requisites

Used OS = Windows

Install docker desktop or Podamn desktop

1- Install CLI > using below link

HURRAY!!

https://aka.ms/dapr-getting-started

2. verify initiation of sidecar done or not ?

run command > explorer “%USERPROFILE%\.dapr\”

3. create default component using command

dapr run — app-id myapp — dapr-http-port 3500

Keep learning !! don't stop

4. push state on default component

/home/mobaxterm  curl -X POST -H "Content-Type: application/json" -d '[{ "key": "name", "value": "Bruce Wayne"}]' http://localhost:3500/v1.0/state/statestore

5. Get component state with feature> store a service’s data as key/value pairs in supported state stores.

/home/mobaxterm  curl http://localhost:3500/v1.0/state/statestore/name

> "Bruce Wayne" ✓

Work hard !

6. Lets run small Go application sample

git clone https://github.com/dapr/quickstarts.git

7. For each below location of folder run go build .

cd \quickstarts\service_invocation\go\http\order-processor

cd \quickstarts\service_invocation\go\http\checkout

8. Option 1 Run application using > Use with Multi-App Run

Note export ENV variables depends on your local machine

Option run all application mulit mode

poc\dapr\cli>set DAPR_HOST=http://localhost 

poc\dapr\cli>set DAPR_HTTP_PORT=6006

poc\dapr\cli>dapr run -f .
Focus

9. Run application as Option 2 : > separate dapr application

Navigate to each folder and run application

poc\dapr\cli\order-processor>dapr run --app-port 6006 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- go run .
poc\dapr\cli>set DAPR_HOST=http://localhost 

poc\dapr\cli>set DAPR_HTTP_PORT=6006

\poc\dapr\cli\checkout>dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- go run .

10 Verify side car service Zipkin for above call http://localhost:9411/zipkin/traces/5a87dc40d80ef245639d226636ed1100

Aim high

Note if you come across below error then order-processor application not discoverable

checkout == Order passed: {"errorCode":"ERR_DIRECT_INVOKE","message":"failed to invoke, id: order-processor, err: couldn't find service: order-processor"}

Then export set DAPR_HOST=http://lo calhost and set DAPR_HTTP_PORT=6006 issue will fix.

Happy learning !! keep in touch !! lets catchup next time with new technology POC , lets build and share knowledge !!

Photo by Caleb Chen on Unsplash

Ref

Lets build next with https://nats.io/#microservices wait for my next post !!

Thanks !

--

--

Vaibhav H Patil

Technology architect , R&ND mind set, Alone we can do so little; together we can do so much..