{"id":8830,"date":"2022-10-10T21:44:11","date_gmt":"2022-10-10T21:44:11","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8830"},"modified":"2022-10-11T08:26:23","modified_gmt":"2022-10-11T08:26:23","slug":"trying-out-dapr","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/trying-out-dapr\/","title":{"rendered":"Trying out Dapr"},"content":{"rendered":"<p><em>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind.<\/em><\/p>\n<p>I&#8217;ve been messing around with microservices in one form or another. Once you start down this route (at least in a Microsoft world) you come across Dapr (Distributed Application Runtime). Let&#8217;s take a look at what it offers us.<\/p>\n<p>To get started simple visit <a href=\"https:\/\/docs.dapr.io\/getting-started\/\" rel=\"noopener\" target=\"_blank\">Getting started with Dapr<\/a> and follow the steps to install and initialize Dapr, I&#8217;m going to reproduce the current steps here for completeness.<\/p>\n<ul>\n<li>Install Dapr, I&#8217;m doing this on a Linux box hence using\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nwget -q https:\/\/raw.githubusercontent.com\/dapr\/cli\/master\/install\/install.sh -O - | \/bin\/bash\r\n<\/pre>\n<\/li>\n<li>Verify the installation by running\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndapr\r\n<\/pre>\n<\/li>\n<li>Initialize dapr by running\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndapr init\r\n<\/pre>\n<p>this will download and set up components, which basically means it&#8217;s download and then run up openzipkin\/zipkin, daprio\/dapr and redis docker images, so now we can check those by running<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker ps\r\n<\/pre>\n<\/li>\n<li>Dapr creates a components directory, for Linix here <em>$HOME\/.dapr<\/em> and for Windows here <em>%USERPROFILE%\\.dapr\\<\/em><\/li>\n<\/ul>\n<p><strong>All installed, now what?<\/strong><\/p>\n<p>Dapr is a <em>sidecar architecture<\/em> which basically means it exposes HTTP and gRPC either via container or process. So applications do not need to reference Dapr&#8217;s runtime instead they use Dapr as a service. The <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/architecture\/patterns\/sidecar\" rel=\"noopener\" target=\"_blank\">sidecar pattern<\/a> is classed as a cloud design pattern.<\/p>\n<p>What Dapr&#8217;s done is given us some &#8220;standard&#8221; application combination, accessible via Dapr in an agnostic manner, i.e. via HTTP calls, we can run up an instance of Dapr using<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndapr run --apo-id {your-app-id} --dapr-htt-port {the-port-to-access-dapr}\r\n<\/pre>\n<p>So for example <em>dapr run &#8211;app-id myapp &#8211;dapr-http-port 3500<\/em> will run Dapr up on port 3500 with the app_id of <em>myapp<\/em>.<\/p>\n<p>The output from the above command will show metrics running on (in my case) port 44333. We can access this from our browser. <\/p>\n<p>By default, zipkin is running on port 9411 (just check docker ps) and can be accessed from your browser using http:\/\/{your-server-ip}:9411\/zipkin\/<\/p>\n<p>As Redis is also running we can access it using the Redis CLI, for example <\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ndocker exec -it dapr_redis redis-cli\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind. I&#8217;ve been messing around with microservices in one form or another. Once you start down this route (at least in a Microsoft [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[338],"tags":[],"class_list":["post-8830","post","type-post","status-publish","format-standard","hentry","category-dapr"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8830"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8830\/revisions"}],"predecessor-version":[{"id":9567,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8830\/revisions\/9567"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}