Application to look up and hold state from the Google Sheets.
One process will be created per lookup.
This application is run independently of the api project. This allows the application to run on a separate node.
Starting the application:
- First navigate to the application's directory and export the credentials
$ cd apps/data_store
$ mix deps.get
$ export GCP_CREDENTIALS="$(< /path/to/service_account.json)" # see Google Auth Setup below
- Start with
iex --sname data -S mix
- From this iex session you can test by running the following:
iex(data@HULK)1> GenServer.call(DataStore.Receiver, {:get, spreadsheet_id, :google_spreadsheet, %{sheet_name: "Sheet1", range: "A1:L7"}})
# inspect running processes as you retrieve sheets
# (view Data Store application and click on PIDs to view their state)
iex(data@HULK)2> :observer.start
To connect from another node, i.e. the api application:
- Start the data store application like above.
- Navigate to the api's directory
$ cd apps/api
$ mix deps.get
- Start with
iex --sname api -S mix
oriex --sname api -S mix phx.server
- From this iex session you can test by running the following:
iex(api@HULK)4> GenServer.call({DataStore.Receiver, :"data@HULK"}, {:get, spreadsheet_id, :google_spreadsheet, %{sheet_name: "Sheet1", range: "A1:L7"}})
- Use this wizard to create or select a project in the Google Developers Console and automatically turn on the API. Click Continue, then Go to credentials.
- On the Add credentials to your project page, create Service account key.
- Select your project name as service account and JSON as key format, download the created key and rename it to service_account.json.
- Press Manage service accounts on a credential page, copy your Service Account Identifier: [projectname]@[domain].iam.gserviceaccount.com
- Create or open existing Google Spreadsheet document on your Google Drive and add Service Account Identifier as user invited in spreadsheet's Collaboration Settings.