<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: abser</title>
    <description>The latest articles on DEV Community by abser (@abserari).</description>
    <link>https://dev.to/abserari</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F453553%2F137a0e72-630c-436c-a0f2-732eb29ecd5a.png</url>
      <title>DEV Community: abser</title>
      <link>https://dev.to/abserari</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abserari"/>
    <language>en</language>
    <item>
      <title>如何编写像 Google Doc 一样的文档</title>
      <dc:creator>abser</dc:creator>
      <pubDate>Sat, 29 Aug 2020 06:59:28 +0000</pubDate>
      <link>https://dev.to/abserari/google-doc-1df3</link>
      <guid>https://dev.to/abserari/google-doc-1df3</guid>
      <description>&lt;p&gt;&lt;a href="https://www.notion.so/Google-Doc-d3b0e0d910874ffdb59a06fc3c7219a7"&gt;More readable&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;如何自己编写像 google doc 一样的文档, 阅读 &lt;a href="https://developers.google.com/tech-writing/one/just-enough-grammar"&gt;Google Writing Principle&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  基础部分
&lt;/h1&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  使用术语
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;术语使用要保持前后一致&lt;/li&gt;
&lt;li&gt;缩略词第一次出现应为 &lt;code&gt;Telekinetic Tactile Network (TTN)&lt;/code&gt;  形式&lt;/li&gt;
&lt;li&gt;使用术语全称还是缩略词需要考究.&lt;/li&gt;
&lt;li&gt;重用名词而不是使用代词.(就像指针一样, 代词往往会引入错误和歧义) &lt;del&gt;This, That, It, Them&lt;/del&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  使用主动语态(谁对谁做了什么)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wxyLzGzq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tuqrlko1vge5h7r4o8g9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wxyLzGzq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tuqrlko1vge5h7r4o8g9.png" alt="Alt Text" width="842" height="183"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6aPZUhTH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fi54rimtnki4z4n397te.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6aPZUhTH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fi54rimtnki4z4n397te.png" alt="Alt Text" width="880" height="194"&gt;&lt;/a&gt;&lt;br&gt;大多数人的思维方式是主动语态, 可以帮助读者跳过预处理器阶段,直接进行编译. 并且主动语态更短. 被动语态有时会省略 actor.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;错误例子

&lt;ul&gt;
&lt;li&gt;It has been suggested that...&lt;/li&gt;
&lt;li&gt;Data was taken...&lt;/li&gt;
&lt;li&gt;Statistics were calculated...&lt;/li&gt;
&lt;li&gt;Results were evaluated.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  消除句子歧义
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  使用准确的动词
&lt;/h3&gt;

&lt;p&gt;The error &lt;del&gt;&lt;strong&gt;occurs&lt;/strong&gt;&lt;/del&gt;&lt;strong&gt; &lt;/strong&gt;when clicking the Submit button.&lt;br&gt;💡Clicking the Submit button &lt;strong&gt;triggers &lt;/strong&gt;the error.&lt;br&gt;&lt;br&gt;
&lt;br&gt;This error message &lt;del&gt;&lt;strong&gt;happens&lt;/strong&gt;&lt;/del&gt; when...&lt;br&gt;💡The system &lt;strong&gt;generates&lt;/strong&gt; this error message when...&lt;br&gt;&lt;br&gt;
&lt;br&gt;We &lt;strong&gt;&lt;del&gt;are&lt;/del&gt; &lt;/strong&gt;very careful to ensure...&lt;br&gt;💡We carefully &lt;strong&gt;ensure&lt;/strong&gt;...&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  去掉 There is, There are
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;&lt;del&gt;There is&lt;/del&gt;&lt;/strong&gt; a variable called that stores the current accuracy.&lt;br&gt;💡A variable named stores the current accuracy. The variable stores the current accuracy.&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;del&gt;&lt;strong&gt;There is&lt;/strong&gt;&lt;/del&gt; no guarantee that the updates will be received in sequential order.&lt;br&gt;💡**Clients **might not receive the updates in sequential order.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  减少形容词和副词
&lt;/h3&gt;

&lt;p&gt;Setting this flag makes the application run screamingly fast.&lt;br&gt;💡Setting this flag makes the application run 225-250% faster.&lt;br&gt;&lt;br&gt;
&lt;br&gt;google doc 在这里说, 减少副词会减少语言魅力, 换成数据可以增加可信和准确度, 是值得的. 我认为可以折中一下.&lt;br&gt;💡Setting this flag makes the application run screamingly faster(225-250%).&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  将长句分割成短句
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  直接分割
&lt;/h3&gt;

&lt;p&gt;The late 1950s was a key era for programming languages because IBM introduced Fortran in 1957 and John McCarthy introduced Lisp the following year, which gave programmers both an iterative way of solving problems and a recursive way.&lt;br&gt;💡The late 1950s was a key era for programming languages. IBM introduced Fortran in 1957. John McCarthy invented Lisp the following year. Consequently, by the late 1950s, programmers could solve problems iteratively or recursively.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  给读者选择阅读的权利
&lt;/h3&gt;

&lt;p&gt;To alter the usual flow of a loop, you may use either a **break **statement (which hops you out of the current loop) or a **continue **statement (which skips past the remainder of the current iteration of the current loop).&lt;br&gt;💡To alter the usual flow of a loop, call one of the following statements: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;break&lt;/strong&gt;, which hops you out of the current loop. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;continue&lt;/strong&gt;, which skips past the remainder of the current iteration of the current loop.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  减少多余的词
&lt;/h3&gt;

&lt;p&gt;An input value greater than 100** causes the triggering of logging.&lt;strong&gt;&lt;br&gt;💡An input value greater than 100 **triggers logging.&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;br&gt;✅&lt;code&gt;one sentence = one idea&lt;/code&gt; 记住这个原则&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  列表语义统一
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;区分顺序和无序列表&lt;/li&gt;
&lt;li&gt;列表每一项应为统一格式&lt;/li&gt;
&lt;li&gt;解释列表的含义&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  段落
&lt;/h2&gt;

&lt;p&gt;写作的工作很简单：解开主题部分之间的依赖关系，并在逻辑流中呈现这些部分，使读者能够理解您。&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;使用总分句式A block of code is any set of contiguous code within the same function. For example, suppose you wrote a block of code that detected whether an input line ended with a period. To evaluate a million input lines, create a loop that runs a million times.&lt;br&gt;💡A loop runs the same block of code multiple times. For example, suppose you wrote a block of code that detected whether an input line ended with a period. To evaluate a million input lines, create a loop that runs a million times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;使每段话保持一个主题, 与主题无关的应该舍弃The Pythagorean Theorem states that the sum of the squares of both legs of a right triangle is equal to the square of the hypotenuse. &lt;del&gt;The perimeter of a triangle is equal to the sum of the three sides.&lt;/del&gt; You can use the Pythagorean Theorem to measure diagonal distances. For example, if you know the length and width of a ping-pong table, you can use the Pythagorean Theorem to determine the diagonal distance.~~ To calculate the perimeter of the ping-pong table, sum the length and the width, and then multiply that sum by 2.~~&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;~~&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;不要太长或太短(这个我觉得保持在 3 到 5 句话就合适, 见仁见智)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;问自己三个问题来优化段落表达&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;你要告诉读者什么&lt;/li&gt;
&lt;li&gt;为什么这一点需要读者知道&lt;/li&gt;
&lt;li&gt;读者怎么使用你告知的信息, 或者读者如何知道你说的是正确的.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡    The garp() function returns the delta between a dataset's mean and median. Many people believe unquestioningly that a mean always holds the truth. However, a mean is easily influenced by a few very large or very small data points. Call garp() to help determine whether a few very large or very small data points are influencing the mean too much. A relatively small garp&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  受众
&lt;/h2&gt;

&lt;p&gt;良好的文档= 受众完成任务所需的知识和技能 – 受众当前的知识和技能&lt;br&gt;
确立受众角色, 斟酌使用术语,习语, 并为读者提供可查阅的资料如果需要.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  文档
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;确立文档范围 &lt;code&gt;本文档介绍了 Frambus 项目的总体设计&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;说明受众期望&lt;code&gt;本文档假定您了解矩阵乘法以及如何泡一杯茶&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;简单摘要 &lt;code&gt;比如简介 比如大纲&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;确立文章预期 &lt;code&gt;读者阅读之后期望得到什么知识和技能&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  提高部分
&lt;/h1&gt;

&lt;p&gt;提高部分主要讲述了一些策略用于优化文档. 斟酌选用他, 并持续保持&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;采用样式指南, 比如让写作者统一学习上面的基础部分.&lt;/li&gt;
&lt;li&gt;在受众的角度来审阅文档 - 该策略可能会为受众增加指向资源的链接, 让他们可以了解更多信息&lt;/li&gt;
&lt;li&gt;大声朗读 - 可以避免不自然的措辞, 长句&lt;/li&gt;
&lt;li&gt;初稿后间隔一段时间( hours ) 再回来改进迭代&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  组织大型文档
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;选择类型, 是单个大文档(像这篇文章) 还是一组文档(就像这篇文章使用的 Google Writing 教程)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cnzwhX20--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ag6cvuedj49r4mb9kzg4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cnzwhX20--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ag6cvuedj49r4mb9kzg4.png" alt="Alt Text" width="880" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;整一个大纲&lt;/li&gt;
&lt;li&gt;优化标题表达&lt;/li&gt;
&lt;li&gt;逐步提供信息 (不要一股脑把所有的概念贴在开头)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  画图
&lt;/h3&gt;

&lt;p&gt;figures truly worth a thousand words.&lt;br&gt;
这是最重要的部分, 首先 图片的吸引力比文本大, 也能让读者学到更多. (这个教程说大多数成年人在面临技术文档的时候还是小孩子, 他们更渴望图片.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;给图片标题&lt;/li&gt;
&lt;li&gt;限制单个图片信息量&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yfEP8OtH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lb4yecipwd79attlqufv.png" alt="Alt Text" width="255" height="150"&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--npJS6riK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yf0b1b93rkq2bts2lu82.png" alt="Alt Text" width="207" height="150"&gt;
&lt;/li&gt;
&lt;li&gt;突出重点聚焦注意力&lt;/li&gt;
&lt;li&gt;不断迭代

&lt;ul&gt;
&lt;li&gt;询问自己问题

&lt;ul&gt;
&lt;li&gt;如何简化插图？&lt;/li&gt;
&lt;li&gt;我应该将此插图拆分为两个或更多更简单的插图吗？&lt;/li&gt;
&lt;li&gt;插图中的文字容易阅读吗？文本是否与其背景形成足够的对比？&lt;/li&gt;
&lt;li&gt;要点是什么？&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  例子代码
&lt;/h2&gt;

&lt;p&gt;提供正确的, 简短的, 可重用的代码, 同时保证代码带来的副作用最小&lt;/p&gt;

</description>
      <category>writing</category>
      <category>googledoc</category>
    </item>
    <item>
      <title>Show Our Opensource Contributions on ObserveableHQ or any Website.</title>
      <dc:creator>abser</dc:creator>
      <pubDate>Wed, 26 Aug 2020 10:32:33 +0000</pubDate>
      <link>https://dev.to/abserari/show-our-opensource-contributions-on-observeablehq-or-any-website-29jf</link>
      <guid>https://dev.to/abserari/show-our-opensource-contributions-on-observeablehq-or-any-website-29jf</guid>
      <description>&lt;p&gt;Hello there.  Today I'll bring you the dynamic opensource contributions display table.&lt;/p&gt;

&lt;p&gt;Let's see first.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jfl7qwNC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1u2x5ev7gfqi8t7jjmvv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jfl7qwNC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1u2x5ev7gfqi8t7jjmvv.png" alt="Alt Text" width="880" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://observablehq.com/@yhyddr/open-source-contributions"&gt;live demo&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Github API could provide us the PullRequest info or others. Call the API on the ObserveableHQ Website and show the info as a table view.&lt;/p&gt;

&lt;p&gt;ObserveableHQ is an online book to think with data. You could run js code on it and analytic data.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Configure Github
&lt;/h3&gt;

&lt;p&gt;we first use the github3 API library on ObserveableHQ&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;viewof&lt;/span&gt; &lt;span class="nx"&gt;ghKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;github3&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@yhyddr/github-api-in-observable-v3-and-v4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ghKey give us the power to request info from github.com. and we store it as a secret: the concept of ObserveableHQ, so the secret would not expose to everyone.&lt;/p&gt;

&lt;p&gt;generate the token at your github.com.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C7qznrqf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w31oi862kumop4eqcia4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C7qznrqf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w31oi862kumop4eqcia4.png" alt="Alt Text" width="880" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then fill the input box and click &lt;code&gt;set secret&lt;/code&gt;. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Us4mxtF---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6198kctq5i612s31wjjr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Us4mxtF---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6198kctq5i612s31wjjr.png" alt="Alt Text" width="646" height="305"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you could request GitHub API with this library!🎉&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;PR&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;github3&lt;/span&gt;&lt;span class="s2"&gt;`search/issues?q=author:abserari+type:pr`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PR variable value would contain the PR info of the user: abserari.&lt;/p&gt;

&lt;h3&gt;
  
  
  Work with data.
&lt;/h3&gt;

&lt;p&gt;First import the table so we don't need to type manually to fill the info.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;table&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@gampleman/table&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;use table to map the PR entries to a table&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DisplayPR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;nully&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;&amp;lt;span style="color: red"&amp;gt;No data&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;enableFilter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;enableCSVDownload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;repo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Repo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;render&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
      &lt;span class="c1"&gt;// `&amp;lt;a href="https://google.com/?q=${val}" target="_blank"&amp;gt;${val}&amp;lt;/a&amp;gt;`&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;statusHTML&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Status&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;render&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;

    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;checksHTML&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Checks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;render&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="c1"&gt;// 'body'&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;render&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;val&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we would get the dynamic table on ObserveableHQ!&lt;/p&gt;

&lt;p&gt;Could download the js file and embed it to yourselves app.&lt;/p&gt;

&lt;p&gt;You also could fork my notebook and configure it with your GitHub token.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>observeablehq</category>
      <category>github</category>
    </item>
    <item>
      <title>Introduction to Dapr Source Code With a Pub-Sub Sample</title>
      <dc:creator>abser</dc:creator>
      <pubDate>Mon, 24 Aug 2020 08:57:52 +0000</pubDate>
      <link>https://dev.to/abserari/introduction-to-dapr-source-code-with-a-pub-sub-sample-2ig6</link>
      <guid>https://dev.to/abserari/introduction-to-dapr-source-code-with-a-pub-sub-sample-2ig6</guid>
      <description>&lt;h1&gt;
  
  
  Introduction to Dapr Source Code With a Pub-Sub Sample
&lt;/h1&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zlkuQlwf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.nlark.com/yuque/0/2020/svg/176280/1598163232910-e2fbc481-ba92-44be-8199-98e3d1cfd1e9.svg%23align%3Dleft%26display%3Dinline%26height%3D270%26margin%3D%255Bobject%2520Object%255D%26originHeight%3D270%26originWidth%3D367%26size%3D0%26status%3Ddone%26style%3Dnone%26width%3D367" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zlkuQlwf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.nlark.com/yuque/0/2020/svg/176280/1598163232910-e2fbc481-ba92-44be-8199-98e3d1cfd1e9.svg%23align%3Dleft%26display%3Dinline%26height%3D270%26margin%3D%255Bobject%2520Object%255D%26originHeight%3D270%26originWidth%3D367%26size%3D0%26status%3Ddone%26style%3Dnone%26width%3D367" alt="" width="367" height="270"&gt;&lt;/a&gt;&lt;br&gt;Hello guys, I'll tell you about the Dapr's source code. Dapr is a distributed application runtime. On its official website. It's introduced as: &lt;a href="https://www.yuque.com/abser/blog/qbw6vc/edit#PBQVJ"&gt;An event-driven, portable runtime for building microservices on cloud and edge.&lt;/a&gt; I have followed Dapr for almost one year. When it was published to the public, I wrote two blogs to introduce how I got familiar with Dapr and recorded my steps.&lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.yuque.com/abser/blog/eh303f"&gt;分布式应用运行时 Dapr X Kubernetes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.yuque.com/abser/blog/fa0ntp"&gt;微服务 Dapr HelloWorld&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today, I'm curious about how Dapr have these features: portable, event-driven, etc. so I dig into the source code and wonder if I could learn something from its architecture.&lt;br&gt;&lt;br&gt;
&lt;br&gt;I drew some pictures and stored them &lt;a href="https://www.yuque.com/abser/architecture/artboards/151574"&gt;here&lt;/a&gt;. Hope they are helpful.&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4ekx69jW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bo86seho2xyi3cnt9w9f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4ekx69jW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bo86seho2xyi3cnt9w9f.png" alt="Alt Text" width="746" height="489"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;br&gt;Below we would run a sample called pub-sub sample and explain how the components like pub-sub could be portable to Dapr.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;We need to get Dapr installed. If not, follow &lt;a href="https://dapr.io/"&gt;https://dapr.io/&lt;/a&gt; or my blog. If you have Mac&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/dapr/cli/master/install/install.sh | /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="nv"&gt;$ &lt;/span&gt; dapr init
⌛  Making the jump to hyperspace...
    Downloading binaries and setting up
    components
✅  Success! Dapr is up and running
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;hint: you should have docker installed, too.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Get the code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git clone https://github.com/abserari/go-sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I wrote a simpler example in &lt;a href="https://github.com/abserari/go-sdk"&gt;https://github.com/abserari/go-sdk/example/pubsub&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  SDK-Source Code
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuration
&lt;/h3&gt;

&lt;p&gt;In the configuration, we specify the metadata of the component, like our pub-sub component below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;dapr.io/v1alpha1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Component&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;messagebus&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pubsub.redis&lt;/span&gt;
  &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redisHost&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;192.168.0.253:32220&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;redisPassword&lt;/span&gt;
    &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;123456"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  name: messagebus
&lt;/h4&gt;

&lt;p&gt;Dapr needs the name to configure the API&lt;br&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wa-_AdvU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5wgzo6y1hnwhpedgd4nj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wa-_AdvU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5wgzo6y1hnwhpedgd4nj.jpg" alt="Alt Text" width="647" height="337"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  spec:
&lt;/h4&gt;

&lt;p&gt;This config is to init the components so Dapr could connect.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Pub.go
&lt;/h3&gt;

&lt;p&gt;After we init the Dapr runtime.  we could use pub-sub with go-sdk quickly.&lt;br&gt;
We use this function to publish data to target pub-sub components with pubsubName and specific topicName.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PublishEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pubsubName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;topicName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Sub.go
&lt;/h3&gt;

&lt;p&gt;It's a little unfamiliar with the way of subscribing to Dapr. you should have a server with some handler to tell Dapr runtime what topic you care about and how to notify you with the specific route when Dapr has a message to publish to the topic your concern.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  config subscription
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;sub&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;common&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Subscription&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;PubsubName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"messagebus"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Topic&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="s"&gt;"neworder"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Route&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;      &lt;span class="s"&gt;"/orders"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  add to server
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddTopicEventHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sub&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eventHandler&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Fatalf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"error adding topic subscription: %v"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Run
&lt;/h2&gt;

&lt;p&gt;This &lt;a href="https://github.com/abserari/go-sdk/example/pubsub"&gt;https://github.com/abserari/go-sdk/example/pubsub&lt;/a&gt; folder contains two go files that use this go-SDK to invoke the Dapr PubSub API.&lt;br&gt;
&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Helpful
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--itO9D3_I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/20q9gw4mvmkvhlnxzhv4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--itO9D3_I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/20q9gw4mvmkvhlnxzhv4.jpg" alt="Alt Text" width="667" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Steps
&lt;/h3&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Preparation
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Get dapr installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Run Subscriber Server
&lt;/h4&gt;

&lt;p&gt;When we use Dapr PubSub to subscribe, we should have an http or gRPC server to receive the requests from Dapr.&lt;br&gt;
Please change directory to pubsub/ and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dapr run &lt;span class="nt"&gt;--app-id&lt;/span&gt; sub &lt;span class="se"&gt;\ &lt;/span&gt;
         &lt;span class="nt"&gt;--app-protocol&lt;/span&gt; http &lt;span class="se"&gt;\ &lt;/span&gt;
         &lt;span class="nt"&gt;--app-port&lt;/span&gt; 8080 &lt;span class="se"&gt;\ &lt;/span&gt;
         &lt;span class="nt"&gt;--port&lt;/span&gt; 3500 &lt;span class="se"&gt;\ &lt;/span&gt;
         &lt;span class="nt"&gt;--log-level&lt;/span&gt; debug &lt;span class="se"&gt;\ &lt;/span&gt;
         &lt;span class="nt"&gt;--components-path&lt;/span&gt; ./config &lt;span class="se"&gt;\ &lt;/span&gt;
         go run sub.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Run Publisher
&lt;/h4&gt;

&lt;p&gt;Publish is more simple than subscribe. Just Publish the data to target pubsub component with its' name.&lt;br&gt;
After you start a server by above guide. Please change directory to pubsub/ and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dapr run &lt;span class="nt"&gt;--app-id&lt;/span&gt; pub &lt;span class="se"&gt;\ &lt;/span&gt;
         &lt;span class="nt"&gt;--log-level&lt;/span&gt; debug &lt;span class="se"&gt;\ &lt;/span&gt;
         &lt;span class="nt"&gt;--components-path&lt;/span&gt; ./config &lt;span class="se"&gt;\ &lt;/span&gt;
         go run pub.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Result
&lt;/h3&gt;

&lt;p&gt;You would see the log that in the terminal which runs the server(subscriber) code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;==&lt;/span&gt; APP &lt;span class="o"&gt;==&lt;/span&gt; 2020/08/23 13:21:58 event - PubsubName: messagebus, Topic: demo, ID: 11acaa82-23c4-4244-8969-7360dae52e5d, Data: ping
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dapr Source Code
&lt;/h2&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Registry
&lt;/h3&gt;

&lt;p&gt;We have to know about the Dapr runtime in the real world. then we tell about how Dapr runtime registers the components.&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tXUeVn74--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5ha5kfsgr8khhgfyfubl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tXUeVn74--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5ha5kfsgr8khhgfyfubl.jpg" alt="Alt Text" width="711" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's an interface in Dapr source code and the different realize of components is in github.com/dapr/components-contrib.&lt;/p&gt;

&lt;p&gt;&lt;br&gt;Then Dapr has a registry struct to store the method that use to new a component instance.&lt;br&gt;
&lt;a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Runtime
&lt;/h3&gt;

&lt;p&gt;&lt;br&gt;When we run the dapr. runtime init all the components with YAML files in your path. if in Kubernetes mode, it would read the yaml from Kubernetes.&lt;br&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i_Wqmqhk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y7gmxygb55so5ihidgqr.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i_Wqmqhk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/y7gmxygb55so5ihidgqr.jpeg" alt="Alt Text" width="746" height="467"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;I'm happy to chat with your question on dapr or this article. Please comment or contact me.&lt;/p&gt;

</description>
      <category>dapr</category>
      <category>kubernetes</category>
      <category>servicemesh</category>
    </item>
  </channel>
</rss>
