接口 ConfigService
public interface ConfigService
Config Service Interface.
- 作者:
- Nacos
-
方法概要
修饰符和类型方法说明voidaddListener(String dataId, String group, Listener listener)Add a listener to the configuration, after the server modified the configuration, the client will use the incoming listener callback.Get config.getConfigAndSignListener(String dataId, String group, long timeoutMs, Listener listener)Get config and register Listener.Get server status.booleanpublishConfig(String dataId, String group, String content)Publish config.booleanpublishConfig(String dataId, String group, String content, String type)Publish config.booleanpublishConfigCas(String dataId, String group, String content, String casMd5)Cas Publish config.booleanCas Publish config.booleanremoveConfig(String dataId, String group)Remove config.voidremoveListener(String dataId, String group, Listener listener)Remove listener.voidshutDown()Shutdown the resource service.
-
方法详细资料
-
getConfig
Get config.- 参数:
dataId- dataIdgroup- grouptimeoutMs- read timeout- 返回:
- config value
- 抛出:
NacosException- NacosException
-
getConfigAndSignListener
String getConfigAndSignListener(String dataId, String group, long timeoutMs, Listener listener) throws NacosExceptionGet config and register Listener.If you want to pull it yourself when the program starts to get the configuration for the first time, and the registered Listener is used for future configuration updates, you can keep the original code unchanged, just add the system parameter: enableRemoteSyncConfig = "true" ( But there is network overhead); therefore we recommend that you use this interface directly
- 参数:
dataId- dataIdgroup- grouptimeoutMs- read timeoutlistener-Listener- 返回:
- config value
- 抛出:
NacosException- NacosException
-
addListener
Add a listener to the configuration, after the server modified the configuration, the client will use the incoming listener callback. Recommended asynchronous processing, the application can implement the getExecutor method in the ManagerListener, provide a thread pool of execution. If not provided, use the main thread callback, May block other configurations or be blocked by other configurations.- 参数:
dataId- dataIdgroup- grouplistener- listener- 抛出:
NacosException- NacosException
-
publishConfig
Publish config.- 参数:
dataId- dataIdgroup- groupcontent- content- 返回:
- Whether publish
- 抛出:
NacosException- NacosException
-
publishConfig
boolean publishConfig(String dataId, String group, String content, String type) throws NacosExceptionPublish config.- 参数:
dataId- dataIdgroup- groupcontent- contenttype- config typeConfigType- 返回:
- Whether publish
- 抛出:
NacosException- NacosException
-
publishConfigCas
boolean publishConfigCas(String dataId, String group, String content, String casMd5) throws NacosExceptionCas Publish config.- 参数:
dataId- dataIdgroup- groupcontent- contentcasMd5- casMd5 prev content's md5 to cas.- 返回:
- Whether publish
- 抛出:
NacosException- NacosException
-
publishConfigCas
boolean publishConfigCas(String dataId, String group, String content, String casMd5, String type) throws NacosExceptionCas Publish config.- 参数:
dataId- dataIdgroup- groupcontent- contentcasMd5- casMd5 prev content's md5 to cas.type- config typeConfigType- 返回:
- Whether publish
- 抛出:
NacosException- NacosException
-
removeConfig
Remove config.- 参数:
dataId- dataIdgroup- group- 返回:
- whether remove
- 抛出:
NacosException- NacosException
-
removeListener
Remove listener.- 参数:
dataId- dataIdgroup- grouplistener- listener
-
getServerStatus
String getServerStatus()Get server status.- 返回:
- whether health
-
shutDown
Shutdown the resource service.- 抛出:
NacosException- exception.
-