Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Remote Config REST API and Versioning

965 views

Published on

This is a presentation material at shibuya.apk @24 Apr 13th in Japan.

Published in: Engineering

Remote Config REST API and Versioning

  1. 1. Remote Con g REST API and Versioning shibuya.apk #24 @red_fat_daruma
  2. 2. Agenda What's Remote Con g? How do we use Remote Con g? What can we do by using REST API? About Remocon
  3. 3. Remote Con g Firebase family Change your app's behavior and view w/o distributing an update Completely free for now
  4. 4. Uses Seasonal stuff which don't depend on device time e.g. promotions, component control etc. A/B testing User segment-based value distributions
  5. 5. Of cial Client Libraries For Android, iOS, Web app Consist of 3 features Fetch con gs and cache them Set default values for missing keys Return an associated value with a key i.e. kinda GET-only KVS client w/ cache system
  6. 6. Overview of Client Default & Fetched Con g are sources for Active Con g ref: https:// rebase.google.com/docs/remote-con g/api-overview
  7. 7. Client libraries kindly handle troublesome problems! e.g. data consistensy, cache etc.
  8. 8. But they are just readers... Cannot be used for Remote Con g management
  9. 9. So far
  10. 10. If you wanna update... Only web UI editor is available You need to click PUBLISH CHANGES after editing
  11. 11. Web UI looks rich! but... No validations for values If you wanna use JSON value, that's horrible Cannot update automatically Publishers might forget to click PUBLISH CHANGES (I often do that) Diffs are not visible Who updated? What was changed? Not friendly for non-developers In addition, don't want them to open projects...
  12. 12. 2018/03/13 Announcing the Remote Con g REST API https://goo.gl/twVB6w
  13. 13. Remote Con g REST API Like single JSON object store and/or Firestore Not key-based management interface Get Fetch con gs from the server as a json le Update Put a json le to update con gs on the server ref: https:// rebase.google.com/docs/remote-con g/use-con g-rest
  14. 14. Authentication Access token approach 1. Download a service account key of the project 2. Publish an access token (which has a time limit) by using Google API Client
  15. 15. 1. Download a key SERVICE ACCOUNTS tab in your project setting
  16. 16. Publish an access token For example, this is for python2. % sudo easy_install oauth2client % YOUR_EDITOR publish_access_token.py
  17. 17. API Spec Endpoint https:// rebaseremotecon g.googleapis.com/v1/projects/${your_p roject_id}/remoteCon g Supported methods GET PUT (w/ a le upload) Accept-Encoding: deflate, gzip is required If missing, Etag is not included
  18. 18. GET con gs The of cial sample is based on curl curl --compressed -D headers -H "Authorization: Bearer $token" -X GET "$ENDPOINT" -o "$output_file_path" # --compressed is required to see etag
  19. 19. PUT con gs curl --compressed -i -H "Content-Type: application/json; UTF8" -H "If-Match: last-returned-etag" -H "Authorization: Bearer $token" -X PUT "$ENDPOINT" -d @filename_of_config_json # --compressed is required if you wanna see etag
  20. 20. Web UI looks rich! but... (again) No validations for values If you wanna use JSON value, that's horrible Cannot update automatically Publishers might forget to click PUBLISH CHANGES (I often do that) Diffs are not visible Who updated? What was changed? Not friendly for non-developers In addition, don't want them to open projects...
  21. 21. What we can do w/ REST API Value validations by your code Nested json is not allowed so json validator is still required Update automatically by your code PUT API publishes changes immediately Diffs would be visible on your VCS Non-developers can change con gs safely w/o rebase permission by your code
  22. 22. Btw, are diffs readable between jsons?
  23. 23. The answer is NO
  24. 24. Okay, I'll do it by myself... so where is a sdk?
  25. 25. THERE IS NO SDK
  26. 26. Remocon Ruby Gem - https://github.com/jmatsu/remocon YAML-based RemoteCon g manager Additional features Validation system File content load
  27. 27. How to use 1. Install remocon 2. Prepare an access token 3. export the following variables FIREBASE_PROJECT_ID REMOTE_CONFIG_ACCESS_TOKEN 4. Run commands!
  28. 28. Get con gs remocon pull --dest=${output_dir}` Create 4 les con g.json : raw.json on the server etag : etag conditions.yml : condition de nitions parameters.yml : parameter de nitions
  29. 29. Get con gs remocon pull --dest=${output_dir}` Create 4 les con g.json : raw json on the server etag : etag conditions.yml : condition de nitions parameters.yml : parameter de nitions Only parameters.yml is what you will update
  30. 30. Update con gs Create a json le to be uploaded Of course, validations run in this section remocon create --conditions="/path/to/conditions.yml" --parameters="/path/to/parameters.yml"` And then, push it to the server remocon push --source="/path/to/config.json" --etag="/path/to/etag"
  31. 31. Validation Just run the following command remocon validation --conditions="/path/to/conditions.yml" --parameters="/path/to/parameters.yml"`
  32. 32. Format of parameters.yml
  33. 33. How does it work on CI? On feature branch Just validate On master Load a service account json Publish an access token Just push your les So it's like terraform's plan and apply ref: http://tech.mercari.com/entry/2018/04/09/110000
  34. 34. Future work Diff-based update A prototype already worked on my local... More readable diff command Plugin system for validators Fix a bug which was found while creating these slides Make it stable... and 1.0.0 release
  35. 35. Appendix1 Can we start with a blank remote con g? Yes. But you need to get the initial Etag by calling GET api. Can we update con gs regularly or speci c time? Partially yes. Firebase doesn't have such features, so we need to use a time-based job scheduler like cron. Can we create conditions by API? No. You need to create them from the console.
  36. 36. Appendix2 Best practice for fetching Remote Con g https://goo.gl/Uw5nzq If you know how to build expressions of conditions, please let me know...!!!

×