Skip to content

Commit

Permalink
Break out config values to top of file
Browse files Browse the repository at this point in the history
  • Loading branch information
momander committed Nov 10, 2019
1 parent 83f78c7 commit 009f414
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions async-cloud-tasks/store-service/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// The ID of the project where the queue has been defined.
const PROJECT_ID = '';
// The location of the payment service, like us-central1.
const LOCATION = '';
// Deploy the payment service, capture its URL, and enter it below.
const PAYMENT_SERVICE_URL = 'https://payment-service...';
const QUEUE_NAME = 'payments';

const {v2beta3} = require('@google-cloud/tasks');
const client = new v2beta3.CloudTasksClient();

Expand Down Expand Up @@ -28,7 +36,7 @@ function generateOrderId() {
async function callPaymentService(order) {
const task = {
httpRequest: {
url: 'https://payment-service-weeju7u4zq-uc.a.run.app',
url: PAYMENT_SERVICE_URL,
body: encodePayload(order),
httpMethod: 'POST',
headers: {'content-type': 'application/json'},
Expand All @@ -40,11 +48,8 @@ async function callPaymentService(order) {
seconds: Date.now() / 1000 + 10,
}
};
const project = 'serverless-toolbox';
const location = 'us-west2';
const queue = 'payments';
const request = {
parent: client.queuePath(project, location, queue),
parent: client.queuePath(PROJECT_ID, LOCATION, QUEUE_NAME),
task: task,
};
const [response] = await client.createTask(request);
Expand Down

0 comments on commit 009f414

Please sign in to comment.