-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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
There was a problem hiding this 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
No description provided.