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

fix(*): validate stateExecTimeout iso8601 #76

Merged
merged 1 commit into from
Sep 23, 2022
Merged

fix(*): validate stateExecTimeout iso8601 #76

merged 1 commit into from
Sep 23, 2022

Conversation

lsytj0413
Copy link
Collaborator

Signed-off-by: lsytj0413 511121939@qq.com

Many thanks for submitting your Pull Request ❤️!

What this PR does / why we need it:

  • add validator for sleep state field
  • refactor StateExecTimeout unmarshal function

Special notes for reviewers:

Additional information (if needed):

@ricardozanini ricardozanini removed the request for review from tsurdilo September 19, 2022 15:23
model/state_exec_timeout.go Show resolved Hide resolved
model/state_exec_timeout.go Show resolved Hide resolved
model/state_exec_timeout.go Outdated Show resolved Hide resolved
@ricardozanini
Copy link
Member

@lsytj0413 see here: https://github.com/lsytj0413/swf-sdk-go/pull/1

I'm still failing to understand when the recursion occurs.

@lsytj0413
Copy link
Collaborator Author

lsytj0413#1

unmarshalJSON1 is previous version implement, and i think unmarshalJSON2(secondary version implement) is more concise:

  1. it only call Unmarshal once, the previous version implement may call Unmarshal 2/3 times
  2. it independent of the field number in struct, the previous version implement may call unmarshal for every field.(take a look at OAuth2AuthProperties.UnmarshalJson,it have a huge number of unmarshalKey)

@lsytj0413
Copy link
Collaborator Author

I'm still failing to understand when the recursion occurs.

the recursion occurs when:

  1. timeout is an object, and we use unmarshalJSON2 implement
  2. first byts is '{', we detect data is object, and call json.Unmarshal(data, s)
  3. because object s(it's type is *StateExecTimeout) implement json.Unmarshaler interface, so the unmarshalJSON2 recursion called by json.Unmarshal function
  4. go to step 2

so we must use another type which didn't implement json.Unmarshaler interface for step 2.

@ricardozanini
Copy link
Member

send me a workflow to include in the unit test, please.

@lsytj0413
Copy link
Collaborator Author

send me a workflow to include in the unit test, please.

I have change PR to secondary implement with all unit test.
PTAL

@ricardozanini
Copy link
Member

Looking good!

Signed-off-by: lsytj0413 <511121939@qq.com>
@ricardozanini ricardozanini merged commit e72f6db into serverlessworkflow:main Sep 23, 2022
@lsytj0413 lsytj0413 deleted the split-sleep-state branch September 25, 2022 14:11
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.

None yet

2 participants