flypiggyyoyoyo commented on code in PR #805: URL: https://github.com/apache/incubator-seata-go/pull/805#discussion_r2061976674
########## pkg/saga/statemachine/engine/core/default_statemachine_config.go: ########## @@ -191,70 +201,209 @@ func (c *DefaultStateMachineConfig) ScriptInvokerManager() invoker.ScriptInvoker } func (c *DefaultStateMachineConfig) CharSet() string { - return c.charset + return c.Charset } func (c *DefaultStateMachineConfig) SetCharSet(charset string) { - c.charset = charset + c.Charset = charset } -func (c *DefaultStateMachineConfig) DefaultTenantId() string { - return c.defaultTenantId +func (c *DefaultStateMachineConfig) GetDefaultTenantId() string { + return c.DefaultTenantId } -func (c *DefaultStateMachineConfig) TransOperationTimeout() int { - return c.transOperationTimeout +func (c *DefaultStateMachineConfig) GetTransOperationTimeout() int { + return c.TransOperationTimeout } -func (c *DefaultStateMachineConfig) ServiceInvokeTimeout() int { - return c.serviceInvokeTimeout +func (c *DefaultStateMachineConfig) GetServiceInvokeTimeout() int { + return c.ServiceInvokeTimeout } func (c *DefaultStateMachineConfig) IsSagaRetryPersistModeUpdate() bool { - return c.sagaRetryPersistModeUpdate + return c.SagaRetryPersistModeUpdate } func (c *DefaultStateMachineConfig) SetSagaRetryPersistModeUpdate(sagaRetryPersistModeUpdate bool) { - c.sagaRetryPersistModeUpdate = sagaRetryPersistModeUpdate + c.SagaRetryPersistModeUpdate = sagaRetryPersistModeUpdate } func (c *DefaultStateMachineConfig) IsSagaCompensatePersistModeUpdate() bool { - return c.sagaCompensatePersistModeUpdate + return c.SagaCompensatePersistModeUpdate } func (c *DefaultStateMachineConfig) SetSagaCompensatePersistModeUpdate(sagaCompensatePersistModeUpdate bool) { - c.sagaCompensatePersistModeUpdate = sagaCompensatePersistModeUpdate + c.SagaCompensatePersistModeUpdate = sagaCompensatePersistModeUpdate } func (c *DefaultStateMachineConfig) IsSagaBranchRegisterEnable() bool { - return c.sagaBranchRegisterEnable + return c.SagaBranchRegisterEnable } func (c *DefaultStateMachineConfig) SetSagaBranchRegisterEnable(sagaBranchRegisterEnable bool) { - c.sagaBranchRegisterEnable = sagaBranchRegisterEnable + c.SagaBranchRegisterEnable = sagaBranchRegisterEnable } func (c *DefaultStateMachineConfig) IsRmReportSuccessEnable() bool { - return c.rmReportSuccessEnable + return c.RmReportSuccessEnable } func (c *DefaultStateMachineConfig) SetRmReportSuccessEnable(rmReportSuccessEnable bool) { - c.rmReportSuccessEnable = rmReportSuccessEnable + c.RmReportSuccessEnable = rmReportSuccessEnable +} + +func (c *DefaultStateMachineConfig) GetStateMachineDefinition(name string) *statemachine.StateMachineObject { + return c.stateMachineDefs[name] +} + +func (c *DefaultStateMachineConfig) GetExpressionFactory(expressionType string) expr.ExpressionFactory { + return c.expressionFactoryManager.GetExpressionFactory(expressionType) +} + +func (c *DefaultStateMachineConfig) GetServiceInvoker(serviceType string) invoker.ServiceInvoker { + return c.serviceInvokerManager.ServiceInvoker(serviceType) +} + +func (c *DefaultStateMachineConfig) RegisterStateMachineDef(resources []string) error { + for _, resourcePath := range resources { + file, err := os.Open(resourcePath) + if err != nil { + return fmt.Errorf("open resource file failed: path=%s, err=%w", resourcePath, err) + } + defer file.Close() + + if err := c.stateMachineRepository.RegistryStateMachineByReader(file); err != nil { + return fmt.Errorf("register state machine from file failed: path=%s, err=%w", resourcePath, err) + } + } + return nil +} + +func (c *DefaultStateMachineConfig) RegisterExpressionFactory(expressionType string, factory expr.ExpressionFactory) { + c.expressionFactoryManager.PutExpressionFactory(expressionType, factory) +} + +func (c *DefaultStateMachineConfig) RegisterServiceInvoker(serviceType string, invoker invoker.ServiceInvoker) { + c.serviceInvokerManager.PutServiceInvoker(serviceType, invoker) +} + +type RuntimeConfig struct { Review Comment: Received all comments above. The modification has been committed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org