Skip to content

Commit 659f761

Browse files
committed
add structformat doc
Signed-off-by: seal90 <578935869@qq.com>
1 parent 491511c commit 659f761

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

  • daprdocs/content/en/reference/components-reference/supported-name-resolution
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
type: docs
3+
title: "StructuredFormat"
4+
linkTitle: "StructuredFormat"
5+
description: Detailed information on the StructuredFormat name resolution component
6+
---
7+
8+
9+
The Structured Format name resolver provides a flexible way to resolve service names using predefined JSON or YAML format templates. It is particularly useful in scenarios where no dedicated service registry is available.
10+
11+
## Configuration
12+
13+
Name resolution is configured via the [Dapr Configuration]({{< ref configuration-overview.md >}}).
14+
15+
Within the configuration YAML, set the `spec.nameResolution.component` property to `"structuredformat"`, then pass configuration options in the `spec.nameResolution.configuration` dictionary.
16+
17+
```yaml
18+
apiVersion: dapr.io/v1alpha1
19+
kind: Configuration
20+
metadata:
21+
name: appconfig
22+
spec:
23+
nameResolution:
24+
component: "structuredformat"
25+
configuration:
26+
structuredType: "jsonString"
27+
stringValue: '{"appInstances":{"myapp":[{"domain":"","ipv4":"127.0.0.1","ipv6":"","port":4433,"extendedInfo":{"hello":"world"}}]}}'
28+
```
29+
30+
## Spec configuration fields
31+
32+
| Field | Required | Details | Example |
33+
|---------|----------|---------|---------|
34+
| structuredType | Y | Structured type: jsonString, yamlString, jsonFile, yamlFile. | jsonString |
35+
| stringValue | N | This field must be configured when structuredType is set to jsonString or yamlString. | {"appInstances":{"myapp":[{"domain":"","ipv4":"127.0.0.1","ipv6":"","port":4433,"extendedInfo":{"hello":"world"}}]}} |
36+
| filePath | N | This field must be configured when structuredType is set to jsonFile or yamlFile. | /path/to/yamlfile.yaml |
37+
38+
## Examples
39+
40+
Service ID "myapp" → "127.0.0.1:4433"
41+
42+
- By jsonString
43+
```yaml
44+
apiVersion: dapr.io/v1alpha1
45+
kind: Configuration
46+
metadata:
47+
name: appconfig
48+
spec:
49+
nameResolution:
50+
component: "structuredformat"
51+
configuration:
52+
structuredType: "jsonString"
53+
stringValue: '{"appInstances":{"myapp":[{"domain":"","ipv4":"127.0.0.1","ipv6":"","port":4433,"extendedInfo":{"hello":"world"}}]}}'
54+
```
55+
56+
- By yamlString
57+
58+
```yaml
59+
apiVersion: dapr.io/v1alpha1
60+
kind: Configuration
61+
metadata:
62+
name: appconfig
63+
spec:
64+
nameResolution:
65+
component: "structuredformat"
66+
configuration:
67+
structuredType: "yamlString"
68+
stringValue: |
69+
appInstances:
70+
myapp:
71+
- domain: ""
72+
ipv4: "127.0.0.1"
73+
ipv6: ""
74+
port: 4433
75+
extendedInfo:
76+
hello: world
77+
```
78+
79+
## Notes
80+
81+
- Empty service IDs are not allowed and will result in an error
82+
- Accessing a non-existent service will also result in an error
83+
- The structured format string must be provided in the configuration
84+
- The program selects the first available address according to the priority order: domain → IPv4 → IPv6, and appends the port to form the final target address

0 commit comments

Comments
 (0)