wormhole/event_database
justinschuldt 44fe7bd726 Cloud function for BigTable queries
Change-Id: I8a2c0e349bdebeeeaf8b79f02285615b3a147884
2021-08-23 19:35:04 +00:00
..
cloud_functions Cloud function for BigTable queries 2021-08-23 19:35:04 +00:00
README.md Cloud function for BigTable queries 2021-08-23 19:35:04 +00:00
database.go Write attestation events to BigTable 2021-08-23 09:54:28 -05:00
database_query.go Event database init script 2021-08-05 12:53:56 +00:00
database_setup.go Event database init script 2021-08-05 12:53:56 +00:00
go.mod Event database init script 2021-08-05 12:53:56 +00:00
go.sum Event database init script 2021-08-05 12:53:56 +00:00

README.md

Initializing BigTable instance

Once you've created a BigTable instance and a Service Account key, these Go scripts can create the table and column families to save event data.

Pass your BigTable connection info via args:

  • the Google Cloud projectID
  • BigTable instance name
  • the path to a GCP Service Account with appropriate permissions

Invoke the script with the DB config options and -setupDB to create the table and column families, if they do not already exist. If they do already exists when the script runs, it will do nothing.

go run . \
  -project your-GCP-projectID \
  -instance your-BigTable-instance-name \
  -keyFilePath ./service-account-key.json \
  -setupDB

Querying BigTable

Lookup a row by the EmitterChain:TxID:

go run . \
  -project wormhole-315720 \
  -instance wormhole-dev \
  -keyFilePath ./bigtable-admin.json \
  -queryRowKey 2:000000000000000000000000e982e462b094850f12af94d21d470e21be9d0e9:6

Lookup all rows with a timestamp >= queryPreviousMinutes ago:

go run . \
  -project wormhole-315720 \
  -instance wormhole-dev \
  -keyFilePath ./bigtable-admin.json \
  -queryPreviousMinutes 120