Comments (7)
Thanks for the reply @grant ,
Apologies for not getting back to you, this one seems to have passed me by.
Appreciate the confirmation, although I think this means Workflow is unlikely to be of much use directly for our desired use case right now.
I didn’t go into detail before, but basically data is written to Pub/Sub and picked up by App Engine for writing to BigQuery.
It felt like a great PoC would have been to bridge this gap from Pub/Sub to BigQuery with a workflow, but if App Engine, Run or Functions would still need to sit in the middle, it’s just adding extra complexity rather than removing it, which is a shame.
Are direct calls from Pub/Sub something you think we may see in the future?
from workflows-samples.
Hi, thanks for the use-case. Maybe this comment also helps.
Right now you'll need Pub/Sub -> Compute (like Functions/Run) -> Workflow
We have a new product Eventarc (http://cloud.google.com/eventarc) that manages event triggers, and can avoid a compute step, but it only supports Cloud Run targets. It's very new (went GA last month) but we only accept 2 inputs (Audit Logs, Pub/Sub) and 1 output (Run) currently. Maybe Workflows could be a target in the future. Then you just need to create the trigger without any compute in the middle.
If you file a feature request in the issue tracker (workflows issue), that helps us track this request:
https://cloud.google.com/workflows/docs/getting-support
I think that waiting for the workflow to be finished is a waste of resources and therefore money.
Oh, to not wait for the workflow to be finished, just return and don't sleep/poll for the status.
await executionClient.createExecution({
parent: executionClient.workflowPath(projectId, location, workflow),
});
Any thoughts on how to implement an idempotent pubsub trigger for workflows which can be retried on failure?
I'm not sure this helps, a Pub/Sub push subscription will use it's retry policy in case of failure, using the response code.
Are direct calls from Pub/Sub something you think we may see in the future?
Eventarc is the Google Cloud event trigger product, so I can imagine a Workflow event sink in the future. Please link the public issue here if you create one using the link above!
from workflows-samples.
@grant thank you. I just want to add here a link to your great article making clear the "Compute (like Functions/Run) -> Workflow" part. https://medium.com/google-cloud/call-a-workflow-from-a-function-51fc7fc8e1ff
Also there are already two similar feature requests in the Google's task tracker:
- Pub/Sub trigger https://issuetracker.google.com/issues/175903554
- Make Workflows accept and parse messages from Pub / Sub #integrations #push-format
https://issuetracker.google.com/issues/175019114
from workflows-samples.
Hey @iamacarpet, I don't think you can directly execute a workflow from a Pub/Sub subscription with GCP right now. I think you'll need to add a compute step (Functions or Run) that executes the workflow.
Here's a little code in Node that might help (we're working on improving the docs and samples), maybe adapt it and put it in a Cloud Function:
const projectId = 'my-project';
const location = 'us-central1';
const workflow = 'quickstart';
const {ExecutionsClient} = require('@google-cloud/workflows');
const executionClient = new ExecutionsClient();
async function runWorkflow() {
// Execute workflow
const createExecutionRes = await executionClient.createExecution({
parent: executionClient.workflowPath(projectId, location, workflow),
});
console.log(`Created execution: ${createExecutionRes[0].name}`);
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
// Wait for execution to finish and print results:
// TODO: poll for result
await sleep(5000);
const executionName = createExecutionRes[0].name;
const execution = await executionClient.getExecution({
name: executionName,
});
console.log(execution[0].result);
}
runWorkflow();
Hope that helps.
from workflows-samples.
Again, hope that helps. If there are further questions, feel free to comment. Thanks.
from workflows-samples.
Either have this question. Thought I can simplify the data processing pipelines with workflows but now I see there is no PubSub trigger for them.
Thanks for sharing the workaround. I think that waiting for the workflow to be finished is a waste of resources and therefore money. Any thoughts on how to implement an idempotent pubsub trigger for workflows which can be retried on failure?
from workflows-samples.
Workflows can now be triggered with Pub/Sub messages via Eventarc.
from workflows-samples.
Related Issues (20)
- Workflow sample for BigQuery does not paginate through results HOT 1
- Clean up Parallel steps samples
- Samples for secret manager not working HOT 2
- A Sheets Connector sample to show how to update an existing spreadsheet HOT 1
- Sample code for BigQuery pagination fails execution if query limit is removed HOT 3
- update schema to include `for` property HOT 1
- update schema to include `parallel` property HOT 1
- additionalProperty error for samples using `try`
- `args` must not have additional properties HOT 1
- expressions not allowed for array types HOT 1
- Sample Request - working with text functions HOT 2
- Suggestion for organizing the a lot of LOC yaml file HOT 2
- Wrong params on connector_dataflow YAML & JSON sample codes
- Remove non-inclusive language
- datetime 404
- Add a sample for googleapis.bigquery.v2.jobs.query and queryParameters use case HOT 1
- Dependency Dashboard
- [Policy Bot] found one or more issues with this repository.
- syntax error in connect_firestore_read
- Documentation example fails due to Null value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workflows-samples.