ganesanbbc / WorkOrderSample

0 stars 1 forks source link

Runtime Configurator - via Cmd #7

Open Rosary7 opened 7 years ago

Rosary7 commented 7 years ago

1)Through CMD line:

Steps : gcloud beta runtime-config configs create my-config gcloud beta runtime-config configs variables set name test1 --config-name=my-config gcloud beta runtime-config configs variables get-value name --config-name=my-config gcloud beta runtime-config configs variables watch name --config-name=my-config gcloud beta runtime-config configs variables list --config-name=my-config

https://runtimeconfig.googleapis.com/projects/[PROJECT_ID]/configs/[CONFIG_NAME]/variables/[VARIABLE_KEY] https://runtimeconfig.googleapis.com/projects/mytestproject-171506/configs/my-config/variables/test1

2) Through code:

dependency>

com.google.apis
<artifactId>google-api-services-runtimeconfig</artifactId>
<version>v1beta1-rev416-1.22.0</version>

import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; import com.google.api.client.http.HttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.services.runtimeconfig.v1beta1.CloudRuntimeConfig; public String index() throws IOException,GeneralSecurityException{ HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); CloudRuntimeConfig c = new CloudRuntimeConfig(httpTransport,jsonFactory,null); return "Greetings from Spring Boot!"; }

Notes:- Watcher and Waiter: The Runtime Configurator also offers a Watcher service and a Waiter service. The Watcher service watches a specific key pair and returns when the value of the key pair changes, while the Waiter service waits for a specific end condition and returns a response once that end condition has been met.