Skip to content

Commit 9c6762b

Browse files
committed
optimize clb binding performance
Signed-off-by: roc <[email protected]>
1 parent 84c2ef9 commit 9c6762b

File tree

6 files changed

+196
-148
lines changed

6 files changed

+196
-148
lines changed

internal/clbbinding/clbbinding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type CLBBinding interface {
1515
GetAssociatedObject(context.Context, client.Client) (Backend, error)
1616
GetObject() client.Object
1717
GetType() string
18-
GetNewest(context.Context, client.Client) (CLBBinding, error)
18+
FetchObject(context.Context, client.Client) (client.Object, error)
1919
}
2020

2121
type Backend interface {

internal/clbbinding/clbnodebinding.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ func (b *CLBNodeBinding) GetType() string {
4343
return "CLBNodeBinding"
4444
}
4545

46-
func (b *CLBNodeBinding) GetNewest(ctx context.Context, c client.Client) (CLBBinding, error) {
46+
func (b *CLBNodeBinding) FetchObject(ctx context.Context, c client.Client) (client.Object, error) {
4747
nbd := &networkingv1alpha1.CLBNodeBinding{}
48-
err := c.Get(ctx, client.ObjectKeyFromObject(b), nbd)
48+
err := c.Get(ctx, client.ObjectKeyFromObject(b.CLBNodeBinding), nbd)
4949
if err == nil {
5050
b.CLBNodeBinding = nbd
51+
return nbd, nil
52+
} else {
53+
return nil, errors.WithStack(err)
5154
}
52-
return WrapCLBNodeBinding(nbd), err
5355
}
5456

5557
type nodeBackend struct {

internal/clbbinding/clbpodbinding.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ func (b *CLBPodBinding) GetType() string {
4343
return "CLBPodBinding"
4444
}
4545

46-
func (b *CLBPodBinding) GetNewest(ctx context.Context, c client.Client) (CLBBinding, error) {
47-
pb := &networkingv1alpha1.CLBPodBinding{}
48-
err := c.Get(ctx, client.ObjectKeyFromObject(b), pb)
46+
func (b *CLBPodBinding) FetchObject(ctx context.Context, c client.Client) (client.Object, error) {
47+
cpb := &networkingv1alpha1.CLBPodBinding{}
48+
err := c.Get(ctx, client.ObjectKeyFromObject(b.CLBPodBinding), cpb)
4949
if err == nil {
50-
b.CLBPodBinding = pb
50+
b.CLBPodBinding = cpb
51+
return cpb, nil
52+
} else {
53+
return nil, errors.WithStack(err)
5154
}
52-
return WrapCLBPodBinding(pb), err
5355
}
5456

5557
type podBackend struct {

0 commit comments

Comments
 (0)