flypiggyyoyoyo commented on code in PR #868:
URL: 
https://github.com/apache/incubator-seata-go/pull/868#discussion_r2263541964


##########
pkg/saga/statemachine/engine/invoker/javascript_script_invoker.go:
##########
@@ -0,0 +1,108 @@
+/*
+ * 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 (
+       "context"
+       "fmt"
+       "sync"
+
+       "github.com/robertkrimen/otto"
+)
+
+type JavaScriptScriptInvoker struct {
+       mutex      sync.Mutex
+       jsonParser JsonParser
+       closed     bool
+}
+
+func NewJavaScriptScriptInvoker() *JavaScriptScriptInvoker {
+       return &JavaScriptScriptInvoker{
+               jsonParser: &DefaultJsonParser{},
+               closed:     false,
+       }
+}
+
+func (j *JavaScriptScriptInvoker) Type() string {
+       return "javascript"
+}
+
+func (j *JavaScriptScriptInvoker) Invoke(ctx context.Context, script string, 
params map[string]interface{}) (interface{}, error) {
+       j.mutex.Lock()
+       defer j.mutex.Unlock()
+
+       if j.closed {
+               return nil, fmt.Errorf("javascript invoker has been closed")
+       }
+
+       vm := otto.New()

Review Comment:
   In the current implementation, the use of Type.MethodByName ensures that the 
obtained method is definitely an instance method, which necessarily includes a 
receiver. However, this modification can serve as a robustness enhancement, and 
I will make the change and submit it.



-- 
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

Reply via email to