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

Provide getGuid() method in java workflow SDK #931

Closed
skyao opened this issue Sep 27, 2023 · 1 comment · Fixed by #947
Closed

Provide getGuid() method in java workflow SDK #931

skyao opened this issue Sep 27, 2023 · 1 comment · Fixed by #947
Labels
good first issue Good for newcomers P1 triaged/resolved Items triaged and ready
Milestone

Comments

@skyao
Copy link
Member

skyao commented Sep 27, 2023

Describe the proposal

As required by documentation "Workflow functions must call deterministic APIs"

https://docs.dapr.io/developing-applications/building-blocks/workflow/workflow-features-concepts/#workflow-functions-must-call-deterministic-apis

// DON'T DO THIS!
DateTime currentTime = DateTime.UtcNow;
Guid newIdentifier = Guid.NewGuid();
string randomString = GetRandomString();
DateTime currentTime = context.CurrentUtcDateTime;
Guid newIdentifier = context.NewGuid();
string randomString = await context.CallActivityAsync<string>("GetRandomString");

Now in java workflow SDK, we don't provide such getGuid() method (yeat context.getCurrentInstant() method is provided) .

We need to improve our java workflow sdk to provide this getGuid() method.

And this getGuid() method is NOT provided by durable task java SDK, so we need to update durable task java SDK first.

This improvement should be included in next release.

@skyao
Copy link
Member Author

skyao commented Sep 27, 2023

Reference to the TaskOrchestrationContext class durabletask in dotnet sdk:

https://github.com/microsoft/durabletask-dotnet/blob/main/src/Abstractions/TaskOrchestrationContext.cs

    /// <summary>
    /// Creates a new GUID that is safe for replay within an orchestration or operation.
    /// </summary>
    /// <remarks>
    /// The default implementation of this method creates a name-based UUID V5 using the algorithm from RFC 4122 §4.3.
    /// The name input used to generate this value is a combination of the orchestration instance ID, the current time,
    /// and an internally managed sequence number.
    /// </remarks>
    /// <returns>The new <see cref="Guid"/> value.</returns>
    public abstract Guid NewGuid();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers P1 triaged/resolved Items triaged and ready
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants