Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:add RemoveResourceNodes #568

Open
wants to merge 1 commit into
base: mosn-customized
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/stat/node_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ func GetResourceNode(resource string) *ResourceNode {
return resNodeMap[resource]
}

func RemoveResourceNodes(resources []string) {
if len(resources) == 0 {
return
}
rnsMux.Lock()
defer rnsMux.Unlock()
for _, resource := range resources {
delete(resNodeMap, resource)
}
}

func GetOrCreateResourceNode(resource string, resourceType base.ResourceType) *ResourceNode {
node := GetResourceNode(resource)
if node != nil {
Expand Down
29 changes: 29 additions & 0 deletions core/stat/node_storage_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package stat

import "testing"

func TestRemoveResourceNodes(t *testing.T) {
type args struct {
resources []string
}
tests := []struct {
name string
args args
}{
{
name: "empty",
args: args{},
},
{
name: "normal",
args: args{
resources: []string{"test"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RemoveResourceNodes(tt.args.resources)
})
}
}
Loading