-
Notifications
You must be signed in to change notification settings - Fork 16
Features register #19
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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
e4a388e
95055e8
b8f946a
97a7ac4
404c8df
e02c95c
09031eb
e4cd5ec
fca98ea
3190310
28ab6e2
9577254
840c7ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,38 +49,38 @@ const ( | |
| InstancePoolTypeNacos int8 = 2 | ||
| ) | ||
|
|
||
| type InstancePoolStorager interface { | ||
| type InstancePoolStorage interface { | ||
| UpdateInstances(context.Context, *Pool, *InstancePool) error | ||
|
|
||
| BatchFetchInstances(context.Context, []*Pool) (map[string]*InstancePool, error) | ||
| } | ||
|
|
||
| type InstancePoolManager struct { | ||
| instancePoolStorages map[int8]InstancePoolStorager | ||
| instancePoolStorages map[int8]InstancePoolStorage | ||
| } | ||
|
|
||
| func NewInstancePoolManager(instancePoolStorages map[int8]InstancePoolStorager) *InstancePoolManager { | ||
| func NewInstancePoolManager(instancePoolStorages map[int8]InstancePoolStorage) *InstancePoolManager { | ||
| return &InstancePoolManager{ | ||
| instancePoolStorages: instancePoolStorages, | ||
| } | ||
| } | ||
|
|
||
| func (pim *InstancePoolManager) BatchFetchInstances(ctx context.Context, pools []*Pool) (map[string]*InstancePool, error) { | ||
| type2InstancePoolList := map[int8][]*Pool{} | ||
| func (m *InstancePoolManager) BatchFetchInstances(ctx context.Context, pools []*Pool) (map[string]*InstancePool, error) { | ||
| type2PoolList := map[int8][]*Pool{} | ||
| for _, one := range pools { | ||
| type2InstancePoolList[one.Type] = append(type2InstancePoolList[one.Type], one) | ||
| type2PoolList[one.Type] = append(type2PoolList[one.Type], one) | ||
| } | ||
|
|
||
| for typ := range type2InstancePoolList { | ||
| _, ok := pim.instancePoolStorages[typ] | ||
| for type2 := range type2PoolList { | ||
|
Member
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. type2 => type? |
||
| _, ok := m.instancePoolStorages[type2] | ||
| if !ok { | ||
| return nil, xerror.WrapModelErrorWithMsg("Type %d not register Storager", typ) | ||
| return nil, xerror.WrapModelErrorWithMsg("Type %d not register Storager", type2) | ||
| } | ||
| } | ||
|
|
||
| rst := map[string]*InstancePool{} | ||
| for typ, pisList := range type2InstancePoolList { | ||
| storager := pim.instancePoolStorages[typ] | ||
| for type2, pisList := range type2PoolList { | ||
|
Member
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. 同line 74 |
||
| storager := m.instancePoolStorages[type2] | ||
|
Member
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. storager => storage |
||
| r, err := storager.BatchFetchInstances(ctx, pisList) | ||
| if err != nil { | ||
| return nil, err | ||
|
|
@@ -94,8 +94,8 @@ func (pim *InstancePoolManager) BatchFetchInstances(ctx context.Context, pools [ | |
| return rst, nil | ||
| } | ||
|
|
||
| func (pim *InstancePoolManager) UpdateInstances(ctx context.Context, pool *Pool, pis *InstancePool) error { | ||
| storager, ok := pim.instancePoolStorages[pool.Type] | ||
| func (m *InstancePoolManager) UpdateInstances(ctx context.Context, pool *Pool, pis *InstancePool) error { | ||
|
Member
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. pis => iPool |
||
| storager, ok := m.instancePoolStorages[pool.Type] | ||
| if !ok { | ||
| return xerror.WrapModelErrorWithMsg("Type %d not register Storager", pool.Type) | ||
| } | ||
|
|
||
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.
piMap => poolMap