Skip to content

Commit 90fdfc2

Browse files
robocanicCopilot
andauthored
feat: support memory type of store (#1332)
* feat: support memory type of store * fix: muilti indexes should use intersecection * simplify code Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * refractor: GetByKeys return a list instead of map --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 9729ec7 commit 90fdfc2

20 files changed

Lines changed: 1072 additions & 49 deletions

File tree

app/dubbo-admin/dubbo-admin.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ console:
3737
password: dubbo@2025
3838
expirationTime: 3600
3939
store:
40-
type: mysql
41-
address: xx
40+
type: memory
4241
discovery:
4342
- type: nacos
4443
id: nacos-44.33
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
package errors
18+
package bizerror
1919

2020
import (
2121
"errors"

pkg/console/handler/configurator_rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func ConfiguratorSearch(ctx consolectx.Context) gin.HandlerFunc {
4848
pageData, err = manager.PageListByIndexes[*meshresource.DynamicConfigResource](
4949
ctx.ResourceManager(),
5050
meshresource.DynamicConfigKind,
51-
map[string]interface{}{
51+
map[string]string{
5252
index.ByMeshIndex: req.Mesh,
5353
},
5454
req.PageReq,

pkg/console/handler/tag_rule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TagRuleSearch(ctx consolectx.Context) gin.HandlerFunc {
4949
pageData, err = manager.PageListByIndexes[*meshresource.TagRouteResource](
5050
ctx.ResourceManager(),
5151
meshresource.TagRouteKind,
52-
map[string]interface{}{
52+
map[string]string{
5353
index.ByMeshIndex: req.Mesh,
5454
},
5555
req.PageReq)

pkg/console/service/application.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func GetApplicationDetail(ctx consolectx.Context, req *model.ApplicationDetailRe
3535
instanceResources, err := manager.ListByIndexes[*meshresource.InstanceResource](
3636
ctx.ResourceManager(),
3737
meshresource.InstanceKind,
38-
map[string]interface{}{
38+
map[string]string{
3939
index.ByMeshIndex: req.Mesh,
4040
index.ByInstanceAppNameIndex: req.AppName,
4141
},
@@ -61,7 +61,7 @@ func GetAppInstanceInfo(ctx consolectx.Context, req *model.ApplicationTabInstanc
6161
pageData, err := manager.PageListByIndexes[*meshresource.InstanceResource](
6262
ctx.ResourceManager(),
6363
meshresource.InstanceKind,
64-
map[string]interface{}{
64+
map[string]string{
6565
index.ByMeshIndex: req.Mesh,
6666
index.ByInstanceAppNameIndex: req.AppName,
6767
},
@@ -117,7 +117,7 @@ func getAppProvideServiceInfo(ctx consolectx.Context, req *model.ApplicationServ
117117
pageData, err := manager.PageListByIndexes[*meshresource.ServiceProviderMetadataResource](
118118
ctx.ResourceManager(),
119119
meshresource.ServiceProviderMetadataKind,
120-
map[string]interface{}{
120+
map[string]string{
121121
index.ByMeshIndex: req.Mesh,
122122
index.ByServiceProviderAppName: req.AppName,
123123
},
@@ -160,7 +160,7 @@ func getAppConsumeServiceInfo(ctx consolectx.Context, req *model.ApplicationServ
160160
pageData, err := manager.PageListByIndexes[*meshresource.ServiceConsumerMetadataResource](
161161
ctx.ResourceManager(),
162162
meshresource.ServiceConsumerMetadataKind,
163-
map[string]interface{}{
163+
map[string]string{
164164
index.ByMeshIndex: req.Mesh,
165165
index.ByServiceConsumerAppName: req.AppName,
166166
},
@@ -239,7 +239,7 @@ func searchApplications(
239239
pageData, err = manager.PageListByIndexes[*meshresource.ApplicationResource](
240240
ctx.ResourceManager(),
241241
meshresource.ApplicationKind,
242-
map[string]interface{}{
242+
map[string]string{
243243
index.ByMeshIndex: mesh,
244244
},
245245
pageReq,

pkg/console/service/instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func SearchInstances(ctx consolectx.Context, req *model.SearchInstanceReq) (*mod
5353
pageData, err = manager.PageListByIndexes[*meshresource.InstanceResource](
5454
ctx.ResourceManager(),
5555
meshresource.InstanceKind,
56-
map[string]interface{}{
56+
map[string]string{
5757
index.ByMeshIndex: req.Mesh,
5858
},
5959
req.PageReq)

pkg/console/service/service.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func SearchServices(ctx consolectx.Context, req *model.ServiceSearchReq) (*model
4747
pageData, err = manager.PageListByIndexes[*meshresource.ServiceResource](
4848
ctx.ResourceManager(),
4949
meshresource.ServiceKind,
50-
map[string]interface{}{
50+
map[string]string{
5151
index.ByMeshIndex: req.Mesh,
5252
},
5353
req.PageReq,

pkg/core/bootstrap/bootstrap.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,8 @@ import (
2323
"github.com/pkg/errors"
2424

2525
"github.com/apache/dubbo-admin/pkg/config/app"
26-
_ "github.com/apache/dubbo-admin/pkg/console"
27-
_ "github.com/apache/dubbo-admin/pkg/core/discovery"
28-
_ "github.com/apache/dubbo-admin/pkg/core/engine"
29-
_ "github.com/apache/dubbo-admin/pkg/core/events"
3026
"github.com/apache/dubbo-admin/pkg/core/logger"
31-
_ "github.com/apache/dubbo-admin/pkg/core/manager"
3227
"github.com/apache/dubbo-admin/pkg/core/runtime"
33-
_ "github.com/apache/dubbo-admin/pkg/core/store"
3428
"github.com/apache/dubbo-admin/pkg/diagnostics"
3529
)
3630

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515
* limitations under the License.
1616
*/
1717

18-
package memory
18+
package bootstrap
1919

20-
import _ "k8s.io/client-go/tools/cache"
21-
22-
// TODO implement memory resource store, refer to client-go cache.Store
20+
import (
21+
_ "github.com/apache/dubbo-admin/pkg/console"
22+
_ "github.com/apache/dubbo-admin/pkg/core/discovery"
23+
_ "github.com/apache/dubbo-admin/pkg/core/engine"
24+
_ "github.com/apache/dubbo-admin/pkg/core/events"
25+
_ "github.com/apache/dubbo-admin/pkg/core/manager"
26+
_ "github.com/apache/dubbo-admin/pkg/core/store"
27+
_ "github.com/apache/dubbo-admin/pkg/store/memory"
28+
)

pkg/core/manager/manager.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ type ReadOnlyResourceManager interface {
2828
// GetByKey returns the resource with the given resource key
2929
GetByKey(rk model.ResourceKind, key string) (r model.Resource, exist bool, err error)
3030
// ListByIndexes returns the resources with the given indexes, indexes is a map of index name and index value
31-
ListByIndexes(rk model.ResourceKind, indexes map[string]interface{}) ([]model.Resource, error)
31+
ListByIndexes(rk model.ResourceKind, indexes map[string]string) ([]model.Resource, error)
3232
// PageListByIndexes page list the resources with the given indexes, indexes is a map of index name and index value
33-
PageListByIndexes(rk model.ResourceKind, indexes map[string]interface{}, pr model.PageReq) (*model.PageData[model.Resource], error)
33+
PageListByIndexes(rk model.ResourceKind, indexes map[string]string, pr model.PageReq) (*model.PageData[model.Resource], error)
3434
// PageSearchResourceByConditions page fuzzy search resource by conditions, conditions cannot be empty
3535
// TODO support multiple conditions
3636
PageSearchResourceByConditions(rk model.ResourceKind, conditions []string, pr model.PageReq) (*model.PageData[model.Resource], error)
@@ -74,7 +74,7 @@ func (rm *resourcesManager) GetByKey(rk model.ResourceKind, key string) (r model
7474
return item.(model.Resource), exist, err
7575
}
7676

77-
func (rm *resourcesManager) ListByIndexes(rk model.ResourceKind, indexes map[string]interface{}) ([]model.Resource, error) {
77+
func (rm *resourcesManager) ListByIndexes(rk model.ResourceKind, indexes map[string]string) ([]model.Resource, error) {
7878
rs, err := rm.StoreRouter.ResourceKindRoute(rk)
7979
if err != nil {
8080
return nil, err
@@ -88,7 +88,7 @@ func (rm *resourcesManager) ListByIndexes(rk model.ResourceKind, indexes map[str
8888

8989
func (rm *resourcesManager) PageListByIndexes(
9090
rk model.ResourceKind,
91-
indexes map[string]interface{},
91+
indexes map[string]string,
9292
pr model.PageReq) (*model.PageData[model.Resource], error) {
9393

9494
rs, err := rm.StoreRouter.ResourceKindRoute(rk)

0 commit comments

Comments
 (0)