接口 ConfigService


  • public interface ConfigService
    Config Service Interface.
    作者:
    Nacos
    • 方法概要

      所有方法 实例方法 抽象方法 
      修饰符和类型 方法 说明
      void addListener​(java.lang.String dataId, java.lang.String group, Listener listener)
      Add a listener to the configuration, after the server modified the configuration, the client will use the incoming listener callback.
      java.lang.String getConfig​(java.lang.String dataId, java.lang.String group, long timeoutMs)
      Get config.
      java.lang.String getConfigAndSignListener​(java.lang.String dataId, java.lang.String group, long timeoutMs, Listener listener)
      Get config and register Listener.
      java.lang.String getServerStatus()
      Get server status.
      boolean publishConfig​(java.lang.String dataId, java.lang.String group, java.lang.String content)
      Publish config.
      boolean publishConfig​(java.lang.String dataId, java.lang.String group, java.lang.String content, java.lang.String type)
      Publish config.
      boolean publishConfigCas​(java.lang.String dataId, java.lang.String group, java.lang.String content, java.lang.String casMd5)
      Cas Publish config.
      boolean publishConfigCas​(java.lang.String dataId, java.lang.String group, java.lang.String content, java.lang.String casMd5, java.lang.String type)
      Cas Publish config.
      boolean removeConfig​(java.lang.String dataId, java.lang.String group)
      Remove config.
      void removeListener​(java.lang.String dataId, java.lang.String group, Listener listener)
      Remove listener.
      void shutDown()
      Shutdown the resource service.
    • 方法详细资料

      • getConfig

        java.lang.String getConfig​(java.lang.String dataId,
                                   java.lang.String group,
                                   long timeoutMs)
                            throws NacosException
        Get config.
        参数:
        dataId - dataId
        group - group
        timeoutMs - read timeout
        返回:
        config value
        抛出:
        NacosException - NacosException
      • getConfigAndSignListener

        java.lang.String getConfigAndSignListener​(java.lang.String dataId,
                                                  java.lang.String group,
                                                  long timeoutMs,
                                                  Listener listener)
                                           throws NacosException
        Get 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 - dataId
        group - group
        timeoutMs - read timeout
        listener - Listener
        返回:
        config value
        抛出:
        NacosException - NacosException
      • addListener

        void addListener​(java.lang.String dataId,
                         java.lang.String group,
                         Listener listener)
                  throws NacosException
        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 - dataId
        group - group
        listener - listener
        抛出:
        NacosException - NacosException
      • publishConfig

        boolean publishConfig​(java.lang.String dataId,
                              java.lang.String group,
                              java.lang.String content)
                       throws NacosException
        Publish config.
        参数:
        dataId - dataId
        group - group
        content - content
        返回:
        Whether publish
        抛出:
        NacosException - NacosException
      • publishConfig

        boolean publishConfig​(java.lang.String dataId,
                              java.lang.String group,
                              java.lang.String content,
                              java.lang.String type)
                       throws NacosException
        Publish config.
        参数:
        dataId - dataId
        group - group
        content - content
        type - config type ConfigType
        返回:
        Whether publish
        抛出:
        NacosException - NacosException
      • publishConfigCas

        boolean publishConfigCas​(java.lang.String dataId,
                                 java.lang.String group,
                                 java.lang.String content,
                                 java.lang.String casMd5)
                          throws NacosException
        Cas Publish config.
        参数:
        dataId - dataId
        group - group
        content - content
        casMd5 - casMd5 prev content's md5 to cas.
        返回:
        Whether publish
        抛出:
        NacosException - NacosException
      • publishConfigCas

        boolean publishConfigCas​(java.lang.String dataId,
                                 java.lang.String group,
                                 java.lang.String content,
                                 java.lang.String casMd5,
                                 java.lang.String type)
                          throws NacosException
        Cas Publish config.
        参数:
        dataId - dataId
        group - group
        content - content
        casMd5 - casMd5 prev content's md5 to cas.
        type - config type ConfigType
        返回:
        Whether publish
        抛出:
        NacosException - NacosException
      • removeConfig

        boolean removeConfig​(java.lang.String dataId,
                             java.lang.String group)
                      throws NacosException
        Remove config.
        参数:
        dataId - dataId
        group - group
        返回:
        whether remove
        抛出:
        NacosException - NacosException
      • removeListener

        void removeListener​(java.lang.String dataId,
                            java.lang.String group,
                            Listener listener)
        Remove listener.
        参数:
        dataId - dataId
        group - group
        listener - listener
      • getServerStatus

        java.lang.String getServerStatus()
        Get server status.
        返回:
        whether health