From 3b98ffdcd3bbacee16bff0ce019909edd3002c1f Mon Sep 17 00:00:00 2001 From: FinnTew Date: Sun, 15 Dec 2024 14:25:06 +0800 Subject: [PATCH 01/11] added yaml format of statelang related test data --- .../simple_statelang_with_choice.yaml | 26 ++ .../saga/statelang/simple_statemachine.yaml | 90 ++++++ .../statelang/state_machine_new_designer.yaml | 278 ++++++++++++++++++ 3 files changed, 394 insertions(+) create mode 100644 testdata/saga/statelang/simple_statelang_with_choice.yaml create mode 100644 testdata/saga/statelang/simple_statemachine.yaml create mode 100644 testdata/saga/statelang/state_machine_new_designer.yaml diff --git a/testdata/saga/statelang/simple_statelang_with_choice.yaml b/testdata/saga/statelang/simple_statelang_with_choice.yaml new file mode 100644 index 000000000..32fa403fa --- /dev/null +++ b/testdata/saga/statelang/simple_statelang_with_choice.yaml @@ -0,0 +1,26 @@ +Name: simpleChoiceTestStateMachine +Comment: 带条件分支的测试状态机定义 +StartState: FirstState +Version: 0.0.1 +States: + FirstState: + Type: ServiceTask + ServiceName: demoService + ServiceMethod: foo + Next: ChoiceState + ChoiceState: + Type: Choice + Choices: + - Expression: "[a] == 1" + Next: SecondState + - Expression: "[a] == 2" + Next: ThirdState + Default: SecondState + SecondState: + Type: ServiceTask + ServiceName: demoService + ServiceMethod: bar + ThirdState: + Type: ServiceTask + ServiceName: demoService + ServiceMethod: foo \ No newline at end of file diff --git a/testdata/saga/statelang/simple_statemachine.yaml b/testdata/saga/statelang/simple_statemachine.yaml new file mode 100644 index 000000000..a5da6c03d --- /dev/null +++ b/testdata/saga/statelang/simple_statemachine.yaml @@ -0,0 +1,90 @@ +Name: simpleTestStateMachine +Comment: 测试状态机定义 +StartState: FirstState +Version: 0.0.1 +States: + FirstState: + Type: ServiceTask + ServiceName: is.seata.saga.DemoService + ServiceMethod: foo + IsPersist: false + Next: ScriptState + ScriptState: + Type: ScriptTask + ScriptType: groovy + ScriptContent: return 'hello ' + inputA + Input: + - inputA: $.data1 + Output: + scriptStateResult: '$.#root' + Next: ChoiceState + ChoiceState: + Type: Choice + Choices: + - Expression: foo == 1 + Next: FirstMatchState + - Expression: foo == 2 + Next: SecondMatchState + Default: FailState + FirstMatchState: + Type: ServiceTask + ServiceName: is.seata.saga.DemoService + ServiceMethod: bar + CompensateState: CompensateFirst + Status: + return.code == 'S': SU + return.code == 'F': FA + '$exception{java.lang.Throwable}': UN + Input: + - inputA1: $.data1 + inputA2: + a: $.data2.a + - inputB: $.header + Output: + firstMatchStateResult: '$.#root' + Retry: + - Exceptions: [java.lang.Exception] + IntervalSeconds: 2 + MaxAttempts: 3 + BackoffRate: 1.5 + Catch: + - Exceptions: + - java.lang.Exception + Next: CompensationTrigger + Next: SuccessState + CompensateFirst: + Type: ServiceTask + ServiceName: is.seata.saga.DemoService + ServiceMethod: compensateBar + IsForCompensation: true + IsForUpdate: true + Input: + - input: $.data + Output: + firstMatchStateResult: '$.#root' + Status: + return.code == 'S': SU + return.code == 'F': FA + '$exception{java.lang.Throwable}': UN + CompensationTrigger: + Type: CompensationTrigger + Next: CompensateEndState + CompensateEndState: + Type: Fail + ErrorCode: StateCompensated + Message: State Compensated! + SecondMatchState: + Type: SubStateMachine + StateMachineName: simpleTestSubStateMachine + Input: + - input: $.data + - header: $.header + Output: + firstMatchStateResult: '$.#root' + Next: SuccessState + FailState: + Type: Fail + ErrorCode: DefaultStateError + Message: No Matches! + SuccessState: + Type: Succeed diff --git a/testdata/saga/statelang/state_machine_new_designer.yaml b/testdata/saga/statelang/state_machine_new_designer.yaml new file mode 100644 index 000000000..6891797eb --- /dev/null +++ b/testdata/saga/statelang/state_machine_new_designer.yaml @@ -0,0 +1,278 @@ +Name: StateMachineNewDesigner +Comment: This state machine is modeled by designer tools. +Version: 0.0.1 +style: + bounds: + x: 200 + y: 200 + width: 36 + height: 36 +States: + ServiceTask-a9h2o51: + style: + bounds: + x: 300 + y: 178 + width: 100 + height: 80 + Name: ServiceTask-a9h2o51 + IsForCompensation: false + Input: + - {} + Output: {} + Status: {} + Retry: [] + ServiceName: "" + ServiceMethod: "" + Type: ServiceTask + Next: Choice-4ajl8nt + edge: + Choice-4ajl8nt: + style: + waypoints: + - original: + x: 400 + y: 218 + x: 400 + y: 218 + - x: 435 + y: 218 + - original: + x: 455 + y: 218 + x: 455 + y: 218 + Type: Transition + CompensateState: CompensateFirstState + Choice-4ajl8nt: + style: + bounds: + x: 455 + y: 193 + width: 50 + height: 50 + Name: Choice-4ajl8nt + Type: Choice + Choices: + - Expression: "" + Next: SubStateMachine-cauj9uy + - Expression: "" + Next: ServiceTask-vdij28l + Default: SubStateMachine-cauj9uy + edge: + SubStateMachine-cauj9uy: + style: + waypoints: + - original: + x: 505 + y: 218 + x: 505 + y: 218 + - x: 530 + y: 218 + - original: + x: 550 + y: 218 + x: 550 + y: 218 + Type: ChoiceEntry + ServiceTask-vdij28l: + style: + waypoints: + - original: + x: 480 + y: 243 + x: 480 + y: 243 + - x: 600 + y: 290 + - original: + x: 600 + y: 310 + x: 600 + y: 310 + Type: ChoiceEntry + CompensateFirstState: + style: + bounds: + x: 300 + y: 310 + width: 100 + height: 80 + Name: CompensateFirstState + IsForCompensation: true + Input: + - {} + Output: {} + Status: {} + Retry: [] + ServiceName: "" + ServiceMethod: "" + Type: ServiceTask + SubStateMachine-cauj9uy: + style: + bounds: + x: 550 + y: 178 + width: 100 + height: 80 + Name: SubStateMachine-cauj9uy + IsForCompensation: false + Input: + - {} + Output: {} + Status: {} + Retry: [] + StateMachineName: "" + Type: SubStateMachine + Next: Succeed-5x3z98u + edge: + Succeed-5x3z98u: + style: + waypoints: + - original: + x: 650 + y: 218 + x: 650 + y: 218 + - x: 702 + y: 218 + - original: + x: 722 + y: 218 + x: 722 + y: 218 + Type: Transition + ServiceTask-vdij28l: + style: + bounds: + x: 550 + y: 310 + width: 100 + height: 80 + Name: ServiceTask-vdij28l + IsForCompensation: false + Input: + - {} + Output: {} + Status: {} + Retry: [] + ServiceName: "" + ServiceMethod: "" + Catch: + - Exceptions: [] + Next: CompensationTrigger-uldp2ou + Type: ServiceTask + catch: + style: + bounds: + x: 632 + y: 372 + width: 36 + height: 36 + edge: + CompensationTrigger-uldp2ou: + style: + waypoints: + - original: + x: 668 + y: 390 + x: 668 + y: 390 + - x: 702 + y: 390 + - original: + x: 722 + y: 390 + x: 722 + y: 390 + source: ServiceTask-vdij28l + target: CompensationTrigger-uldp2ou + Type: ExceptionMatch + Next: Succeed-5x3z98u + edge: + Succeed-5x3z98u: + style: + waypoints: + - original: + x: 600 + y: 310 + x: 600 + y: 310 + - x: 740 + y: 256 + - original: + x: 740 + y: 236 + x: 740 + y: 236 + source: ServiceTask-vdij28l + target: Succeed-5x3z98u + Type: Transition + Succeed-5x3z98u: + style: + bounds: + x: 722 + y: 200 + width: 36 + height: 36 + Name: Succeed-5x3z98u + Type: Succeed + CompensationTrigger-uldp2ou: + style: + bounds: + x: 722 + y: 372 + width: 36 + height: 36 + Name: CompensationTrigger-uldp2ou + Type: CompensationTrigger + Next: Fail-9roxcv5 + edge: + Fail-9roxcv5: + style: + waypoints: + - original: + x: 758 + y: 390 + x: 758 + y: 390 + - x: 792 + y: 390 + - original: + x: 812 + y: 390 + x: 812 + y: 390 + source: CompensationTrigger-uldp2ou + target: Fail-9roxcv5 + Type: Transition + Fail-9roxcv5: + style: + bounds: + x: 812 + y: 372 + width: 36 + height: 36 + Name: Fail-9roxcv5 + ErrorCode: "" + Message: "" + Type: Fail +StartState: ServiceTask-a9h2o51 +edge: + style: + waypoints: + - original: + x: 236 + y: 218 + x: 236 + y: 218 + - x: 280 + y: 218 + - original: + x: 300 + y: 218 + x: 300 + y: 218 + target: ServiceTask-a9h2o51 + Type: Transition \ No newline at end of file From 9801d4b23ea68683fe9e1ef9226b469021324fad Mon Sep 17 00:00:00 2001 From: FinnTew Date: Sun, 15 Dec 2024 14:46:57 +0800 Subject: [PATCH 02/11] feature: implement multi type config parser --- .../parser/statemachine_config_parser.go | 127 ++++++++++++++++++ .../parser/statemachine_config_parser_test.go | 46 +++++++ 2 files changed, 173 insertions(+) create mode 100644 pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go create mode 100644 pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go new file mode 100644 index 000000000..2c87beb18 --- /dev/null +++ b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go @@ -0,0 +1,127 @@ +package parser + +import ( + "bytes" + "encoding/json" + "fmt" + "gopkg.in/yaml.v3" + "io" + "os" + "path/filepath" +) + +type ConfigParser interface { + Parse(configContent []byte) (*StateMachineObject, error) +} + +type StateMachineConfigParser struct{} + +func NewStateMachineConfigParser() *StateMachineConfigParser { + return &StateMachineConfigParser{} +} + +func (p *StateMachineConfigParser) checkConfigFile(configFilePath string) error { + if _, err := os.Stat(configFilePath); err != nil { + if os.IsNotExist(err) { + return fmt.Errorf("config file %s does not exist: %w", configFilePath, err) + } + return fmt.Errorf("failed to access config file %s: %w", configFilePath, err) + } + return nil +} + +func (p *StateMachineConfigParser) readFile(configFilePath string) ([]byte, error) { + file, _ := os.Open(configFilePath) + defer func(file *os.File) { + _ = file.Close() + }(file) + + var buf bytes.Buffer + _, err := io.Copy(&buf, file) + if err != nil { + return nil, fmt.Errorf("failed to read config file %s: %w", configFilePath, err) + } + + return buf.Bytes(), nil +} + +func (p *StateMachineConfigParser) getParser(configFilePath string) (ConfigParser, error) { + fileExt := filepath.Ext(configFilePath) + switch fileExt { + case ".json": + return NewJSONConfigParser(), nil + case ".yaml", ".yml": + return NewYAMLConfigParser(), nil + default: + return nil, fmt.Errorf("unsupported config file format: %s", fileExt) + } +} + +func (p *StateMachineConfigParser) Parse(configFilePath string) (*StateMachineObject, error) { + if err := p.checkConfigFile(configFilePath); err != nil { + return nil, err + } + + configContent, err := p.readFile(configFilePath) + if err != nil { + return nil, err + } + + parser, err := p.getParser(configFilePath) + if err != nil { + return nil, err + } + + return parser.Parse(configContent) +} + +type JSONConfigParser struct{} + +func NewJSONConfigParser() *JSONConfigParser { + return &JSONConfigParser{} +} + +func (p *JSONConfigParser) Parse(configContent []byte) (*StateMachineObject, error) { + if configContent == nil || len(configContent) == 0 { + return nil, fmt.Errorf("empty JSON config content") + } + + var stateMachineObject StateMachineObject + if err := json.Unmarshal(configContent, &stateMachineObject); err != nil { + return nil, fmt.Errorf("failed to parse JSON config content: %w", err) + } + + return &stateMachineObject, nil +} + +type YAMLConfigParser struct{} + +func NewYAMLConfigParser() *YAMLConfigParser { + return &YAMLConfigParser{} +} + +func (p *YAMLConfigParser) Parse(configContent []byte) (*StateMachineObject, error) { + if configContent == nil || len(configContent) == 0 { + return nil, fmt.Errorf("empty YAML config content") + } + + var stateMachineObject StateMachineObject + if err := yaml.Unmarshal(configContent, &stateMachineObject); err != nil { + return nil, fmt.Errorf("failed to parse YAML config content: %w", err) + } + + return &stateMachineObject, nil +} + +type StateMachineObject struct { + Name string `json:"Name" yaml:"Name"` + Comment string `json:"Comment" yaml:"Comment"` + Version string `json:"Version" yaml:"Version"` + StartState string `json:"StartState" yaml:"StartState"` + RecoverStrategy string `json:"RecoverStrategy" yaml:"RecoverStrategy"` + Persist bool `json:"IsPersist" yaml:"IsPersist"` + RetryPersistModeUpdate bool `json:"IsRetryPersistModeUpdate" yaml:"IsRetryPersistModeUpdate"` + CompensatePersistModeUpdate bool `json:"IsCompensatePersistModeUpdate" yaml:"IsCompensatePersistModeUpdate"` + Type string `json:"Type" yaml:"Type"` + States map[string]interface{} `json:"States" yaml:"States"` +} diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go new file mode 100644 index 000000000..c8b38a5b4 --- /dev/null +++ b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go @@ -0,0 +1,46 @@ +package parser + +import "testing" + +func TestStateMachineConfigParser_Parse(t *testing.T) { + parser := NewStateMachineConfigParser() + + tests := []struct { + name string + configFilePath string + }{ + { + name: "JSON Simple 1", + configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.json", + }, + { + name: "JSON Simple 2", + configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.json", + }, + { + name: "JSON Simple 3", + configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.json", + }, + { + name: "YAML Simple 1", + configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.yaml", + }, + { + name: "YAML Simple 2", + configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.yaml", + }, + { + name: "YAML Simple 3", + configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.yaml", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := parser.Parse(tt.configFilePath) + if err != nil { + t.Error("parse fail: " + err.Error()) + } + }) + } +} From 2115edbfa0cfdbd76ee5cd601c50e17c19e7dde9 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Sun, 15 Dec 2024 14:52:28 +0800 Subject: [PATCH 03/11] adjust statemachine_json_parser to suit config parser --- .../parser/statemachine_json_parser.go | 20 +--- .../parser/statemachine_json_parser_test.go | 91 ++++++++++++++----- 2 files changed, 68 insertions(+), 43 deletions(-) diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go index 4bcfdcbc6..9c9bcc5c8 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go @@ -1,7 +1,6 @@ package parser import ( - "encoding/json" "github.com/pkg/errors" "github.com/seata/seata-go/pkg/saga/statemachine/constant" "github.com/seata/seata-go/pkg/saga/statemachine/statelang" @@ -22,10 +21,8 @@ func (stateMachineParser JSONStateMachineParser) GetType() string { return "JSON" } -func (stateMachineParser JSONStateMachineParser) Parse(content string) (statelang.StateMachine, error) { - var stateMachineJsonObject StateMachineJsonObject - - err := json.Unmarshal([]byte(content), &stateMachineJsonObject) +func (stateMachineParser JSONStateMachineParser) Parse(configFilePath string) (statelang.StateMachine, error) { + stateMachineJsonObject, err := NewStateMachineConfigParser().Parse(configFilePath) if err != nil { return nil, err } @@ -115,16 +112,3 @@ func (stateMachineParser JSONStateMachineParser) isTaskState(stateType string) b } return false } - -type StateMachineJsonObject struct { - Name string `json:"Name"` - Comment string `json:"Comment"` - Version string `json:"Version"` - StartState string `json:"StartState"` - RecoverStrategy string `json:"RecoverStrategy"` - Persist bool `json:"IsPersist"` - RetryPersistModeUpdate bool `json:"IsRetryPersistModeUpdate"` - CompensatePersistModeUpdate bool `json:"IsCompensatePersistModeUpdate"` - Type string `json:"Type"` - States map[string]interface{} `json:"States"` -} diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go index 0028309ab..f2736da8d 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go @@ -1,45 +1,86 @@ package parser import ( - "os" "testing" ) func TestParseChoice(t *testing.T) { - filePath := "../../../../../testdata/saga/statelang/simple_statelang_with_choice.json" - fileContent, err := os.ReadFile(filePath) - if err != nil { - t.Error("parse fail: " + err.Error()) - return + parser := NewJSONStateMachineParser() + + tests := []struct { + name string + configFilePath string + }{ + { + name: "JSON Simple: StateLang With Choice", + configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.json", + }, + { + name: "YAML Simple: StateLang With Choice", + configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.yaml", + }, } - _, err = NewJSONStateMachineParser().Parse(string(fileContent)) - if err != nil { - t.Error("parse fail: " + err.Error()) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := parser.Parse(tt.configFilePath) + if err != nil { + t.Error("parse fail: " + err.Error()) + } + }) } } func TestParseServiceTaskForSimpleStateMachine(t *testing.T) { - filePath := "../../../../../testdata/saga/statelang/simple_statemachine.json" - fileContent, err := os.ReadFile(filePath) - if err != nil { - t.Error("parse fail: " + err.Error()) - return + parser := NewJSONStateMachineParser() + + tests := []struct { + name string + configFilePath string + }{ + { + name: "JSON Simple: StateMachine", + configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.json", + }, + { + name: "YAML Simple: StateMachine", + configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.yaml", + }, } - _, err = NewJSONStateMachineParser().Parse(string(fileContent)) - if err != nil { - t.Error("parse fail: " + err.Error()) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := parser.Parse(tt.configFilePath) + if err != nil { + t.Error("parse fail: " + err.Error()) + } + }) } } func TestParseServiceTaskForNewDesigner(t *testing.T) { - filePath := "../../../../../testdata/saga/statelang/state_machine_new_designer.json" - fileContent, err := os.ReadFile(filePath) - if err != nil { - t.Error("parse fail: " + err.Error()) - return + parser := NewJSONStateMachineParser() + + tests := []struct { + name string + configFilePath string + }{ + { + name: "JSON Simple: StateMachine New Designer", + configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.json", + }, + { + name: "YAML Simple: StateMachine New Designer", + configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.yaml", + }, } - _, err = NewJSONStateMachineParser().Parse(string(fileContent)) - if err != nil { - t.Error("parse fail: " + err.Error()) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + _, err := parser.Parse(tt.configFilePath) + if err != nil { + t.Error("parse fail: " + err.Error()) + } + }) } } From fa1d7870484f50c8b2bff17e54d9572179d982a6 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Sun, 15 Dec 2024 14:54:50 +0800 Subject: [PATCH 04/11] bugfix: fix the problem of failure to parse "ServiceName" --- .../statemachine/statelang/parser/task_state_json_parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go b/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go index 8dcfff5c5..ca5766111 100644 --- a/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go +++ b/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go @@ -242,7 +242,7 @@ func (s ServiceTaskStateParser) Parse(stateName string, stateMap map[string]inte return nil, err } - serviceName, err := s.GetString(stateName, stateMap, "serviceName") + serviceName, err := s.GetString(stateName, stateMap, "ServiceName") if err != nil { return nil, err } From 6be422f33da4f7579508510064d4225666d06548 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Sun, 15 Dec 2024 14:57:52 +0800 Subject: [PATCH 05/11] adjust statemachine_parser to be compatible with yaml --- .../statelang/parser/statemachine_parser.go | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_parser.go index 690ad278f..892c8f484 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_parser.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_parser.go @@ -148,18 +148,23 @@ func (b BaseStateParser) GetIntOrDefault(stateName string, stateMap map[string]i return defaultValue, nil } - // just use float64 to convert, json reader will read all number as float64 - valueAsFloat64, ok := value.(float64) - if !ok { + // use float64 conversion when the configuration file is json, and use int conversion when the configuration file is yaml + valueAsFloat64, okToFloat64 := value.(float64) + valueAsInt, okToInt := value.(int) + if !okToFloat64 && !okToInt { return defaultValue, errors.New("State [" + stateName + "] " + key + " illegal, required int") } - floatStr := strconv.FormatFloat(valueAsFloat64, 'f', -1, 64) - if strings.Contains(floatStr, ".") { - return defaultValue, errors.New("State [" + stateName + "] " + key + " illegal, required int") + if okToFloat64 { + floatStr := strconv.FormatFloat(valueAsFloat64, 'f', -1, 64) + if strings.Contains(floatStr, ".") { + return defaultValue, errors.New("State [" + stateName + "] " + key + " illegal, required int") + } + + return int(valueAsFloat64), nil } - return int(valueAsFloat64), nil + return valueAsInt, nil } func (b BaseStateParser) GetFloat64OrDefault(stateName string, stateMap map[string]interface{}, key string, defaultValue float64) (float64, error) { @@ -169,11 +174,17 @@ func (b BaseStateParser) GetFloat64OrDefault(stateName string, stateMap map[stri return defaultValue, nil } - valueAsFloat64, ok := value.(float64) - if !ok { + // use float64 conversion when the configuration file is json, and use int conversion when the configuration file is yaml + valueAsFloat64, okToFloat64 := value.(float64) + valueAsInt, okToInt := value.(int) + if !okToFloat64 && !okToInt { return defaultValue, errors.New("State [" + stateName + "] " + key + " illegal, required float64") } - return valueAsFloat64, nil + + if okToFloat64 { + return valueAsFloat64, nil + } + return float64(valueAsInt), nil } type StateParserFactory interface { From f981e95fbc3bd2001d6c8881cddccec7a919f6c5 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Mon, 16 Dec 2024 14:46:04 +0800 Subject: [PATCH 06/11] add apache License, add some comments, and make some logical adjustments --- .../parser/statemachine_config_parser.go | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go index 2c87beb18..1de776390 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( @@ -10,6 +27,7 @@ import ( "path/filepath" ) +// ConfigParser is a general configuration parser interface, used to agree on the implementation of different types of parsers type ConfigParser interface { Parse(configContent []byte) (*StateMachineObject, error) } @@ -21,10 +39,11 @@ func NewStateMachineConfigParser() *StateMachineConfigParser { } func (p *StateMachineConfigParser) checkConfigFile(configFilePath string) error { - if _, err := os.Stat(configFilePath); err != nil { - if os.IsNotExist(err) { - return fmt.Errorf("config file %s does not exist: %w", configFilePath, err) - } + _, err := os.Stat(configFilePath) + if os.IsNotExist(err) { + return fmt.Errorf("config file %s does not exist: %w", configFilePath, err) + } + if err != nil { return fmt.Errorf("failed to access config file %s: %w", configFilePath, err) } return nil @@ -47,10 +66,11 @@ func (p *StateMachineConfigParser) readFile(configFilePath string) ([]byte, erro func (p *StateMachineConfigParser) getParser(configFilePath string) (ConfigParser, error) { fileExt := filepath.Ext(configFilePath) + // check the file extension, compatible with some illegal but possible situations switch fileExt { - case ".json": + case ".json", ".JSON": return NewJSONConfigParser(), nil - case ".yaml", ".yml": + case ".yaml", ".yml", ".YAML", ".YML": return NewYAMLConfigParser(), nil default: return nil, fmt.Errorf("unsupported config file format: %s", fileExt) From c9a8fe5b13d79fa1a10d67d4863bd87d9fb98193 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Mon, 16 Dec 2024 20:18:48 +0800 Subject: [PATCH 07/11] update state_machine_new_designer.yaml --- .../statelang/state_machine_new_designer.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/testdata/saga/statelang/state_machine_new_designer.yaml b/testdata/saga/statelang/state_machine_new_designer.yaml index 6891797eb..d646ab01d 100644 --- a/testdata/saga/statelang/state_machine_new_designer.yaml +++ b/testdata/saga/statelang/state_machine_new_designer.yaml @@ -42,6 +42,8 @@ States: y: 218 x: 455 y: 218 + source: ServiceTask-a9h2o51 + target: Choice-4ajl8nt Type: Transition CompensateState: CompensateFirstState Choice-4ajl8nt: @@ -75,6 +77,8 @@ States: y: 218 x: 550 y: 218 + source: Choice-4ajl8nt + target: SubStateMachine-cauj9uy Type: ChoiceEntry ServiceTask-vdij28l: style: @@ -91,6 +95,8 @@ States: y: 310 x: 600 y: 310 + source: Choice-4ajl8nt + target: ServiceTask-vdij28l Type: ChoiceEntry CompensateFirstState: style: @@ -142,6 +148,8 @@ States: y: 218 x: 722 y: 218 + source: SubStateMachine-cauj9uy + target: Succeed-5x3z98u Type: Transition ServiceTask-vdij28l: style: @@ -206,8 +214,8 @@ States: y: 236 x: 740 y: 236 - source: ServiceTask-vdij28l - target: Succeed-5x3z98u + source: ServiceTask-vdij28l + target: Succeed-5x3z98u Type: Transition Succeed-5x3z98u: style: @@ -244,8 +252,8 @@ States: y: 390 x: 812 y: 390 - source: CompensationTrigger-uldp2ou - target: Fail-9roxcv5 + source: CompensationTrigger-uldp2ou + target: Fail-9roxcv5 Type: Transition Fail-9roxcv5: style: From 5e76a6cc8da27587459685fe63fc8b1360df5561 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Mon, 16 Dec 2024 20:21:00 +0800 Subject: [PATCH 08/11] optimize and improve the unit test of config parser --- .../parser/statemachine_config_parser_test.go | 846 +++++++++++++++++- 1 file changed, 830 insertions(+), 16 deletions(-) diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go index c8b38a5b4..79563a831 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go @@ -1,46 +1,860 @@ package parser -import "testing" +import ( + "github.com/stretchr/testify/assert" + "testing" +) func TestStateMachineConfigParser_Parse(t *testing.T) { parser := NewStateMachineConfigParser() tests := []struct { - name string - configFilePath string + name string + configFilePath string + expectedStateMachineObject *StateMachineObject }{ { - name: "JSON Simple 1", - configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.json", + name: "JSON Simple 1", + configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.json", + expectedStateMachineObject: GetStateMachineObject1("json"), }, { - name: "JSON Simple 2", - configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.json", + name: "JSON Simple 2", + configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.json", + expectedStateMachineObject: GetStateMachineObject2("json"), }, { - name: "JSON Simple 3", - configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.json", + name: "JSON Simple 3", + configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.json", + expectedStateMachineObject: GetStateMachineObject3("json"), }, { - name: "YAML Simple 1", - configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.yaml", + name: "YAML Simple 1", + configFilePath: "../../../../../testdata/saga/statelang/simple_statelang_with_choice.yaml", + expectedStateMachineObject: GetStateMachineObject1("yaml"), }, { - name: "YAML Simple 2", - configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.yaml", + name: "YAML Simple 2", + configFilePath: "../../../../../testdata/saga/statelang/simple_statemachine.yaml", + expectedStateMachineObject: GetStateMachineObject2("yaml"), }, { - name: "YAML Simple 3", - configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.yaml", + name: "YAML Simple 3", + configFilePath: "../../../../../testdata/saga/statelang/state_machine_new_designer.yaml", + expectedStateMachineObject: GetStateMachineObject3("yaml"), }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - _, err := parser.Parse(tt.configFilePath) + object, err := parser.Parse(tt.configFilePath) if err != nil { t.Error("parse fail: " + err.Error()) } + assert.Equal(t, tt.expectedStateMachineObject, object) }) } } + +func GetStateMachineObject1(format string) *StateMachineObject { + switch format { + case "json": + case "yaml": + } + + return &StateMachineObject{ + Name: "simpleChoiceTestStateMachine", + Comment: "带条件分支的测试状态机定义", + StartState: "FirstState", + Version: "0.0.1", + States: map[string]interface{}{ + "FirstState": map[string]interface{}{ + "Type": "ServiceTask", + "ServiceName": "demoService", + "ServiceMethod": "foo", + "Next": "ChoiceState", + }, + "ChoiceState": map[string]interface{}{ + "Type": "Choice", + "Choices": []interface{}{ + map[string]interface{}{ + "Expression": "[a] == 1", + "Next": "SecondState", + }, + map[string]interface{}{ + "Expression": "[a] == 2", + "Next": "ThirdState", + }, + }, + "Default": "SecondState", + }, + "SecondState": map[string]interface{}{ + "Type": "ServiceTask", + "ServiceName": "demoService", + "ServiceMethod": "bar", + }, + "ThirdState": map[string]interface{}{ + "Type": "ServiceTask", + "ServiceName": "demoService", + "ServiceMethod": "foo", + }, + }, + } +} + +func GetStateMachineObject2(format string) *StateMachineObject { + var retryMap map[string]interface{} + + switch format { + case "json": + retryMap = map[string]interface{}{ + "Exceptions": []interface{}{ + "java.lang.Exception", + }, + "IntervalSeconds": float64(2), + "MaxAttempts": float64(3), + "BackoffRate": 1.5, + } + case "yaml": + retryMap = map[string]interface{}{ + "Exceptions": []interface{}{ + "java.lang.Exception", + }, + "IntervalSeconds": 2, + "MaxAttempts": 3, + "BackoffRate": 1.5, + } + } + + return &StateMachineObject{ + Name: "simpleTestStateMachine", + Comment: "测试状态机定义", + StartState: "FirstState", + Version: "0.0.1", + States: map[string]interface{}{ + "FirstState": map[string]interface{}{ + "Type": "ServiceTask", + "ServiceName": "is.seata.saga.DemoService", + "ServiceMethod": "foo", + "IsPersist": false, + "Next": "ScriptState", + }, + "ScriptState": map[string]interface{}{ + "Type": "ScriptTask", + "ScriptType": "groovy", + "ScriptContent": "return 'hello ' + inputA", + "Input": []interface{}{ + map[string]interface{}{ + "inputA": "$.data1", + }, + }, + "Output": map[string]interface{}{ + "scriptStateResult": "$.#root", + }, + "Next": "ChoiceState", + }, + "ChoiceState": map[string]interface{}{ + "Type": "Choice", + "Choices": []interface{}{ + map[string]interface{}{ + "Expression": "foo == 1", + "Next": "FirstMatchState", + }, + map[string]interface{}{ + "Expression": "foo == 2", + "Next": "SecondMatchState", + }, + }, + "Default": "FailState", + }, + "FirstMatchState": map[string]interface{}{ + "Type": "ServiceTask", + "ServiceName": "is.seata.saga.DemoService", + "ServiceMethod": "bar", + "CompensateState": "CompensateFirst", + "Status": map[string]interface{}{ + "return.code == 'S'": "SU", + "return.code == 'F'": "FA", + "$exception{java.lang.Throwable}": "UN", + }, + "Input": []interface{}{ + map[string]interface{}{ + "inputA1": "$.data1", + "inputA2": map[string]interface{}{ + "a": "$.data2.a", + }, + }, + map[string]interface{}{ + "inputB": "$.header", + }, + }, + "Output": map[string]interface{}{ + "firstMatchStateResult": "$.#root", + }, + "Retry": []interface{}{ + retryMap, + }, + "Catch": []interface{}{ + map[string]interface{}{ + "Exceptions": []interface{}{ + "java.lang.Exception", + }, + "Next": "CompensationTrigger", + }, + }, + "Next": "SuccessState", + }, + "CompensateFirst": map[string]interface{}{ + "Type": "ServiceTask", + "ServiceName": "is.seata.saga.DemoService", + "ServiceMethod": "compensateBar", + "IsForCompensation": true, + "IsForUpdate": true, + "Input": []interface{}{ + map[string]interface{}{ + "input": "$.data", + }, + }, + "Output": map[string]interface{}{ + "firstMatchStateResult": "$.#root", + }, + "Status": map[string]interface{}{ + "return.code == 'S'": "SU", + "return.code == 'F'": "FA", + "$exception{java.lang.Throwable}": "UN", + }, + }, + "CompensationTrigger": map[string]interface{}{ + "Type": "CompensationTrigger", + "Next": "CompensateEndState", + }, + "CompensateEndState": map[string]interface{}{ + "Type": "Fail", + "ErrorCode": "StateCompensated", + "Message": "State Compensated!", + }, + "SecondMatchState": map[string]interface{}{ + "Type": "SubStateMachine", + "StateMachineName": "simpleTestSubStateMachine", + "Input": []interface{}{ + map[string]interface{}{ + "input": "$.data", + }, + map[string]interface{}{ + "header": "$.header", + }, + }, + "Output": map[string]interface{}{ + "firstMatchStateResult": "$.#root", + }, + "Next": "SuccessState", + }, + "FailState": map[string]interface{}{ + "Type": "Fail", + "ErrorCode": "DefaultStateError", + "Message": "No Matches!", + }, + "SuccessState": map[string]interface{}{ + "Type": "Succeed", + }, + }, + } +} + +func GetStateMachineObject3(format string) *StateMachineObject { + var ( + boundsMap1 map[string]interface{} + boundsMap2 map[string]interface{} + boundsMap3 map[string]interface{} + boundsMap4 map[string]interface{} + boundsMap5 map[string]interface{} + boundsMap6 map[string]interface{} + boundsMap7 map[string]interface{} + boundsMap8 map[string]interface{} + boundsMap9 map[string]interface{} + + waypoints1 []interface{} + waypoints2 []interface{} + waypoints3 []interface{} + waypoints4 []interface{} + waypoints5 []interface{} + waypoints6 []interface{} + waypoints7 []interface{} + ) + + switch format { + case "json": + boundsMap1 = map[string]interface{}{ + "x": float64(300), + "y": float64(178), + "width": float64(100), + "height": float64(80), + } + boundsMap2 = map[string]interface{}{ + "x": float64(455), + "y": float64(193), + "width": float64(50), + "height": float64(50), + } + boundsMap3 = map[string]interface{}{ + "x": float64(300), + "y": float64(310), + "width": float64(100), + "height": float64(80), + } + boundsMap4 = map[string]interface{}{ + "x": float64(550), + "y": float64(178), + "width": float64(100), + "height": float64(80), + } + boundsMap5 = map[string]interface{}{ + "x": float64(550), + "y": float64(310), + "width": float64(100), + "height": float64(80), + } + boundsMap6 = map[string]interface{}{ + "x": float64(632), + "y": float64(372), + "width": float64(36), + "height": float64(36), + } + boundsMap7 = map[string]interface{}{ + "x": float64(722), + "y": float64(200), + "width": float64(36), + "height": float64(36), + } + boundsMap8 = map[string]interface{}{ + "x": float64(722), + "y": float64(372), + "width": float64(36), + "height": float64(36), + } + boundsMap9 = map[string]interface{}{ + "x": float64(812), + "y": float64(372), + "width": float64(36), + "height": float64(36), + } + + waypoints1 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(400), + "y": float64(218), + }, + "x": float64(400), + "y": float64(218), + }, + map[string]interface{}{"x": float64(435), "y": float64(218)}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(455), + "y": float64(218), + }, + "x": float64(455), + "y": float64(218), + }, + } + waypoints2 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(505), + "y": float64(218), + }, + "x": float64(505), + "y": float64(218), + }, + map[string]interface{}{"x": float64(530), "y": float64(218)}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(550), + "y": float64(218), + }, + "x": float64(550), + "y": float64(218), + }, + } + waypoints3 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(480), + "y": float64(243), + }, + "x": float64(480), + "y": float64(243), + }, + map[string]interface{}{"x": float64(600), "y": float64(290)}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(600), + "y": float64(310), + }, + "x": float64(600), + "y": float64(310), + }, + } + waypoints4 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(650), + "y": float64(218), + }, + "x": float64(650), + "y": float64(218), + }, + map[string]interface{}{"x": float64(702), "y": float64(218)}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(722), + "y": float64(218), + }, + "x": float64(722), + "y": float64(218), + }, + } + waypoints5 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(668), + "y": float64(390), + }, + "x": float64(668), + "y": float64(390), + }, + map[string]interface{}{"x": float64(702), "y": float64(390)}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(722), + "y": float64(390), + }, + "x": float64(722), + "y": float64(390), + }, + } + waypoints6 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(600), + "y": float64(310), + }, + "x": float64(600), + "y": float64(310), + }, + map[string]interface{}{"x": float64(740), "y": float64(256)}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(740), + "y": float64(236), + }, + "x": float64(740), + "y": float64(236), + }, + } + waypoints7 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(758), + "y": float64(390), + }, + "x": float64(758), + "y": float64(390), + }, + map[string]interface{}{"x": float64(792), "y": float64(390)}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": float64(812), + "y": float64(390), + }, + "x": float64(812), + "y": float64(390), + }, + } + + case "yaml": + boundsMap1 = map[string]interface{}{ + "x": 300, + "y": 178, + "width": 100, + "height": 80, + } + boundsMap2 = map[string]interface{}{ + "x": 455, + "y": 193, + "width": 50, + "height": 50, + } + boundsMap3 = map[string]interface{}{ + "x": 300, + "y": 310, + "width": 100, + "height": 80, + } + boundsMap4 = map[string]interface{}{ + "x": 550, + "y": 178, + "width": 100, + "height": 80, + } + boundsMap5 = map[string]interface{}{ + "x": 550, + "y": 310, + "width": 100, + "height": 80, + } + boundsMap6 = map[string]interface{}{ + "x": 632, + "y": 372, + "width": 36, + "height": 36, + } + boundsMap7 = map[string]interface{}{ + "x": 722, + "y": 200, + "width": 36, + "height": 36, + } + boundsMap8 = map[string]interface{}{ + "x": 722, + "y": 372, + "width": 36, + "height": 36, + } + boundsMap9 = map[string]interface{}{ + "x": 812, + "y": 372, + "width": 36, + "height": 36, + } + + waypoints1 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 400, + "y": 218, + }, + "x": 400, + "y": 218, + }, + map[string]interface{}{"x": 435, "y": 218}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 455, + "y": 218, + }, + "x": 455, + "y": 218, + }, + } + waypoints2 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 505, + "y": 218, + }, + "x": 505, + "y": 218, + }, + map[string]interface{}{"x": 530, "y": 218}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 550, + "y": 218, + }, + "x": 550, + "y": 218, + }, + } + waypoints3 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 480, + "y": 243, + }, + "x": 480, + "y": 243, + }, + map[string]interface{}{"x": 600, "y": 290}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 600, + "y": 310, + }, + "x": 600, + "y": 310, + }, + } + waypoints4 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 650, + "y": 218, + }, + "x": 650, + "y": 218, + }, + map[string]interface{}{"x": 702, "y": 218}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 722, + "y": 218, + }, + "x": 722, + "y": 218, + }, + } + waypoints5 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 668, + "y": 390, + }, + "x": 668, + "y": 390, + }, + map[string]interface{}{"x": 702, "y": 390}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 722, + "y": 390, + }, + "x": 722, + "y": 390, + }, + } + waypoints6 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 600, + "y": 310, + }, + "x": 600, + "y": 310, + }, + map[string]interface{}{"x": 740, "y": 256}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 740, + "y": 236, + }, + "x": 740, + "y": 236, + }, + } + waypoints7 = []interface{}{ + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 758, + "y": 390, + }, + "x": 758, + "y": 390, + }, + map[string]interface{}{"x": 792, "y": 390}, + map[string]interface{}{ + "original": map[string]interface{}{ + "x": 812, + "y": 390, + }, + "x": 812, + "y": 390, + }, + } + } + + return &StateMachineObject{ + Name: "StateMachineNewDesigner", + Comment: "This state machine is modeled by designer tools.", + Version: "0.0.1", + StartState: "ServiceTask-a9h2o51", + RecoverStrategy: "", + Persist: false, + RetryPersistModeUpdate: false, + CompensatePersistModeUpdate: false, + Type: "", + States: map[string]interface{}{ + "ServiceTask-a9h2o51": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap1, + }, + "Name": "ServiceTask-a9h2o51", + "IsForCompensation": false, + "Input": []interface{}{map[string]interface{}{}}, + "Output": map[string]interface{}{}, + "Status": map[string]interface{}{}, + "Retry": []interface{}{}, + "ServiceName": "", + "ServiceMethod": "", + "Type": "ServiceTask", + "Next": "Choice-4ajl8nt", + "edge": map[string]interface{}{ + "Choice-4ajl8nt": map[string]interface{}{ + "style": map[string]interface{}{ + "waypoints": waypoints1, + "source": "ServiceTask-a9h2o51", + "target": "Choice-4ajl8nt", + }, + "Type": "Transition", + }, + }, + "CompensateState": "CompensateFirstState", + }, + "Choice-4ajl8nt": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap2, + }, + "Name": "Choice-4ajl8nt", + "Type": "Choice", + "Choices": []interface{}{ + map[string]interface{}{ + "Expression": "", + "Next": "SubStateMachine-cauj9uy", + }, + map[string]interface{}{ + "Expression": "", + "Next": "ServiceTask-vdij28l", + }, + }, + "Default": "SubStateMachine-cauj9uy", + "edge": map[string]interface{}{ + "SubStateMachine-cauj9uy": map[string]interface{}{ + "style": map[string]interface{}{ + "waypoints": waypoints2, + "source": "Choice-4ajl8nt", + "target": "SubStateMachine-cauj9uy", + }, + "Type": "ChoiceEntry", + }, + "ServiceTask-vdij28l": map[string]interface{}{ + "style": map[string]interface{}{ + "waypoints": waypoints3, + "source": "Choice-4ajl8nt", + "target": "ServiceTask-vdij28l", + }, + "Type": "ChoiceEntry", + }, + }, + }, + "CompensateFirstState": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap3, + }, + "Name": "CompensateFirstState", + "IsForCompensation": true, + "Input": []interface{}{map[string]interface{}{}}, + "Output": map[string]interface{}{}, + "Status": map[string]interface{}{}, + "Retry": []interface{}{}, + "ServiceName": "", + "ServiceMethod": "", + "Type": "ServiceTask", + }, + "SubStateMachine-cauj9uy": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap4, + }, + "Name": "SubStateMachine-cauj9uy", + "IsForCompensation": false, + "Input": []interface{}{map[string]interface{}{}}, + "Output": map[string]interface{}{}, + "Status": map[string]interface{}{}, + "Retry": []interface{}{}, + "StateMachineName": "", + "Type": "SubStateMachine", + "Next": "Succeed-5x3z98u", + "edge": map[string]interface{}{ + "Succeed-5x3z98u": map[string]interface{}{ + "style": map[string]interface{}{ + "waypoints": waypoints4, + "source": "SubStateMachine-cauj9uy", + "target": "Succeed-5x3z98u", + }, + "Type": "Transition", + }, + }, + }, + "ServiceTask-vdij28l": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap5, + }, + "Name": "ServiceTask-vdij28l", + "IsForCompensation": false, + "Input": []interface{}{map[string]interface{}{}}, + "Output": map[string]interface{}{}, + "Status": map[string]interface{}{}, + "Retry": []interface{}{}, + "ServiceName": "", + "ServiceMethod": "", + "Catch": []interface{}{ + map[string]interface{}{ + "Exceptions": []interface{}{}, + "Next": "CompensationTrigger-uldp2ou", + }, + }, + "Type": "ServiceTask", + "catch": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap6, + }, + "edge": map[string]interface{}{ + "CompensationTrigger-uldp2ou": map[string]interface{}{ + "style": map[string]interface{}{ + "waypoints": waypoints5, + "source": "ServiceTask-vdij28l", + "target": "CompensationTrigger-uldp2ou", + }, + "Type": "ExceptionMatch", + }, + }, + }, + "Next": "Succeed-5x3z98u", + "edge": map[string]interface{}{ + "Succeed-5x3z98u": map[string]interface{}{ + "style": map[string]interface{}{ + "waypoints": waypoints6, + "source": "ServiceTask-vdij28l", + "target": "Succeed-5x3z98u", + }, + "Type": "Transition", + }, + }, + }, + "Succeed-5x3z98u": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap7, + }, + "Name": "Succeed-5x3z98u", + "Type": "Succeed", + }, + "CompensationTrigger-uldp2ou": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap8, + }, + "Name": "CompensationTrigger-uldp2ou", + "Type": "CompensationTrigger", + "Next": "Fail-9roxcv5", + "edge": map[string]interface{}{ + "Fail-9roxcv5": map[string]interface{}{ + "style": map[string]interface{}{ + "waypoints": waypoints7, + "source": "CompensationTrigger-uldp2ou", + "target": "Fail-9roxcv5", + }, + "Type": "Transition", + }, + }, + }, + "Fail-9roxcv5": map[string]interface{}{ + "style": map[string]interface{}{ + "bounds": boundsMap9, + }, + "Name": "Fail-9roxcv5", + "ErrorCode": "", + "Message": "", + "Type": "Fail", + }, + }, + } +} From 79294707a0841ba8e6b368d5e276b601f9c14b07 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Tue, 7 Jan 2025 13:51:16 +0800 Subject: [PATCH 09/11] refactor config parser --- .../parser/statemachine_config_parser.go | 117 ++++++++---------- .../parser/statemachine_config_parser_test.go | 6 +- .../parser/statemachine_json_parser.go | 4 +- 3 files changed, 60 insertions(+), 67 deletions(-) diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go index 1de776390..63276e2ec 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser.go @@ -24,7 +24,6 @@ import ( "gopkg.in/yaml.v3" "io" "os" - "path/filepath" ) // ConfigParser is a general configuration parser interface, used to agree on the implementation of different types of parsers @@ -32,69 +31,6 @@ type ConfigParser interface { Parse(configContent []byte) (*StateMachineObject, error) } -type StateMachineConfigParser struct{} - -func NewStateMachineConfigParser() *StateMachineConfigParser { - return &StateMachineConfigParser{} -} - -func (p *StateMachineConfigParser) checkConfigFile(configFilePath string) error { - _, err := os.Stat(configFilePath) - if os.IsNotExist(err) { - return fmt.Errorf("config file %s does not exist: %w", configFilePath, err) - } - if err != nil { - return fmt.Errorf("failed to access config file %s: %w", configFilePath, err) - } - return nil -} - -func (p *StateMachineConfigParser) readFile(configFilePath string) ([]byte, error) { - file, _ := os.Open(configFilePath) - defer func(file *os.File) { - _ = file.Close() - }(file) - - var buf bytes.Buffer - _, err := io.Copy(&buf, file) - if err != nil { - return nil, fmt.Errorf("failed to read config file %s: %w", configFilePath, err) - } - - return buf.Bytes(), nil -} - -func (p *StateMachineConfigParser) getParser(configFilePath string) (ConfigParser, error) { - fileExt := filepath.Ext(configFilePath) - // check the file extension, compatible with some illegal but possible situations - switch fileExt { - case ".json", ".JSON": - return NewJSONConfigParser(), nil - case ".yaml", ".yml", ".YAML", ".YML": - return NewYAMLConfigParser(), nil - default: - return nil, fmt.Errorf("unsupported config file format: %s", fileExt) - } -} - -func (p *StateMachineConfigParser) Parse(configFilePath string) (*StateMachineObject, error) { - if err := p.checkConfigFile(configFilePath); err != nil { - return nil, err - } - - configContent, err := p.readFile(configFilePath) - if err != nil { - return nil, err - } - - parser, err := p.getParser(configFilePath) - if err != nil { - return nil, err - } - - return parser.Parse(configContent) -} - type JSONConfigParser struct{} func NewJSONConfigParser() *JSONConfigParser { @@ -133,6 +69,59 @@ func (p *YAMLConfigParser) Parse(configContent []byte) (*StateMachineObject, err return &stateMachineObject, nil } +type StateMachineConfigParser struct{} + +func NewStateMachineConfigParser() *StateMachineConfigParser { + return &StateMachineConfigParser{} +} + +func (p *StateMachineConfigParser) CheckConfigFile(filePath string) error { + _, err := os.Stat(filePath) + if os.IsNotExist(err) { + return fmt.Errorf("config file %s does not exist: %w", filePath, err) + } + if err != nil { + return fmt.Errorf("failed to access config file %s: %w", filePath, err) + } + return nil +} + +func (p *StateMachineConfigParser) ReadConfigFile(configFilePath string) ([]byte, error) { + file, _ := os.Open(configFilePath) + defer func(file *os.File) { + _ = file.Close() + }(file) + + var buf bytes.Buffer + _, err := io.Copy(&buf, file) + if err != nil { + return nil, fmt.Errorf("failed to read config file %s: %w", configFilePath, err) + } + + return buf.Bytes(), nil +} + +func (p *StateMachineConfigParser) getParser(content []byte) (ConfigParser, error) { + var obj interface{} + if err := json.Unmarshal(content, &obj); err == nil { + return NewJSONConfigParser(), nil + } + if err := yaml.Unmarshal(content, &obj); err == nil { + return NewYAMLConfigParser(), nil + } + + return nil, fmt.Errorf("unsupported config file format") +} + +func (p *StateMachineConfigParser) Parse(content []byte) (*StateMachineObject, error) { + parser, err := p.getParser(content) + if err != nil { + return nil, err + } + + return parser.Parse(content) +} + type StateMachineObject struct { Name string `json:"Name" yaml:"Name"` Comment string `json:"Comment" yaml:"Comment"` diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go index 79563a831..203ff43c5 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go @@ -47,7 +47,11 @@ func TestStateMachineConfigParser_Parse(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - object, err := parser.Parse(tt.configFilePath) + content, err := parser.ReadConfigFile(tt.configFilePath) + if err != nil { + t.Error("parse fail: " + err.Error()) + } + object, err := parser.Parse(content) if err != nil { t.Error("parse fail: " + err.Error()) } diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go index 9c9bcc5c8..9f9f4fe81 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go @@ -21,8 +21,8 @@ func (stateMachineParser JSONStateMachineParser) GetType() string { return "JSON" } -func (stateMachineParser JSONStateMachineParser) Parse(configFilePath string) (statelang.StateMachine, error) { - stateMachineJsonObject, err := NewStateMachineConfigParser().Parse(configFilePath) +func (stateMachineParser JSONStateMachineParser) Parse(content string) (statelang.StateMachine, error) { + stateMachineJsonObject, err := NewStateMachineConfigParser().Parse([]byte(content)) if err != nil { return nil, err } From 51d265db8674b4b4fbad3682e60ae53948671b65 Mon Sep 17 00:00:00 2001 From: FinnTew Date: Tue, 7 Jan 2025 14:24:40 +0800 Subject: [PATCH 10/11] add apache License --- pkg/saga/statemachine/constant/constant.go | 17 +++++++++++++++++ .../engine/core/bussiness_processor.go | 17 +++++++++++++++++ .../engine/core/compensation_holder.go | 17 +++++++++++++++++ .../engine/core/default_statemachine_config.go | 17 +++++++++++++++++ .../statemachine/engine/core/engine_utils.go | 17 +++++++++++++++++ pkg/saga/statemachine/engine/core/event.go | 17 +++++++++++++++++ pkg/saga/statemachine/engine/core/event_bus.go | 17 +++++++++++++++++ .../statemachine/engine/core/event_consumer.go | 17 +++++++++++++++++ .../statemachine/engine/core/event_publisher.go | 17 +++++++++++++++++ .../statemachine/engine/core/instruction.go | 17 +++++++++++++++++ .../engine/core/loop_context_holder.go | 17 +++++++++++++++++ .../statemachine/engine/core/loop_task_utils.go | 17 +++++++++++++++++ .../statemachine/engine/core/parameter_utils.go | 17 +++++++++++++++++ .../statemachine/engine/core/process_context.go | 17 +++++++++++++++++ .../engine/core/process_controller.go | 17 +++++++++++++++++ .../core/process_ctrl_statemachine_engine.go | 17 +++++++++++++++++ .../statemachine/engine/core/process_router.go | 17 +++++++++++++++++ .../statemachine/engine/core/process_state.go | 17 +++++++++++++++++ .../statemachine/engine/core/state_router.go | 17 +++++++++++++++++ .../engine/core/statemachine_config.go | 17 +++++++++++++++++ .../engine/core/statemachine_engine.go | 17 +++++++++++++++++ .../engine/core/statemachine_engine_test.go | 17 +++++++++++++++++ .../engine/core/statemachine_store.go | 17 +++++++++++++++++ .../statemachine/engine/core/status_decision.go | 17 +++++++++++++++++ pkg/saga/statemachine/engine/core/utils.go | 17 +++++++++++++++++ .../statemachine/engine/exception/exception.go | 17 +++++++++++++++++ pkg/saga/statemachine/engine/expr/expression.go | 17 +++++++++++++++++ .../statemachine/engine/invoker/grpc_invoker.go | 17 +++++++++++++++++ .../engine/invoker/grpc_invoker_test.go | 17 +++++++++++++++++ pkg/saga/statemachine/engine/invoker/invoker.go | 17 +++++++++++++++++ .../statemachine/engine/sequence/sequence.go | 17 +++++++++++++++++ .../statemachine/engine/sequence/snowflake.go | 17 +++++++++++++++++ .../engine/sequence/snowflake_test.go | 17 +++++++++++++++++ pkg/saga/statemachine/engine/sequence/uuid.go | 17 +++++++++++++++++ .../engine/serializer/serializer.go | 17 +++++++++++++++++ .../engine/serializer/serializer_test.go | 17 +++++++++++++++++ .../handlers/service_task_state_handler.go | 17 +++++++++++++++++ .../process_ctrl/process/process_type.go | 17 +++++++++++++++++ .../parser/choice_state_json_parser.go | 17 +++++++++++++++++ .../parser/compensation_trigger_state_parser.go | 17 +++++++++++++++++ .../statelang/parser/end_state_parser.go | 17 +++++++++++++++++ .../parser/statemachine_config_parser_test.go | 17 +++++++++++++++++ .../parser/statemachine_json_parser.go | 17 +++++++++++++++++ .../parser/statemachine_json_parser_test.go | 17 +++++++++++++++++ .../statelang/parser/statemachine_parser.go | 17 +++++++++++++++++ .../parser/sub_state_machine_parser.go | 17 +++++++++++++++++ .../statelang/parser/task_state_json_parser.go | 17 +++++++++++++++++ pkg/saga/statemachine/statelang/state.go | 17 +++++++++++++++++ .../statelang/state/choice_state.go | 17 +++++++++++++++++ .../state/compensation_trigger_state.go | 17 +++++++++++++++++ .../statemachine/statelang/state/end_state.go | 17 +++++++++++++++++ .../statelang/state/loop_start_state.go | 17 +++++++++++++++++ .../statelang/state/sub_state_machine.go | 17 +++++++++++++++++ .../statemachine/statelang/state/task_state.go | 17 +++++++++++++++++ .../statemachine/statelang/state_instance.go | 17 +++++++++++++++++ pkg/saga/statemachine/statelang/statemachine.go | 17 +++++++++++++++++ .../statelang/statemachine_instance.go | 17 +++++++++++++++++ pkg/saga/statemachine/store/db/db.go | 17 +++++++++++++++++ pkg/saga/statemachine/store/db/db_test.go | 17 +++++++++++++++++ pkg/saga/statemachine/store/db/statelang.go | 17 +++++++++++++++++ .../statemachine/store/db/statelang_test.go | 17 +++++++++++++++++ pkg/saga/statemachine/store/db/statelog.go | 17 +++++++++++++++++ pkg/saga/statemachine/store/db/statelog_test.go | 17 +++++++++++++++++ .../repository/state_machine_repository.go | 17 +++++++++++++++++ pkg/util/reflectx/unmarkshaler.go | 17 +++++++++++++++++ 65 files changed, 1105 insertions(+) diff --git a/pkg/saga/statemachine/constant/constant.go b/pkg/saga/statemachine/constant/constant.go index a089e7d57..72af09e92 100644 --- a/pkg/saga/statemachine/constant/constant.go +++ b/pkg/saga/statemachine/constant/constant.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package constant const ( diff --git a/pkg/saga/statemachine/engine/core/bussiness_processor.go b/pkg/saga/statemachine/engine/core/bussiness_processor.go index 6b0a2bb46..38846dff5 100644 --- a/pkg/saga/statemachine/engine/core/bussiness_processor.go +++ b/pkg/saga/statemachine/engine/core/bussiness_processor.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/compensation_holder.go b/pkg/saga/statemachine/engine/core/compensation_holder.go index 562cb020c..c22fb1fe0 100644 --- a/pkg/saga/statemachine/engine/core/compensation_holder.go +++ b/pkg/saga/statemachine/engine/core/compensation_holder.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/default_statemachine_config.go b/pkg/saga/statemachine/engine/core/default_statemachine_config.go index c76926961..fa2ef1572 100644 --- a/pkg/saga/statemachine/engine/core/default_statemachine_config.go +++ b/pkg/saga/statemachine/engine/core/default_statemachine_config.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/engine_utils.go b/pkg/saga/statemachine/engine/core/engine_utils.go index e1dcd4de4..63eb79903 100644 --- a/pkg/saga/statemachine/engine/core/engine_utils.go +++ b/pkg/saga/statemachine/engine/core/engine_utils.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/event.go b/pkg/saga/statemachine/engine/core/event.go index 4f7c18b2c..871c0ce99 100644 --- a/pkg/saga/statemachine/engine/core/event.go +++ b/pkg/saga/statemachine/engine/core/event.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core type Event interface { diff --git a/pkg/saga/statemachine/engine/core/event_bus.go b/pkg/saga/statemachine/engine/core/event_bus.go index 47d617d49..e793419f2 100644 --- a/pkg/saga/statemachine/engine/core/event_bus.go +++ b/pkg/saga/statemachine/engine/core/event_bus.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/event_consumer.go b/pkg/saga/statemachine/engine/core/event_consumer.go index 1df21bdb4..25f8762e0 100644 --- a/pkg/saga/statemachine/engine/core/event_consumer.go +++ b/pkg/saga/statemachine/engine/core/event_consumer.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/event_publisher.go b/pkg/saga/statemachine/engine/core/event_publisher.go index 9ad86940c..447dee309 100644 --- a/pkg/saga/statemachine/engine/core/event_publisher.go +++ b/pkg/saga/statemachine/engine/core/event_publisher.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import "context" diff --git a/pkg/saga/statemachine/engine/core/instruction.go b/pkg/saga/statemachine/engine/core/instruction.go index ed81fc9c0..4b8f9d3c1 100644 --- a/pkg/saga/statemachine/engine/core/instruction.go +++ b/pkg/saga/statemachine/engine/core/instruction.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/loop_context_holder.go b/pkg/saga/statemachine/engine/core/loop_context_holder.go index b1f69fe80..242e455b9 100644 --- a/pkg/saga/statemachine/engine/core/loop_context_holder.go +++ b/pkg/saga/statemachine/engine/core/loop_context_holder.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/loop_task_utils.go b/pkg/saga/statemachine/engine/core/loop_task_utils.go index d56ac7f0a..18a3bec46 100644 --- a/pkg/saga/statemachine/engine/core/loop_task_utils.go +++ b/pkg/saga/statemachine/engine/core/loop_task_utils.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/parameter_utils.go b/pkg/saga/statemachine/engine/core/parameter_utils.go index 680167cf3..56336b7dd 100644 --- a/pkg/saga/statemachine/engine/core/parameter_utils.go +++ b/pkg/saga/statemachine/engine/core/parameter_utils.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/process_context.go b/pkg/saga/statemachine/engine/core/process_context.go index 9da5c3e87..163ea6406 100644 --- a/pkg/saga/statemachine/engine/core/process_context.go +++ b/pkg/saga/statemachine/engine/core/process_context.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/process_controller.go b/pkg/saga/statemachine/engine/core/process_controller.go index 2f45aebdc..4c987db57 100644 --- a/pkg/saga/statemachine/engine/core/process_controller.go +++ b/pkg/saga/statemachine/engine/core/process_controller.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/process_ctrl_statemachine_engine.go b/pkg/saga/statemachine/engine/core/process_ctrl_statemachine_engine.go index 426ec65dc..1b59123d3 100644 --- a/pkg/saga/statemachine/engine/core/process_ctrl_statemachine_engine.go +++ b/pkg/saga/statemachine/engine/core/process_ctrl_statemachine_engine.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/process_router.go b/pkg/saga/statemachine/engine/core/process_router.go index 5d7e59981..1875cb163 100644 --- a/pkg/saga/statemachine/engine/core/process_router.go +++ b/pkg/saga/statemachine/engine/core/process_router.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/process_state.go b/pkg/saga/statemachine/engine/core/process_state.go index 3dc06920f..66dee8ff6 100644 --- a/pkg/saga/statemachine/engine/core/process_state.go +++ b/pkg/saga/statemachine/engine/core/process_state.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/state_router.go b/pkg/saga/statemachine/engine/core/state_router.go index 185984e4e..73dd02e2d 100644 --- a/pkg/saga/statemachine/engine/core/state_router.go +++ b/pkg/saga/statemachine/engine/core/state_router.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/statemachine_config.go b/pkg/saga/statemachine/engine/core/statemachine_config.go index 9c77b73a9..e3f9da29f 100644 --- a/pkg/saga/statemachine/engine/core/statemachine_config.go +++ b/pkg/saga/statemachine/engine/core/statemachine_config.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/statemachine_engine.go b/pkg/saga/statemachine/engine/core/statemachine_engine.go index c18d91c16..75cdb1a60 100644 --- a/pkg/saga/statemachine/engine/core/statemachine_engine.go +++ b/pkg/saga/statemachine/engine/core/statemachine_engine.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/statemachine_engine_test.go b/pkg/saga/statemachine/engine/core/statemachine_engine_test.go index e87eb9ca6..8af2cdfc5 100644 --- a/pkg/saga/statemachine/engine/core/statemachine_engine_test.go +++ b/pkg/saga/statemachine/engine/core/statemachine_engine_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/statemachine_store.go b/pkg/saga/statemachine/engine/core/statemachine_store.go index 7a7633351..f47065dd3 100644 --- a/pkg/saga/statemachine/engine/core/statemachine_store.go +++ b/pkg/saga/statemachine/engine/core/statemachine_store.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/status_decision.go b/pkg/saga/statemachine/engine/core/status_decision.go index e95a6316b..6fd596ffb 100644 --- a/pkg/saga/statemachine/engine/core/status_decision.go +++ b/pkg/saga/statemachine/engine/core/status_decision.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/core/utils.go b/pkg/saga/statemachine/engine/core/utils.go index 8300c0eb3..49f03e008 100644 --- a/pkg/saga/statemachine/engine/core/utils.go +++ b/pkg/saga/statemachine/engine/core/utils.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package core import ( diff --git a/pkg/saga/statemachine/engine/exception/exception.go b/pkg/saga/statemachine/engine/exception/exception.go index f5c582395..ea7c07802 100644 --- a/pkg/saga/statemachine/engine/exception/exception.go +++ b/pkg/saga/statemachine/engine/exception/exception.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package exception import "github.com/seata/seata-go/pkg/util/errors" diff --git a/pkg/saga/statemachine/engine/expr/expression.go b/pkg/saga/statemachine/engine/expr/expression.go index 767c49da0..00441d1f8 100644 --- a/pkg/saga/statemachine/engine/expr/expression.go +++ b/pkg/saga/statemachine/engine/expr/expression.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package expr import ( diff --git a/pkg/saga/statemachine/engine/invoker/grpc_invoker.go b/pkg/saga/statemachine/engine/invoker/grpc_invoker.go index e83e798bd..afdc7ef39 100644 --- a/pkg/saga/statemachine/engine/invoker/grpc_invoker.go +++ b/pkg/saga/statemachine/engine/invoker/grpc_invoker.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package invoker import ( diff --git a/pkg/saga/statemachine/engine/invoker/grpc_invoker_test.go b/pkg/saga/statemachine/engine/invoker/grpc_invoker_test.go index 09d6745f9..4beb0d187 100644 --- a/pkg/saga/statemachine/engine/invoker/grpc_invoker_test.go +++ b/pkg/saga/statemachine/engine/invoker/grpc_invoker_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package invoker import ( diff --git a/pkg/saga/statemachine/engine/invoker/invoker.go b/pkg/saga/statemachine/engine/invoker/invoker.go index e1dd5dce2..e0cb85f45 100644 --- a/pkg/saga/statemachine/engine/invoker/invoker.go +++ b/pkg/saga/statemachine/engine/invoker/invoker.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package invoker import ( diff --git a/pkg/saga/statemachine/engine/sequence/sequence.go b/pkg/saga/statemachine/engine/sequence/sequence.go index 1a7fdae73..57cb19c0d 100644 --- a/pkg/saga/statemachine/engine/sequence/sequence.go +++ b/pkg/saga/statemachine/engine/sequence/sequence.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package sequence type SeqGenerator interface { diff --git a/pkg/saga/statemachine/engine/sequence/snowflake.go b/pkg/saga/statemachine/engine/sequence/snowflake.go index f5622b064..6f64edb48 100644 --- a/pkg/saga/statemachine/engine/sequence/snowflake.go +++ b/pkg/saga/statemachine/engine/sequence/snowflake.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package sequence import ( diff --git a/pkg/saga/statemachine/engine/sequence/snowflake_test.go b/pkg/saga/statemachine/engine/sequence/snowflake_test.go index 451f478dc..9c6a96a23 100644 --- a/pkg/saga/statemachine/engine/sequence/snowflake_test.go +++ b/pkg/saga/statemachine/engine/sequence/snowflake_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package sequence import ( diff --git a/pkg/saga/statemachine/engine/sequence/uuid.go b/pkg/saga/statemachine/engine/sequence/uuid.go index f3060dcf5..6dfb0c818 100644 --- a/pkg/saga/statemachine/engine/sequence/uuid.go +++ b/pkg/saga/statemachine/engine/sequence/uuid.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package sequence import "github.com/google/uuid" diff --git a/pkg/saga/statemachine/engine/serializer/serializer.go b/pkg/saga/statemachine/engine/serializer/serializer.go index 4d668ef5c..3a3ddf0a5 100644 --- a/pkg/saga/statemachine/engine/serializer/serializer.go +++ b/pkg/saga/statemachine/engine/serializer/serializer.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package serializer import ( diff --git a/pkg/saga/statemachine/engine/serializer/serializer_test.go b/pkg/saga/statemachine/engine/serializer/serializer_test.go index 9dba88a07..eb163368e 100644 --- a/pkg/saga/statemachine/engine/serializer/serializer_test.go +++ b/pkg/saga/statemachine/engine/serializer/serializer_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package serializer import ( diff --git a/pkg/saga/statemachine/process_ctrl/handlers/service_task_state_handler.go b/pkg/saga/statemachine/process_ctrl/handlers/service_task_state_handler.go index 28d60d0a0..f2a7aff20 100644 --- a/pkg/saga/statemachine/process_ctrl/handlers/service_task_state_handler.go +++ b/pkg/saga/statemachine/process_ctrl/handlers/service_task_state_handler.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package handlers import ( diff --git a/pkg/saga/statemachine/process_ctrl/process/process_type.go b/pkg/saga/statemachine/process_ctrl/process/process_type.go index b1a8e0304..c67c806c7 100644 --- a/pkg/saga/statemachine/process_ctrl/process/process_type.go +++ b/pkg/saga/statemachine/process_ctrl/process/process_type.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package process type ProcessType string diff --git a/pkg/saga/statemachine/statelang/parser/choice_state_json_parser.go b/pkg/saga/statemachine/statelang/parser/choice_state_json_parser.go index 9b4d51cd0..091085483 100644 --- a/pkg/saga/statemachine/statelang/parser/choice_state_json_parser.go +++ b/pkg/saga/statemachine/statelang/parser/choice_state_json_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/compensation_trigger_state_parser.go b/pkg/saga/statemachine/statelang/parser/compensation_trigger_state_parser.go index d41a6d299..3131da907 100644 --- a/pkg/saga/statemachine/statelang/parser/compensation_trigger_state_parser.go +++ b/pkg/saga/statemachine/statelang/parser/compensation_trigger_state_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/end_state_parser.go b/pkg/saga/statemachine/statelang/parser/end_state_parser.go index 823ee8df4..8baa03ad7 100644 --- a/pkg/saga/statemachine/statelang/parser/end_state_parser.go +++ b/pkg/saga/statemachine/statelang/parser/end_state_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go index 203ff43c5..d901296bd 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_config_parser_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go index 9f9f4fe81..c3003ddf6 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go index f2736da8d..2cc82808e 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_json_parser_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/statemachine_parser.go b/pkg/saga/statemachine/statelang/parser/statemachine_parser.go index 892c8f484..883d28e29 100644 --- a/pkg/saga/statemachine/statelang/parser/statemachine_parser.go +++ b/pkg/saga/statemachine/statelang/parser/statemachine_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/sub_state_machine_parser.go b/pkg/saga/statemachine/statelang/parser/sub_state_machine_parser.go index 4de6e5de3..5938e5e4b 100644 --- a/pkg/saga/statemachine/statelang/parser/sub_state_machine_parser.go +++ b/pkg/saga/statemachine/statelang/parser/sub_state_machine_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go b/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go index ca5766111..3c9bff097 100644 --- a/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go +++ b/pkg/saga/statemachine/statelang/parser/task_state_json_parser.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package parser import ( diff --git a/pkg/saga/statemachine/statelang/state.go b/pkg/saga/statemachine/statelang/state.go index 29ac67278..f53449cfe 100644 --- a/pkg/saga/statemachine/statelang/state.go +++ b/pkg/saga/statemachine/statelang/state.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package statelang type State interface { diff --git a/pkg/saga/statemachine/statelang/state/choice_state.go b/pkg/saga/statemachine/statelang/state/choice_state.go index c3f482765..2226404be 100644 --- a/pkg/saga/statemachine/statelang/state/choice_state.go +++ b/pkg/saga/statemachine/statelang/state/choice_state.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package state import "github.com/seata/seata-go/pkg/saga/statemachine/statelang" diff --git a/pkg/saga/statemachine/statelang/state/compensation_trigger_state.go b/pkg/saga/statemachine/statelang/state/compensation_trigger_state.go index cac714206..922b380f6 100644 --- a/pkg/saga/statemachine/statelang/state/compensation_trigger_state.go +++ b/pkg/saga/statemachine/statelang/state/compensation_trigger_state.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package state import ( diff --git a/pkg/saga/statemachine/statelang/state/end_state.go b/pkg/saga/statemachine/statelang/state/end_state.go index 099e2e079..3e1c20331 100644 --- a/pkg/saga/statemachine/statelang/state/end_state.go +++ b/pkg/saga/statemachine/statelang/state/end_state.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package state import ( diff --git a/pkg/saga/statemachine/statelang/state/loop_start_state.go b/pkg/saga/statemachine/statelang/state/loop_start_state.go index e059431d5..91d604a65 100644 --- a/pkg/saga/statemachine/statelang/state/loop_start_state.go +++ b/pkg/saga/statemachine/statelang/state/loop_start_state.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package state import ( diff --git a/pkg/saga/statemachine/statelang/state/sub_state_machine.go b/pkg/saga/statemachine/statelang/state/sub_state_machine.go index 78683a0a3..e18fc0ee9 100644 --- a/pkg/saga/statemachine/statelang/state/sub_state_machine.go +++ b/pkg/saga/statemachine/statelang/state/sub_state_machine.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package state import ( diff --git a/pkg/saga/statemachine/statelang/state/task_state.go b/pkg/saga/statemachine/statelang/state/task_state.go index bc9880ac8..a258a28de 100644 --- a/pkg/saga/statemachine/statelang/state/task_state.go +++ b/pkg/saga/statemachine/statelang/state/task_state.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package state import ( diff --git a/pkg/saga/statemachine/statelang/state_instance.go b/pkg/saga/statemachine/statelang/state_instance.go index e77da058c..5248d0338 100644 --- a/pkg/saga/statemachine/statelang/state_instance.go +++ b/pkg/saga/statemachine/statelang/state_instance.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package statelang import "time" diff --git a/pkg/saga/statemachine/statelang/statemachine.go b/pkg/saga/statemachine/statelang/statemachine.go index 8b13f8d02..0e7dfff81 100644 --- a/pkg/saga/statemachine/statelang/statemachine.go +++ b/pkg/saga/statemachine/statelang/statemachine.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package statelang import ( diff --git a/pkg/saga/statemachine/statelang/statemachine_instance.go b/pkg/saga/statemachine/statelang/statemachine_instance.go index 9da71ee24..b794e1013 100644 --- a/pkg/saga/statemachine/statelang/statemachine_instance.go +++ b/pkg/saga/statemachine/statelang/statemachine_instance.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package statelang import ( diff --git a/pkg/saga/statemachine/store/db/db.go b/pkg/saga/statemachine/store/db/db.go index 39d62e972..aba2c668f 100644 --- a/pkg/saga/statemachine/store/db/db.go +++ b/pkg/saga/statemachine/store/db/db.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package db import ( diff --git a/pkg/saga/statemachine/store/db/db_test.go b/pkg/saga/statemachine/store/db/db_test.go index a5e3edc1a..e80f704bf 100644 --- a/pkg/saga/statemachine/store/db/db_test.go +++ b/pkg/saga/statemachine/store/db/db_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package db import ( diff --git a/pkg/saga/statemachine/store/db/statelang.go b/pkg/saga/statemachine/store/db/statelang.go index e49bf96ac..f0c25e332 100644 --- a/pkg/saga/statemachine/store/db/statelang.go +++ b/pkg/saga/statemachine/store/db/statelang.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package db import ( diff --git a/pkg/saga/statemachine/store/db/statelang_test.go b/pkg/saga/statemachine/store/db/statelang_test.go index 87f868d8c..4b870c114 100644 --- a/pkg/saga/statemachine/store/db/statelang_test.go +++ b/pkg/saga/statemachine/store/db/statelang_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package db import ( diff --git a/pkg/saga/statemachine/store/db/statelog.go b/pkg/saga/statemachine/store/db/statelog.go index 23c3b5511..ba60c61f8 100644 --- a/pkg/saga/statemachine/store/db/statelog.go +++ b/pkg/saga/statemachine/store/db/statelog.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package db import ( diff --git a/pkg/saga/statemachine/store/db/statelog_test.go b/pkg/saga/statemachine/store/db/statelog_test.go index 437674765..fb15b8cb4 100644 --- a/pkg/saga/statemachine/store/db/statelog_test.go +++ b/pkg/saga/statemachine/store/db/statelog_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package db import ( diff --git a/pkg/saga/statemachine/store/repository/state_machine_repository.go b/pkg/saga/statemachine/store/repository/state_machine_repository.go index 8a62cc49f..ea37171b9 100644 --- a/pkg/saga/statemachine/store/repository/state_machine_repository.go +++ b/pkg/saga/statemachine/store/repository/state_machine_repository.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package repository import ( diff --git a/pkg/util/reflectx/unmarkshaler.go b/pkg/util/reflectx/unmarkshaler.go index 73acb2763..a507a3a89 100644 --- a/pkg/util/reflectx/unmarkshaler.go +++ b/pkg/util/reflectx/unmarkshaler.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package reflectx import ( From b2470014de035a9be23cfb4fea25a198b503784a Mon Sep 17 00:00:00 2001 From: FinnTew Date: Tue, 7 Jan 2025 14:37:57 +0800 Subject: [PATCH 11/11] update --- .../statemachine/engine/invoker/func_invoker.go | 17 +++++++++++++++++ .../engine/invoker/func_invoker_test.go | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/pkg/saga/statemachine/engine/invoker/func_invoker.go b/pkg/saga/statemachine/engine/invoker/func_invoker.go index 085decb88..3131c52e2 100644 --- a/pkg/saga/statemachine/engine/invoker/func_invoker.go +++ b/pkg/saga/statemachine/engine/invoker/func_invoker.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package invoker import ( diff --git a/pkg/saga/statemachine/engine/invoker/func_invoker_test.go b/pkg/saga/statemachine/engine/invoker/func_invoker_test.go index e800fdc13..9a97427b5 100644 --- a/pkg/saga/statemachine/engine/invoker/func_invoker_test.go +++ b/pkg/saga/statemachine/engine/invoker/func_invoker_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package invoker import (