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

Implement workflow versioning and keep the existing instance upon import #15496

Open
hyzx86 opened this issue Mar 13, 2024 · 3 comments · May be fixed by #16043
Open

Implement workflow versioning and keep the existing instance upon import #15496

hyzx86 opened this issue Mar 13, 2024 · 3 comments · May be fixed by #16043

Comments

@hyzx86
Copy link
Contributor

hyzx86 commented Mar 13, 2024

Is your feature request related to a problem? Please describe.

At present, the imported workflow type always cleans up the workflow instances of the process.

In some cases, we want to keep them, otherwise the process in progress will be cleaned up.

Describe the solution you'd like

There was a note in the source code before, which gave the scheme. We should implement the workflow version.

Describe alternatives you've considered

No

@hyzx86 hyzx86 changed the title Implement the workflow version and keep the instance in progress. Implement the workflow version and keep the exsist instances Mar 13, 2024
@sebastienros
Copy link
Member

I assume this is cleaned up because the instances might be in a state that is incompatible with the new definition? Can you link to the code that is doing it?

An option could be to have a flag in the workflow definition step to not clean the instances.

@sebastienros sebastienros added this to the 1.x milestone Mar 14, 2024
@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 14, 2024

Yes, here , at line 77.

var model = context.Step.ToObject<WorkflowStepModel>();
var urlHelper = GetUrlHelper();
foreach (var token in model.Data.Cast<JsonObject>())
{
var workflow = token.ToObject<WorkflowType>(_jsonSerializerOptions);
var existing = await _workflowTypeStore.GetAsync(workflow.WorkflowTypeId);
if (existing is null)
{
workflow.Id = 0;
if (urlHelper is not null)
{
foreach (var activity in workflow.Activities.Where(a => a.Name == nameof(HttpRequestEvent)))
{
if (!activity.Properties.TryGetPropertyValue("TokenLifeSpan", out var tokenLifeSpan))
{
continue;
}
activity.Properties["Url"] = ReGenerateHttpRequestEventUrl(urlHelper, workflow, activity, tokenLifeSpan.ToObject<int>());
}
}
}
else
{
await _workflowTypeStore.DeleteAsync(existing);
}
await _workflowTypeStore.SaveAsync(workflow);

@hyzx86
Copy link
Contributor Author

hyzx86 commented Mar 14, 2024

And here

public async Task DeleteAsync(WorkflowType workflowType)
{
// Delete workflows first.
var workflows = await _session.Query<Workflow, WorkflowIndex>(x => x.WorkflowTypeId == workflowType.WorkflowTypeId).ListAsync();
foreach (var workflow in workflows)
{
_session.Delete(workflow);
}
// Then delete the workflow type.
_session.Delete(workflowType);
var context = new WorkflowTypeDeletedContext(workflowType);
await _handlers.InvokeAsync((handler, context) => handler.DeletedAsync(context), context, _logger);

@hyzx86 hyzx86 linked a pull request May 13, 2024 that will close this issue
10 tasks
@Piedone Piedone changed the title Implement the workflow version and keep the exsist instances Implement workflow versioning and keep the existing instance upon import May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants