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

Run Godspeed workflows without any eventsources #954

Closed
3 tasks done
mastersilv3r opened this issue Feb 11, 2024 · 0 comments
Closed
3 tasks done

Run Godspeed workflows without any eventsources #954

mastersilv3r opened this issue Feb 11, 2024 · 0 comments
Assignees
Labels
current current sprint feature new feature

Comments

@mastersilv3r
Copy link
Contributor

mastersilv3r commented Feb 11, 2024

The Problem

Currently Godspeed project starts as a service only, and depends on some event source like http graphql etc to start. If we want to setup datasources and run some workflows, we can not do it via a command line.

The Solution

Allow a developer to run workflows from a command.
Remove the condition that there must be atleast one eventsource. If no event sources are found, events folder will also be ignored. Rest of the things like config, functions, mappings, datasources will be loaded.

How will we solve

  • When initializing godspeed instance, allow every param to be optional and also pass withoutEventSource as true as second argument to godspeedInstance.initialize()
  • In GodspeedParams, following changes will happen

image

  • Allow developer to call workflows without running any eventsource like this.
import Godspeed, { GodspeedParams, logger, childLogger } from "@godspeedsystems/core";

const params: GodspeedParams = {
    // eventsFolderPath: undefined,
    workflowsFolderPath: 'dist/functions',
    definitionsFolderPath: 'dist/definitions',
    configFolderPath: '/config',
    datasourcesFolderPath: 'dist/datasources',
    // eventsourcesFolderPath: undefined,
    mappingsFolderPath: 'dist/mappings',
    pluginsFolderPath: 'dist/plugins'
  }

// create a godspeed instance without events and eventsources folder paths. Do remember to pass true for initializing without eventsources. Otherwise project will load from default value of eventsource folder. That will be something you do not want for invoking a workflow directly.
const gsApp = new Godspeed(params, true);

// initilize the Godspeed App
// this is responsible to load all kind of entities
gsApp.initialize().then(async () => {
    logger.info('project initialized');
    await execute();
    
})
.catch(console.error)
async function execute() {
    await gsApp.executeWorkflow('model.device.create', {body: {name: 'mastersilv3r'}});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
current current sprint feature new feature
Projects
None yet
Development

No branches or pull requests

2 participants