Skip to content

Feature: finish implementation for StateMachineConfig #805

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

Open
wants to merge 19 commits into
base: feature/saga
Choose a base branch
from

Conversation

flypiggyyoyoyo
Copy link

What this PR does:

  • Interface & Default Config: Defined StateMachineConfig and implemented DefaultStateMachineConfig with runtime defaults and dynamic JSON/YAML loading.
  • Non - code Support: Added LoadConfig for state machine definition parsing, with duplicate checks and in - memory storage.
  • Expression & Invoker: Implemented EL expressions, sequence ID generation, and ServiceInvoker with LocalServiceInvoker.
  • Concurrency & Dependency: Used sync for thread - safety and enabled component injection.
  • Testing: Added unit tests for core functions and edge cases.

Which issue(s) this PR fixes:

Fixes #792

Special notes for your reviewer: The implementation references the Java version but uses Go idioms without Spring dependencies.

Does this PR introduce a user-facing change?:


)

type JsonParser interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why must we use a structure to parse JSON here?

Copy link
Author

Choose a reason for hiding this comment

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

Parameters need to be serialized and deserialized, so a parser was introduced. Method invocation is decoupled from its concrete implementation by defining an interface and a struct, ensuring maintainable and extensible code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that what’s needed here is just a Parser interface. Based on the abstraction of the parser, there can be different serialization formats, such as JSON, Protobuf, etc. However, since currently only the JSON format is used, this abstraction might not be necessary.

我理解这里需要的是一个Parser的 interface即可。基于parser的抽象,有不同的序列化方式,比如json,pb等。但是目前只有json的格式,所以这个抽象也许用不到

func NewDefaultStateMachineConfig() *DefaultStateMachineConfig {

// TODO: Initialize the statemachine_repository, following the implementation of the Java version.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we initialize this part at present? Is it because statemachine_repository has not been fully implemented yet? What is missing?

Copy link
Author

Choose a reason for hiding this comment

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

Apologies for the oversight. Initially, I was unsure whether this implementation was required. However, after re-reviewing the codebase from the perspective of aligning versions, I realized it is necessary. This was my mistake, and I will correct it immediately. Thank you for your understanding.

@flypiggyyoyoyo
Copy link
Author

Compatibility issues arose after merging the new expression version. I'm working on fixing them now.

@flypiggyyoyoyo
Copy link
Author

Sorry for the delayed progress – I'm limited by time and capacity at the moment. I'll keep refining and adding to this PR. Thanks for your understanding!

}

func (e *ErrorExpression) SetValue(value any, elContext any) {
//错误表达式不设置值
Copy link
Contributor

Choose a reason for hiding this comment

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

Why hasn’t this been implemented here? Why hasn’t this been implemented here?

Copy link
Author

Choose a reason for hiding this comment

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

Because an ErrorExpression represents a parsing failure and has no valid value to store, its SetValue method is intentionally left empty.

Copy link
Author

Choose a reason for hiding this comment

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

I originally coupled ErrorExpression with DefaultStateMachineConfig, but I’ve now moved it to the expr package and decoupled it.

)

type JsonParser interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that what’s needed here is just a Parser interface. Based on the abstraction of the parser, there can be different serialization formats, such as JSON, Protobuf, etc. However, since currently only the JSON format is used, this abstraction might not be necessary.

我理解这里需要的是一个Parser的 interface即可。基于parser的抽象,有不同的序列化方式,比如json,pb等。但是目前只有json的格式,所以这个抽象也许用不到

Copy link
Contributor

@Code-Fight Code-Fight left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@xjlgod xjlgod left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants