-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : add script routing functionality #2669
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2b10398
add jsScript Instance test
5a2694c
impl script half logic
5f9440c
add license
19215b4
add script-router process logic
bdb9f15
fix ci
d1f5571
Merge branch 'apache:main' into main2
YarBor 927b76a
add package path to imports/import
4f6c5d9
The basic filtering function of invoker has been tested and completed.
0fcf224
package inputed Invoker, to make script operate url safly
99752ef
set panic safy
7ea5367
add more test case, remove unuse field,struct,interface
27d0d0a
fix CI, golangci-lint
2b5d48f
fix Config Update, make enable field useful
fa480e9
remove extra comment
c17eb4a
reformat imports
5c7b696
Rewrite the monitoring logic and modify the rules of get script insta…
17f951a
rewrite comment, fix ci-lint
5bb551d
make nacosDynamicConfiguration support multiple listeners
c9328e1
fix comment
26ca110
update scriptRouter recycle logic
a650f8a
fix misspell
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
package inputed Invoker, to make script operate url safly
Signed-off-by: YarBor <yarbor.ww@gmail.com>
- Loading branch information
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,18 +88,26 @@ type jsInstance struct { | |
|
||
func (i *jsInstances) RunScript(_ string, invokers []protocol.Invoker, invocation protocol.Invocation) ([]protocol.Invoker, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 改成 Run |
||
pg := i.program.Load() | ||
if pg == nil { | ||
if pg == nil || len(invokers) == 0 { | ||
return invokers, nil | ||
} | ||
matcher := i.insPool.Get().(*jsInstance) | ||
matcher.initCallArgs(invokers, invocation) | ||
|
||
packInvokers := make([]protocol.Invoker, 0, len(invokers)) | ||
for _, invoker := range invokers { | ||
packInvokers = append(packInvokers, newScriptInvokerImpl(invoker)) | ||
} | ||
|
||
matcher.initCallArgs(packInvokers, invocation) | ||
matcher.initReplyVar() | ||
scriptRes, err := matcher.runScript(i.program.Load()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
result := make([]protocol.Invoker, 0, len(scriptRes.(*goja.Object).Export().([]interface{}))) | ||
for _, res := range scriptRes.(*goja.Object).Export().([]interface{}) { | ||
res.(*scriptInvokerPackImpl).setRanMode() | ||
result = append(result, res.(protocol.Invoker)) | ||
} | ||
return result, nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reformat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what the problem is, I ran go fmt and it doesn't work, looks the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go fmt will not change the order of the import, it will only format locks and spaces. You can use goimports instead,https://pkg.go.dev/golang.org/x/tools/cmd/goimports
Generally speaking, the standard import format is:
import (
go standard packages (sorted alphabetically)
(space)
Three-party packages (sorted alphabetically)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们 dubbogo 有自己的 import format 工具 https://github.com/dubbogo/tools/tree/master/cmd/imports-formatter
编译出二进制,在项目根目录下执行一次,就可以 format 整个工程的 import 顺序。比你们找的这个工具高级多了。
用好前人积累的工具。