Uploaded image for project: 'Apache ServiceComb'
  1. Apache ServiceComb
  2. SCB-425

Add an easier way to read configurations

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • None
    • None
    • Java-Chassis
    • None

    Description

      Background:

      Read configurations for microservice or operation is quite common in code, e.g.

      config = CONSUMER_FAULTINJECTION + serviceName + ".schemas." + schema + "."
      + CONSUMER_FAULTINJECTION_POLICY_PROTOCOLS + invocation.getTransport().getName() + "." + key;
      value = getConfigValue(config);
      if ((value != FAULT_INJECTION_DEFAULT_VALUE)) {
      return value;
      }
      config = CONSUMER_FAULTINJECTION + serviceName + "." + CONSUMER_FAULTINJECTION_POLICY_PROTOCOLS
      + invocation.getTransport().getName() + "." + key;
      value = getConfigValue(config);
      if ((value != FAULT_INJECTION_DEFAULT_VALUE)) {
      return value;
      }
      config = CONSUMER_FAULTINJECTION_GLOBAL + CONSUMER_FAULTINJECTION_POLICY_PROTOCOLS
      + invocation.getTransport().getName() + "." + key;
      

      This code is very long and add callbacks if hard for user code. 

       

      Suggestions:

      We need a easier way to read configurations, code snippets: 

      @Configuration(name="cse.myconfiguration")
      class MyConfiguration
      {
         @Configuration(name="prop1")
         String prop1;
         @Configuration(name="prop2")
         String prop2;
      }
      
      MyConfiguration configuration = ConfigurationFactory.getReference(invocation.getQualifiedMicroserviceName())

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            liubao68 liubao
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment