This example shows how to add, delete, modify, and watch the apollo configuration center through Layotto.
You can skip this step, you don't need to deploy the apollo server yourself to use this demo. This demo will use the demo environment provided by apollo official: http://106.54.227.205/
If you have deployed apollo yourself, you can modify Layotto's config file to change the apollo server address to your own.
After downloading the project code to the local, switch the code directory and compile:
cd ${projectpath}/cmd/layotto
go buildAfter success, a new layotto file will be generated in the directory. Let's run it:
./layotto start -c ../../configs/config_apollo.jsonThe client demo calls Layotto to add, delete, modify, and query configuration
cd ${projectpath}/demo/configuration/apollo
go build -o apolloClientDemo
./apolloClientDemoIf the following information is printed, the call is successful:
save key success
get configuration after save, &{Key:key1 Content:value1 Group:application Label:prod Tags:map[feature:print release:1.0.0] Metadata:map[]}
get configuration after save, &{Key:haha Content:heihei Group:application Label:prod Tags:map[feature:haha release:1.0.0] Metadata:map[]}
delete keys success
write start
receive subscribe resp store_name:"apollo" app_id:"apollo" items:<key:"heihei" content:"heihei1" group:"application" label:"prod" tags:<key:"feature" value:"haha" > tags:<key:"release" value:"16" > >The client demo uses the golang version SDK provided by Layotto. The SDK is located in the sdk directory. Users can directly call the APIs provided by Layotto through the corresponding SDK.
Besides the SDK,you can also call Layotto server directly using grpc,which makes it easy for different language to interact with Layotto.