Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google BigQuery: add quotas #70

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/appmixer/google/bigquery/AddRow/AddRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ async function streamingInsert(context) {
projectId
});

// eslint-disable-next-line no-unused-vars
const [table] = await client.dataset(datasetId).table(tableId).get();

const excludedKeys = [
'projectId',
'datasetId',
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/AddRow/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"name": "appmixer.google.bigquery.AddRow",
"author": "Camilo Manrique <[email protected]>",
"description": "Add a new row inside a BigQuery table.",
"version": "1.0.1",
"version": "1.0.2",
"private": false,
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"auth": {
"service": "appmixer:google",
"scope": [
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/CreateInspector/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
"author": "Camilo Manrique <[email protected]>",
"description": "Create inspector for BigQuery components.",
"private": true,
"version": "1.1.1",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"version": "1.1.2",
"auth": {
"service": "appmixer:google",
"scope": [
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/DeleteRow/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"name": "appmixer.google.bigquery.DeleteRow",
"author": "Camilo Manrique <[email protected]>",
"description": "Removes a row inside a BigQuery table.",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"private": false,
"version": "1.0.3",
"version": "1.0.4",
"auth": {
"service": "appmixer:google",
"scope": [
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/DeletedRow/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"name": "appmixer.google.bigquery.DeletedRow",
"author": "Camilo Manrique <[email protected]>",
"description": "Watch for deleted rows in your BigQuery dataset.",
"version": "1.0.1",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"version": "1.0.2",
"private": false,
"tick": true,
"auth": {
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/GetTable/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"name": "appmixer.google.bigquery.GetTable",
"author": "Camilo Manrique <[email protected]>",
"description": "Gets the specified table resource by table ID.",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"private": true,
"version": "2.0.3",
"version": "2.0.4",
"auth": {
"service": "appmixer:google",
"scope": [
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/ListDatasets/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"name": "appmixer.google.bigquery.ListDatasets",
"author": "Camilo Manrique <[email protected]>",
"description": "List the datasets in a given project.",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"private": true,
"version": "2.0.1",
"version": "2.0.2",
"inPorts": [
{
"name": "in",
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/ListProjects/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"name": "appmixer.google.bigquery.ListProjects",
"author": "Camilo Manrique <[email protected]>",
"description": "List Google Console projects.",
"version": "3.0.0",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "projects.list",
"scope": {
"userId": "{{userId}}"
}
},
"version": "3.0.1",
"private": true,
"inPorts": [
"in"
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/ListTables/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"name": "appmixer.google.bigquery.ListTables",
"author": "Camilo Manrique <[email protected]>",
"description": "List BigQuery tables in the given dataset.",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"private": false,
"version": "2.1.1",
"version": "2.1.2",
"auth": {
"service": "appmixer:google",
"scope": [
Expand Down
11 changes: 9 additions & 2 deletions src/appmixer/google/bigquery/NewRow/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"name": "appmixer.google.bigquery.NewRow",
"author": "Camilo Manrique <[email protected]>",
"description": "Watch for new rows in your BigQuery dataset.",
"version": "1.0.1",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"version": "1.0.2",
"private": false,
"tick": true,
"state": {
Expand All @@ -11,7 +18,7 @@
"auth": {
"service": "appmixer:google",
"scope": [
"https://www.googleapis.com/auth/bigquery.readonly"
"https://www.googleapis.com/auth/bigquery"
]
},
"properties": {
Expand Down
11 changes: 9 additions & 2 deletions src/appmixer/google/bigquery/UpdatedRow/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
"name": "appmixer.google.bigquery.UpdatedRow",
"author": "Camilo Manrique <[email protected]>",
"description": "Watch for row updates in your BigQuery dataset.",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"private": false,
"tick": true,
"version": "1.0.2",
"version": "1.0.3",
"state": {
"persistent": true
},
"auth": {
"service": "appmixer:google",
"scope": [
"https://www.googleapis.com/auth/bigquery.readonly"
"https://www.googleapis.com/auth/bigquery"
]
},
"properties": {
Expand Down
9 changes: 8 additions & 1 deletion src/appmixer/google/bigquery/UpdatedRowOutput/component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"name": "appmixer.google.bigquery.UpdatedRowOutput",
"author": "Camilo Manrique <[email protected]>",
"description": "Output variables for UpdatedRow.",
"version": "1.0.1",
"quota": {
"manager": "appmixer:google:bigquery",
"resources": "requests",
"scope": {
"userId": "{{userId}}"
}
},
"version": "1.0.2",
"private": true,
"auth": {
"service": "appmixer:google",
Expand Down
5 changes: 4 additions & 1 deletion src/appmixer/google/bigquery/bundle.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appmixer.google.bigquery",
"version": "3.0.0",
"version": "3.0.1",
"changelog": {
"1.0.0": [
"Initial version."
Expand All @@ -27,6 +27,9 @@
],
"3.0.0": [
"(breaking) ListProjects: updated endpoint to retrieve project properties. The object returned is not backward compatible. See more here: https://github.com/clientIO/appmixer-connectors/pull/56"
],
"3.0.1": [
"Add quotas for all components."
]
}
}
6 changes: 3 additions & 3 deletions src/appmixer/google/bigquery/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ module.exports.getProjectId = async function(context) {
const [projectNumber] = clientId.split('-');

const authClient = commons.getAuthLibraryOAuth2Client(context.auth);
const res = await authClient.request({ url: 'https://cloudresourcemanager.googleapis.com/v1/projects' });
const res = await authClient.request({ url: 'https://bigquery.googleapis.com/bigquery/v2/projects' });
const { projects } = res.data;

const project = projects.find(project => project.projectNumber === projectNumber);
return project.projectId;
const project = projects.find(project => project.numericId === projectNumber);
return project.id;
};

module.exports.getInterval = function(context) {
Expand Down
6 changes: 3 additions & 3 deletions src/appmixer/google/bigquery/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "appmixer.google.bigquery",
"version": "0.0.1",
"version": "0.0.2",
"dependencies": {
"@google-cloud/bigquery": "^6.0.1",
"googleapis": "^105.0.0"
"@google-cloud/bigquery": "6.2.1",
"googleapis": "105.0.0"
}
}
24 changes: 24 additions & 0 deletions src/appmixer/google/bigquery/quota.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

module.exports = {

rules: [
// https://cloud.google.com/bigquery/quotas#api_quotas_and_limits
// A user can make up to 100 API requests per second to an API method.
// If a user makes more than 100 requests per second to a method, then throttling can occur.
{
limit: 100,
window: 1000,
scope: 'userId',
resource: 'requests'
},
// Official docs: Your project can make up to two projects.list requests per second.
// Tested out: 10 requests per second always fine.
{
limit: 10,
window: 1000,
scope: 'userId',
resource: 'projects.list'
}
]
};
Loading