| <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Apache Dubbo – Erlang</title><link>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/</link><description>Recent content in Erlang on Apache Dubbo</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><atom:link href="https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/index.xml" rel="self" type="application/rss+xml"/><item><title>Docsv2.7: 快速开始</title><link>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/quick-start/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/quick-start/</guid><description> |
| <p>建议先使用 java 定义接口 jar,并使用 <a href="https://github.com/apache/dubbo-erlang/tree/master/tools/erlanalysis">erlanalysis</a> 工具解析java接口至Erlang lib</p> |
| <h2 id="导入依赖库">导入依赖库</h2> |
| <h3 id="使用-rebar-编译工具">使用 Rebar 编译工具。</h3> |
| <p>Add dubblerl to rebar.config with your project</p> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span>{deps, [ |
| </span></span><span style="display:flex;"><span> {dubboerl, {git, <span style="color:#2aa198">&#34;https://github.com/apache/dubbo-erlang.git&#34;</span>, {branch, <span style="color:#2aa198">&#34;master&#34;</span>}}} |
| </span></span><span style="display:flex;"><span>]}. |
| </span></span></code></pre></div><h3 id="使用-erlangmk-编译工具">使用 erlang.mk 编译工具</h3> |
| <p><code>待补充</code></p> |
| <h2 id="导入接口库">导入接口库</h2> |
| <p>Suppose the interface lib you exported is called dubbo_service.</p> |
| <ul> |
| <li>If you didn&rsquo;t upload your lib to your git repository, It is recommended that you copy the <code>dubbo_service</code> lib |
| into the project&rsquo;s <code>apps</code> directory.</li> |
| <li>If it is upload to your git repository, you can import like this:</li> |
| </ul> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span>{deps, [ |
| </span></span><span style="display:flex;"><span> {dubboerl, {git, <span style="color:#2aa198">&#34;https://github.com/apache/dubbo-erlang.git&#34;</span>, {branch, <span style="color:#2aa198">&#34;master&#34;</span>}}}, |
| </span></span><span style="display:flex;"><span> {dubbo_service,{git,<span style="color:#2aa198">&#34;${INTERFACE_LIB_URL}&#34;</span>,{branch,<span style="color:#2aa198">&#34;master&#34;</span>}}} <span style="color:#586e75">%% replace ${INTERFACE_LIB_URL} with your lib git repos url |
| </span></span></span><span style="display:flex;"><span><span style="color:#586e75"></span>]}. |
| </span></span></code></pre></div><h2 id="消费者配置">消费者配置</h2> |
| <p>Please reference <a href="../reference/">Reference Config</a></p> |
| <h2 id="init-dubbolib-in-your-project">Init dubbolib in your project</h2> |
| <p>It is need you</p> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span>dubboerl:<span style="color:#268bd2">init</span>(). |
| </span></span></code></pre></div><h2 id="如何调用">如何调用?</h2> |
| <h3 id="同步调用">同步调用</h3> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span><span style="color:#268bd2">Request</span> <span style="color:#719e07">=</span> #userInfoRequest{requestId <span style="color:#719e07">=</span> <span style="color:#2aa198">123</span>, username <span style="color:#719e07">=</span> <span style="color:#2aa198">&#34;testname&#34;</span>}, |
| </span></span><span style="display:flex;"><span>{ok,<span style="color:#268bd2">RequestRef</span>,<span style="color:#268bd2">Response</span>,<span style="color:#268bd2">RpcContent</span>} <span style="color:#719e07">=</span> userOperator:<span style="color:#268bd2">queryUserInfo</span>(<span style="color:#268bd2">Request</span>,#{sync<span style="color:#719e07">=&gt;</span> true}). |
| </span></span></code></pre></div><p>If it occur error, is reponse <code>{error,Reason}</code>.</p> |
| <h3 id="异步调用">异步调用</h3> |
| <p>Default is Async call.</p> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span><span style="color:#268bd2">Request</span> <span style="color:#719e07">=</span> #userInfoRequest{requestId <span style="color:#719e07">=</span> <span style="color:#2aa198">123</span>, username <span style="color:#719e07">=</span> <span style="color:#2aa198">&#34;testname&#34;</span>}, |
| </span></span><span style="display:flex;"><span>{ok,<span style="color:#268bd2">RequestRef</span>} <span style="color:#719e07">=</span> userOperator:<span style="color:#268bd2">queryUserInfo</span>(<span style="color:#268bd2">Request</span>). |
| </span></span><span style="display:flex;"><span> |
| </span></span><span style="display:flex;"><span><span style="color:#586e75">%% you can receive the message after. |
| </span></span></span><span style="display:flex;"><span><span style="color:#586e75"></span><span style="color:#268bd2">handle_cast</span>({msg_back,<span style="color:#268bd2">RequestRef</span>,<span style="color:#268bd2">Response</span>,<span style="color:#268bd2">RpcContent</span>},<span style="color:#268bd2">State</span>). |
| </span></span></code></pre></div><h2 id="示例">示例</h2> |
| <p>参考项目 <a href="https://github.com/apache/dubbo-erlang/tree/master/samples">dubboerl_demo</a></p></description></item><item><title>Docsv2.7: 消费者配置</title><link>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/reference/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/reference/</guid><description> |
| <h2 id="基础配置">基础配置</h2> |
| <p>消费者配置项需要添加到 <code>sys.config</code> 文件 <code>dubboerl</code> 应用配置项里。</p> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span>{dubboerl,[ |
| </span></span><span style="display:flex;"><span> <span style="color:#586e75">%% other config ... |
| </span></span></span><span style="display:flex;"><span><span style="color:#586e75"></span> {consumer,[ |
| </span></span><span style="display:flex;"><span> {<span style="color:#719e07">&lt;&lt;</span><span style="color:#2aa198">&#34;interface fullname&#34;</span><span style="color:#719e07">&gt;&gt;</span>,[<span style="color:#268bd2">Option</span>]}, |
| </span></span><span style="display:flex;"><span> <span style="color:#586e75">%% eg: |
| </span></span></span><span style="display:flex;"><span><span style="color:#586e75"></span> {<span style="color:#719e07">&lt;&lt;</span><span style="color:#2aa198">&#34;org.apache.dubbo.erlang.sample.service.facade.UserOperator&#34;</span><span style="color:#719e07">&gt;&gt;</span>,[]}, |
| </span></span><span style="display:flex;"><span> ]} |
| </span></span><span style="display:flex;"><span>]} |
| </span></span></code></pre></div><p>Option 配置项待添加中。</p></description></item><item><title>Docsv2.7: 提供者配置</title><link>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/service/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/service/</guid><description> |
| <h2 id="基本配置">基本配置</h2> |
| <p>提供者配置项需要添加到 <code>sys.config</code> 文件 <code>dubboerl</code> 应用配置项里。</p> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span>{dubboerl,[ |
| </span></span><span style="display:flex;"><span> <span style="color:#586e75">%% other config ... |
| </span></span></span><span style="display:flex;"><span><span style="color:#586e75"></span> {provider,[ |
| </span></span><span style="display:flex;"><span> {module_implements,interface_module,interface_fullname,[<span style="color:#268bd2">Options</span>]}, |
| </span></span><span style="display:flex;"><span> <span style="color:#586e75">%% eg: |
| </span></span></span><span style="display:flex;"><span><span style="color:#586e75"></span> {userOperator_impl,userOperator,<span style="color:#719e07">&lt;&lt;</span><span style="color:#2aa198">&#34;org.apache.dubbo.erlang.sample.service.facade.UserOperator&#34;</span><span style="color:#719e07">&gt;&gt;</span>,[<span style="color:#268bd2">Option</span>]} |
| </span></span><span style="display:flex;"><span> ]} |
| </span></span><span style="display:flex;"><span>]} |
| </span></span></code></pre></div><table> |
| <thead> |
| <tr> |
| <th>ConfigName</th> |
| <th>Type</th> |
| <th>DefaultValue</th> |
| <th>Remarks</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>module_implements</td> |
| <td>atom()</td> |
| <td>-</td> |
| <td>The service implements module name</td> |
| </tr> |
| <tr> |
| <td>interface_module</td> |
| <td>atom()</td> |
| <td>-</td> |
| <td>Interface module name is transfer form java jar</td> |
| </tr> |
| <tr> |
| <td>interface_fullname</td> |
| <td>binary()</td> |
| <td>-</td> |
| <td>Interface full name is the java class name</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>Option is to be added.</p></description></item><item><title>Docsv2.7: 序列化配置项</title><link>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/serialization/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://dubbo.apache.org/zh-cn/docsv2.7/user/languages/erlang/serialization/</guid><description> |
| <p>当前该库只实现了 <code>dubbo://</code> 通讯协议。</p> |
| <p>序列化方式实现了 <code>hessian</code> 和 <code>json</code> 两种方式。</p> |
| <h2 id="配置样例">配置样例</h2> |
| <p>序列化配置需要添加到 <code>sys.config</code> 文件 <code>dubboerl</code> 应用配置项里。</p> |
| <div class="highlight"><pre tabindex="0" style="color:#93a1a1;background-color:#002b36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-erlang" data-lang="erlang"><span style="display:flex;"><span>{dubboerl,[ |
| </span></span><span style="display:flex;"><span> <span style="color:#586e75">%% other config ... |
| </span></span></span><span style="display:flex;"><span><span style="color:#586e75"></span> {protocol,hessian} |
| </span></span><span style="display:flex;"><span>]} |
| </span></span></code></pre></div><table> |
| <thead> |
| <tr> |
| <th>ConfigName</th> |
| <th>Type</th> |
| <th>DefaultValue</th> |
| <th>Remarks</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>protocol</td> |
| <td>atom()</td> |
| <td>hessian</td> |
| <td>hessian,json</td> |
| </tr> |
| </tbody> |
| </table></description></item></channel></rss> |