This document discusses Remote Config, a Firebase service that allows modifying app behavior without deploying updates. It summarizes the Remote Config REST API and a Ruby gem called Remocon that provides additional features for managing Remote Config via a YAML-based approach. Remocon allows validating config values, automatically pushing updates, and viewing diffs between configurations. The document provides code samples for fetching, updating, and validating Remote Config using the REST API and Remocon.
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. Remote Con g
Firebase family
Change your app's behavior
and view w/o distributing an
update
Completely free for now
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. 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. Overview of Client
Default & Fetched
Con g are sources
for Active Con g
ref: https:// rebase.google.com/docs/remote-con g/api-overview
10. If you wanna update...
Only web UI editor is available
You need to click PUBLISH CHANGES after editing
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...
14. 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
15. 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
16. 1. Download a key
SERVICE ACCOUNTS tab in your project setting
17. Publish an access token
For example, this is for python2.
% sudo easy_install oauth2client
% YOUR_EDITOR publish_access_token.py
18. 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
19. 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
20. 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
21. 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...
22. 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
27. Remocon
Ruby Gem - https://github.com/jmatsu/remocon
YAML-based RemoteCon g manager
Additional features
Validation system
File content load
28. 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!
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
30. 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
31. 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"
32. Validation
Just run the following command
remocon validation
--conditions="/path/to/conditions.yml"
--parameters="/path/to/parameters.yml"`
34. 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
35. 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
36. 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.
37. 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...!!!