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

Setup: add skeleton #2

Merged
merged 7 commits into from
Oct 3, 2023
Merged

Setup: add skeleton #2

merged 7 commits into from
Oct 3, 2023

Conversation

zklgame
Copy link
Collaborator

@zklgame zklgame commented Sep 30, 2023

No description provided.

@zklgame zklgame changed the title Setup Setup: add skeleton Sep 30, 2023
Copy link
Contributor

@longquanzheng longquanzheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great. God job!

README.md Outdated
## 1.0

- [ ] StartProcessExecution API
- [] Basic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: [ ] with a space otherwise it will not look right

/**
* {@link BasicClient} serves as a foundational client without a process {@link io.xdb.core.registry}.
* It represents the internal implementation of the {@link Client}.
* However, it can also be utilized directly if there is a compelling reason, allowing you to invoke APIs on the xdb server with minimal type validation checks, such as process type, queue names, and so forth.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with minimal type validation checks

I think it's no type check actually.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I just copied this descrption from the golang-sdk.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I will fix that

}

public String startProcess(
final String processType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use Process processDefinition to make it more "strongly typing experience".

Copy link
Contributor

@longquanzheng longquanzheng Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry 😢 I forgot this. In Java it’s even better to just use the class type like this https://github.com/indeedeng/iwf-java-sdk/blob/d2ae8439d4b7ed996c20303be57f248eb00fe4ef/src/main/java/io/iworkflow/core/Client.java#L63 override process/workflow type is really rare and they can probably use basic client instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think users will be confused when they define type in the options but pass the class in the startProcess method, and find the customized type is not working.

So let's keep using the definition here to avoid such confusion.

Copy link
Contributor

@longquanzheng longquanzheng Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can provide both the string processType and the Class like iwf-java-sdk.

Or even just not allow customizing processType for now. It's really not useful so far. In our new python SDK, I just don't expose the workflowType customization: https://github.com/indeedeng/iwf-python-sdk/blob/main/iwf/workflow.py#L8 And it's not late to add it later when needed.

On the other side, using Class is much more friendly than using the workflow instance, it save the user code for dependency injection. As a result, I deleted this one in Java SDK recently: indeedeng/iwf-java-sdk#195 (still keep the string WorkflowType)

final FeignException.FeignClientException exception
) {
if (exception.status() >= 400 && exception.status() < 500) {
return new ClientSideException(objectEncoder, exception);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for 400<statusCode<500, can you add some more friendly exceptions (use final exceptions):
404: ProcessNotFoundException
409: ProcessAlreadyStartedException

This is also something that I want to improve in iWF: indeedeng/iwf-java-sdk#203

and we have done the same in Python SDK later: https://github.com/indeedeng/iwf-python-sdk/blob/main/iwf/errors.py

public class BasicClientProcessOptions {

private final Optional<ProcessOptions> processOptionsOptional;
private final AsyncStateConfig startStateConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startStateConfig should also be optional

private final AsyncStateConfig startStateConfig;

public BasicClientProcessOptions(final ProcessOptions processOptions, final AsyncStateConfig startStateConfig) {
if (processOptions == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think it can be just Optional.ofNullable(processOptions)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good learning!

* It represents a fundamental concept at the top level in XDB.
*/
public interface Process {
default String getType() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking to do this for Golang SDK recently --

What do you think that we move the ProcessOptions here so that ProcessOption will include this Type, and others like timeouts, IdReusePolicy?

Because usually those timeout/IdReusePolicy can be determined when implementing the process definition, rather than being specified when starting a process.

Another reasons is that I am hoping to have a more extensible struct to to represent those "optional configuration" for a process definition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea. I am going to implment in this way here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried in Java and found that if moving the type out of Process, we cannot provide the default value as the class.getSimpleName() because now the type is not included in the class def.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do it in the Golang way — use an empty value to represent the default value. When resolving the process type , we can use class name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

*
* @return the state id
*/
default String getId() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then similarly, we can use AsyncStateOptions here to merge it with our future getAsyncStateOptions


public class WorkerService {

private static final String API_PATH_ASYNC_STATE_WAIT_UNTIL = "/api/v1/xdb/worker/async-state/wait-until";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they need to be public so that user code can use


public static ServerApiRetryConfig getDefault() {
return ServerApiRetryConfig
.builder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks like lombok is better/friendly than immutable 👍 I had to manually add those builder helpers myself when using immutable

@zklgame zklgame requested a review from longquanzheng October 2, 2023 00:52
Copy link
Contributor

@longquanzheng longquanzheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some final minor comments

@zklgame zklgame merged commit 40df895 into main Oct 3, 2023
1 check passed
@zklgame zklgame deleted the setup branch October 3, 2023 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants