You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.0: Update usage of new service discovery helper API
Since v1.13.0 new helper API is introduced.
It makes supporting service_discovery easy.
ref. fluent/fluentd#3299
Signed-off-by: Kentaro Hayashi <[email protected]>
@@ -66,5 +74,63 @@ It manages service discovery functionalities such as updating target services an
66
74
67
75
*[`out_forward`](../output/forward.md)
68
76
77
+
## Migration guide from `service_discovery_create_manager` to more simpler helper method
78
+
79
+
Here is the guide to migrate to newer API which is available since v1.13.0.
80
+
81
+
Example:
82
+
83
+
```ruby
84
+
require'fluent/plugin/output'
85
+
86
+
moduleFluent::Plugin
87
+
classExampleOutput < Output
88
+
Fluent::Plugin.register_output('example', self)
89
+
90
+
helpers :service_discovery
91
+
92
+
defconfigure(conf)
93
+
super
94
+
95
+
# 1. Remove the following code which parse 'service_discovery' section by yourself
96
+
#
97
+
# config = conf.elements(name: 'service_discovery').map do |s|
98
+
# { type: :static, conf: s }
99
+
# end
100
+
101
+
# 2. Remove the following code and use service_discovery_configure
102
+
#
103
+
# service_discovery_create_manager(
104
+
# :out_example_service_discovery_watcher,
105
+
# configurations: config,
106
+
# )
107
+
service_discovery_configure(
108
+
:out_example_service_discovery_watcher,
109
+
static_default_service_directive:'server'
110
+
)
111
+
end
112
+
113
+
defwrite(chunk)
114
+
# 3. Remove the following code and use service_discovery_select_service to select service
115
+
#
116
+
# @discovery_manager.select_service do |node|
117
+
# send_data(node, chunk)
118
+
# end
119
+
service_discovery_select_service do |node|
120
+
send_data(node, chunk)
121
+
end
122
+
end
123
+
124
+
defsend_data(node, chunk)
125
+
# Send data
126
+
end
127
+
end
128
+
end
129
+
```
130
+
131
+
You can also use helper methods such as `service_discovery_services` or `service_discovery_rebalance` instead of
132
+
`@discovery_manager.services` or `@discovery_manager.services`.
133
+
134
+
69
135
If this article is incorrect or outdated, or omits critical information, please [let us know](https://github.com/fluent/fluentd-docs-gitbook/issues?state=open). [Fluentd](http://www.fluentd.org/) is an open-source project under [Cloud Native Computing Foundation \(CNCF\)](https://cncf.io/). All components are available under the Apache 2 License.
0 commit comments