Google Cloud Extension (Early Access)
The GCP extension provides Action Handlers to write to Google Cloud Storage and BigQuery Tables.
Setup
In order to use Action Handlers provided by this extension, add the following dependency in your pom.xml:
Replace {GRAINITE-VERSION}
with the version of Grainite you are also using for libgrainite (the Grainite Client library for Java).
Contents
The GCP extension includes:
StorageWriterHandler
: Handler that uploads the provided JSON list into a Google Cloud Storage bucket.BigQueryWriterHandler
: Handler that uploads a JSON blob from Google Cloud Storage to a BigQuery table.
Common Required Configuration Options
Both the handlers require the following configuration options:
Property | Value | Description |
---|---|---|
| Example: | Credentials for the service account that will be used by the Action Handlers. |
| Example: | Project ID of the GCP project - https://support.google.com/googleapi/answer/7014113?hl=en |
Creating Service Account credentials and storing them in Grainite
To create the service account credentials, follow these instructions: link. Alternatively, you can use the gcloud
CLI to generate the JSON credentials file:
Where:
/path/to/key-file.json
is where you would like to store the JSON credentials file.<service-account-email>
is the service account for which you wish to generate credentials.
StorageWriterHandler
This handler takes a list of JSON blobs and uploads them to the configured bucket in Google Cloud Storage. The blob name format is as follows: <optional_prefix>:<time_millis>
. The <optional_prefix> (blob.name.prefix
) is not mandatory, and <time_millis> represents the time, in milliseconds, when the handler uploaded the blob.
The handler uploads blobs in batches for efficiency. The handler accumulates events until one of the following happens:
The max batch size (
upload.batch_size
) is reached.The max upload size (
upload.payload_size
) is reached.There are remaining events in the Grain state, when the timer fires (
upload.timer
).
The handler can be optionally configured to send notifications for successful blob uploads by appending events (where the payload is the blob URI) to a Grainite Topic.
Usage
To include this handler in your application, you must specify the following in your application's configuration YAML file:
Below are the configuration options that can be passed in under config
:
Property | Required? | Value | Description |
---|---|---|---|
| REQUIRED | - | |
| REQUIRED | - | |
| REQUIRED | Example: | Bucket name where the blobs will be uploaded. |
| Optional |
| Prints some additional debugging information when |
| Optional | Example: | A prefix to add to each blob name. |
| Optional | Example: | The topic to which an event should be appended upon successful blob uploads. |
| Optional | Example: | The maximum number of events to accumulate, before uploading them to the bucket. |
| Optional | Example: | The maximum size (in bytes) to accumulate, before uploading the events to the bucket. |
| Optional | Example: | Time in seconds in which to check for pending uploads. |
BigQueryWriterHandler
This handler takes a gcs blob URI for a JSON, and uploads it's contents into a BigQuery dataset table.
Note that the limitations from the following URL apply to this handler - https://cloud.google.com/bigquery/docs/loading-data-cloud-storage-json.
Usage
To include this handler in your application, you must specify the following in your application's configuration YAML file:
Below are the configuration options that can be passed in under config
:
Property | Required? | Value | Description |
---|---|---|---|
| REQUIRED | - | |
| REQUIRED | - | |
| REQUIRED | Example: | Dataset name of the table. |
| REQUIRED | Example: | Name of the table to which the rows will be added. |
| Optional |
| Prints some additional debugging information when |
Google Cloud Storage and BigQuery are trademarks of Google LLC.
Last updated