<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>名称解析提供者组件规范 on Dapr 文档库</title><link>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/</link><description>Recent content in 名称解析提供者组件规范 on Dapr 文档库</description><generator>Hugo</generator><language>zh-hans</language><atom:link href="https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/index.xml" rel="self" type="application/rss+xml"/><item><title>HashiCorp Consul</title><link>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/setup-nr-consul/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/setup-nr-consul/</guid><description>&lt;h2 id="配置格式">配置格式&lt;/h2>
&lt;p>在 &lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/configuration/configuration-overview/">Dapr 配置&lt;/a> 中设置 HashiCorp Consul。&lt;/p>
&lt;p>在配置中，添加 &lt;code>nameResolution&lt;/code> 规范，并将 &lt;code>component&lt;/code> 字段设为 &lt;code>&amp;quot;consul&amp;quot;&lt;/code>。&lt;/p>
&lt;p>如果您使用 Dapr sidecar 将服务注册到 Consul，需要以下配置：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">apiVersion&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">dapr.io/v1alpha1&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">kind&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">Configuration&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">metadata&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">appconfig&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">spec&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">nameResolution&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">component&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;consul&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">configuration&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">selfRegister&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">true&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>如果 Consul 服务注册由 Dapr 外部管理，您需要确保 Dapr 到 Dapr 的内部 gRPC 端口已添加到服务元数据中的 &lt;code>DAPR_PORT&lt;/code>（此键是可配置的），并且 Consul 服务 ID 与 Dapr 应用 ID 匹配。在这种情况下，可以省略上述配置中的 &lt;code>selfRegister&lt;/code>。&lt;/p>
&lt;h2 id="行为">行为&lt;/h2>
&lt;p>在 &lt;code>init&lt;/code> 时，Consul 组件会验证与配置的（或默认的）代理的连接，或者在配置时注册服务。名称解析接口不支持“关闭时”模式，因此在使用 Dapr 将服务注册到 Consul 时请注意，它不会注销服务。&lt;/p>
&lt;p>该组件通过过滤健康服务来解析目标应用，并在元数据中查找 &lt;code>DAPR_PORT&lt;/code>（键是可配置的）以获取 Dapr sidecar 端口。Consul 使用 &lt;code>service.meta&lt;/code> 而不是 &lt;code>service.port&lt;/code>，以避免干扰现有的 Consul 配置。&lt;/p></description></item><item><title>Kubernetes DNS</title><link>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/nr-kubernetes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/nr-kubernetes/</guid><description>&lt;h2 id="配置格式">配置格式&lt;/h2>
&lt;p>一般情况下，&lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/hosting/kubernetes/">Kubernetes 模式&lt;/a>下的 Kubernetes DNS 名称解析由 Dapr 自动配置。除非需要对 Kubernetes 名称解析组件进行特定的覆盖，否则无需额外配置即可使用 Kubernetes DNS 作为名称解析提供者。&lt;/p>
&lt;p>如果需要进行覆盖，可以在 &lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/configuration/configuration-overview/">Dapr 配置&lt;/a> CRD 中，添加一个 &lt;code>nameResolution&lt;/code> 规范，并将 &lt;code>component&lt;/code> 字段设置为 &lt;code>&amp;quot;kubernetes&amp;quot;&lt;/code>。其他配置字段可以根据需要在 &lt;code>configuration&lt;/code> 映射中设置，如下所示。&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">apiVersion&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">dapr.io/v1alpha1&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">kind&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">Configuration&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">metadata&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">appconfig&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">spec&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">nameResolution&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">component&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;kubernetes&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">configuration&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">clusterDomain&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;cluster.local&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 与 template 字段互斥&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">template&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;{{.ID}}-{{.Data.region}}.internal:{{.Port}}&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#8f5902;font-style:italic"># 与 clusterDomain 字段互斥&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="行为">行为&lt;/h2>
&lt;p>该组件通过 Kubernetes 集群的 DNS 提供者来解析目标应用。您可以在 &lt;a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/">Kubernetes 文档&lt;/a>中了解更多信息。&lt;/p>
&lt;h2 id="规范配置字段">规范配置字段&lt;/h2>
&lt;p>配置规范固定为 Consul API 的 v1.3.0 版本&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>字段&lt;/th>
 &lt;th style="text-align: center">必需&lt;/th>
 &lt;th style="text-align: right">类型&lt;/th>
 &lt;th style="text-align: left">详情&lt;/th>
 &lt;th>示例&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>clusterDomain&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;code>string&lt;/code>&lt;/td>
 &lt;td style="text-align: left">用于解析地址的集群域。此字段与 &lt;code>template&lt;/code> 字段互斥。&lt;/td>
 &lt;td>&lt;code>cluster.local&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>template&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;code>string&lt;/code>&lt;/td>
 &lt;td style="text-align: left">使用 &lt;a href="https://pkg.go.dev/text/template#Template">text/template&lt;/a> 解析地址时的模板字符串。模板将由 &lt;a href="https://github.com/dapr/components-contrib/blob/release-1.16/nameresolution/requests.go#L20">ResolveRequest&lt;/a> 结构中的字段填充。此字段与 &lt;code>clusterDomain&lt;/code> 字段互斥。&lt;/td>
 &lt;td>&lt;code>{{.ID}}-{{.Data.region}}.{{.Namespace}}.internal:{{.Port}}&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="相关链接">相关链接&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/service-invocation/">服务调用构建块&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/">Kubernetes DNS 文档&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>mDNS</title><link>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/nr-mdns/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/nr-mdns/</guid><description>&lt;h2 id="配置格式">配置格式&lt;/h2>
&lt;p>在Dapr的&lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/hosting/self-hosted/">自托管模式&lt;/a>中，mDNS会自动配置。使用mDNS作为名称解析提供程序无需进行任何配置。&lt;/p>
&lt;h2 id="行为">行为&lt;/h2>
&lt;p>该组件通过主机系统的mDNS服务来解析目标应用程序。您可以在&lt;a href="https://en.wikipedia.org/wiki/Multicast_DNS">这里&lt;/a>了解更多关于mDNS的信息。&lt;/p>
&lt;h3 id="故障排除">故障排除&lt;/h3>
&lt;p>在某些云提供商的虚拟网络中，例如Microsoft Azure，mDNS可能不可用。请使用其他提供程序，例如&lt;a href="https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/setup-nr-consul/">HashiCorp Consul&lt;/a>。&lt;/p>
&lt;p>在某些企业管理的系统上，如果配置了网络过滤器或代理，macOS上的mDNS可能会被禁用。如果mDNS被禁用且您无法在本地使用服务调用，请与您的IT部门确认。&lt;/p>
&lt;h2 id="规格配置字段">规格配置字段&lt;/h2>
&lt;p>不适用，因为在自托管模式下运行时，mDNS由Dapr自动配置。&lt;/p>
&lt;h2 id="相关链接">相关链接&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/service-invocation/">服务调用构建块&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://en.wikipedia.org/wiki/Multicast_DNS">mDNS参考&lt;/a>&lt;/li>
&lt;/ul></description></item><item><title>SQLite</title><link>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/nr-sqlite/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://v1-18.docs.dapr.io/zh-hans/reference/components-reference/supported-name-resolution/nr-sqlite/</guid><description>&lt;p>SQLite名称解析组件可以作为mDNS的替代方案，适用于在单节点环境中运行Dapr以及本地开发场景。集群中的Dapr sidecar会将其信息存储在本地机器上的SQLite数据库中。&lt;/p>


&lt;div class="alert alert-primary" role="alert">
&lt;h4 class="alert-heading">注意&lt;/h4>

 该组件经过优化，适用于所有Dapr实例运行在同一台物理机器上的场景，数据库通过同一个本地挂载的磁盘进行访问。&lt;br>
通过网络（包括SMB/NFS）使用SQLite名称解析器访问数据库文件可能会导致数据损坏，因此&lt;strong>不支持&lt;/strong>。

&lt;/div>

&lt;h2 id="配置格式">配置格式&lt;/h2>
&lt;p>名称解析通过&lt;a href="https://v1-18.docs.dapr.io/zh-hans/operations/configuration/configuration-overview/">Dapr配置&lt;/a>进行设置。&lt;/p>
&lt;p>在配置YAML中，将&lt;code>spec.nameResolution.component&lt;/code>属性设置为&lt;code>&amp;quot;sqlite&amp;quot;&lt;/code>，然后在&lt;code>spec.nameResolution.configuration&lt;/code>字典中传递配置选项。&lt;/p>
&lt;p>以下是一个基本的配置示例：&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-yaml" data-lang="yaml">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">apiVersion&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">dapr.io/v1alpha1&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">kind&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">Configuration&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">metadata&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">name&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#000">appconfig&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline">&lt;/span>&lt;span style="color:#204a87;font-weight:bold">spec&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">nameResolution&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">component&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;sqlite&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">version&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;v1&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">configuration&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#204a87;font-weight:bold">connectionString&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline"> &lt;/span>&lt;span style="color:#4e9a06">&amp;#34;/home/user/.dapr/nr.db&amp;#34;&lt;/span>&lt;span style="color:#f8f8f8;text-decoration:underline">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="规格配置字段">规格配置字段&lt;/h2>
&lt;p>使用SQLite名称解析组件时，&lt;code>spec.nameResolution.configuration&lt;/code>字典包含以下选项：&lt;/p>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>字段&lt;/th>
 &lt;th style="text-align: center">必需&lt;/th>
 &lt;th style="text-align: right">类型&lt;/th>
 &lt;th style="text-align: left">详情&lt;/th>
 &lt;th>示例&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;code>connectionString&lt;/code>&lt;/td>
 &lt;td style="text-align: center">Y&lt;/td>
 &lt;td style="text-align: right">&lt;code>string&lt;/code>&lt;/td>
 &lt;td style="text-align: left">SQLite数据库的连接字符串。通常，这是磁盘上文件的路径，可以是相对路径或绝对路径。&lt;/td>
 &lt;td>&lt;code>&amp;quot;nr.db&amp;quot;&lt;/code>（相对于工作目录），&lt;code>&amp;quot;/home/user/.dapr/nr.db&amp;quot;&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>updateInterval&lt;/code>&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;a href="https://pkg.go.dev/time#ParseDuration">Go duration&lt;/a> (作为&lt;code>string&lt;/code>)&lt;/td>
 &lt;td style="text-align: left">活跃的Dapr sidecar在数据库中更新其状态的间隔，用作健康检查。&lt;br>较小的间隔减少了应用程序离线时返回过时数据的可能性，但增加了数据库的负载。&lt;br>必须至少比&lt;code>timeout&lt;/code>大1秒。带有秒数分数的值会被截断（例如，&lt;code>1500ms&lt;/code>变为&lt;code>1s&lt;/code>）。默认值：&lt;code>5s&lt;/code>&lt;/td>
 &lt;td>&lt;code>&amp;quot;2s&amp;quot;&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>timeout&lt;/code>&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;a href="https://pkg.go.dev/time#ParseDuration">Go duration&lt;/a> (作为&lt;code>string&lt;/code>)。&lt;br>必须至少为1秒。&lt;/td>
 &lt;td style="text-align: left">数据库操作的超时时间。整数被解释为秒数。默认值为&lt;code>1s&lt;/code>&lt;/td>
 &lt;td>&lt;code>&amp;quot;2s&amp;quot;&lt;/code>，&lt;code>2&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>tableName&lt;/code>&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;code>string&lt;/code>&lt;/td>
 &lt;td style="text-align: left">存储数据的表的名称。如果表不存在，Dapr会创建该表。默认值为&lt;code>hosts&lt;/code>。&lt;/td>
 &lt;td>&lt;code>&amp;quot;hosts&amp;quot;&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>metadataTableName&lt;/code>&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;code>string&lt;/code>&lt;/td>
 &lt;td style="text-align: left">Dapr用于存储组件元数据的表的名称。如果表不存在，Dapr会创建该表。默认值为&lt;code>metadata&lt;/code>。&lt;/td>
 &lt;td>&lt;code>&amp;quot;metadata&amp;quot;&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>cleanupInterval&lt;/code>&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;a href="https://pkg.go.dev/time#ParseDuration">Go duration&lt;/a> (作为&lt;code>string&lt;/code>)&lt;/td>
 &lt;td style="text-align: left">从数据库中删除过时记录的间隔。默认值：&lt;code>1h&lt;/code>（1小时）&lt;/td>
 &lt;td>&lt;code>&amp;quot;10m&amp;quot;&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>busyTimeout&lt;/code>&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;a href="https://pkg.go.dev/time#ParseDuration">Go duration&lt;/a> (作为&lt;code>string&lt;/code>)&lt;/td>
 &lt;td style="text-align: left">在SQLite数据库当前忙于处理另一个请求时等待的间隔，然后返回“数据库忙”错误。这是一个高级设置。&lt;/br>&lt;code>busyTimeout&lt;/code>控制SQLite中的锁定工作方式。对于SQLite，写入是独占的，因此每次任何应用程序写入时，数据库都会被锁定。如果另一个应用程序尝试写入，它会等待最多&lt;code>busyTimeout&lt;/code>时间，然后返回“数据库忙”错误。然而，&lt;code>timeout&lt;/code>设置控制整个操作的超时时间。例如，如果查询“挂起”，在数据库获取锁之后（即在忙超时清除之后），则&lt;code>timeout&lt;/code>生效。默认值：&lt;code>800ms&lt;/code>（800毫秒）&lt;/td>
 &lt;td>&lt;code>&amp;quot;100ms&amp;quot;&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;code>disableWAL&lt;/code>&lt;/td>
 &lt;td style="text-align: center">N&lt;/td>
 &lt;td style="text-align: right">&lt;code>bool&lt;/code>&lt;/td>
 &lt;td style="text-align: left">如果设置为true，则禁用SQLite数据库的预写日志记录。这仅适用于高级场景&lt;/td>
 &lt;td>&lt;code>true&lt;/code>，&lt;code>false&lt;/code>&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h2 id="相关链接">相关链接&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://v1-18.docs.dapr.io/zh-hans/developing-applications/building-blocks/service-invocation/">服务调用构建块&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>