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

refactor: separate deployer into serval api and implement query and scale #165

Merged
merged 6 commits into from
Oct 19, 2023

Conversation

shawnh2
Copy link
Contributor

@shawnh2 shawnh2 commented Oct 10, 2023

related to #160

in the following PR, the pkg/cmd, pkg/deployer, pkg/connector shall be removed or rewrote.

…cale

Signed-off-by: sh2 <shawnhxh@outlook.com>
Signed-off-by: sh2 <shawnhxh@outlook.com>
Signed-off-by: sh2 <shawnhxh@outlook.com>
@codecov-commenter
Copy link

codecov-commenter commented Oct 10, 2023

Codecov Report

Attention: 193 lines in your changes are missing coverage. Please review.

Comparison is base (c64a3c2) 35.80% compared to head (ab1d381) 34.29%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #165      +/-   ##
===========================================
- Coverage    35.80%   34.29%   -1.51%     
===========================================
  Files           12       16       +4     
  Lines         1430     1522      +92     
===========================================
+ Hits           512      522      +10     
- Misses         814      893      +79     
- Partials       104      107       +3     
Files Coverage Δ
pkg/cluster/baremetal/validate.go 84.21% <84.21%> (ø)
pkg/cluster/baremetal/not_implemented.go 0.00% <0.00%> (ø)
pkg/cluster/baremetal/config.go 0.00% <0.00%> (ø)
pkg/cluster/baremetal/cluster.go 0.00% <0.00%> (ø)
pkg/cluster/baremetal/get.go 12.87% <12.87%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: sh2 <shawnhxh@outlook.com>
@zyy17
Copy link
Collaborator

zyy17 commented Oct 11, 2023

What a big PR #_#, let me slow down and have a look.

@zyy17
Copy link
Collaborator

zyy17 commented Oct 16, 2023

I have another abstraction design as the following structs that can be more clean:

type Cluster struct { ... }

type ClusterOperation interface {
    Create(ctx context.Context, name string, options *CreateOptions) error
    Get(ctx context.Context, name string, options *GetOptions) (*Cluster, error)
    List(ctx context.Context, options *ListOptions) ([]*Cluster, error)
    Update(ctx context.Context, options *UpdateOptions)
    Connect(ctx context.Context, options *ConnectOptions)
}

We can implement the K8s and bare-metal clusteroption and provide the factory method. For K8s mode, the creation of an etcd cluster and operator can be hidden in Create().

For this PR, IMHO:

  1. pkg/api: I think it's better to maintain in pkg/cluster. api is more like the interface for cli users. But in this scenario, it's the apis for internal usage.
  2. pkg/api/scale and pkg/api/query: maybe the two apis are too small, and it's unnecessary to split them from the parent interface. Keep in one interface will be clean;

@shawnh2
Copy link
Contributor Author

shawnh2 commented Oct 17, 2023

I have another abstraction design as the following structs that can be more clean:

type Cluster struct { ... }

type ClusterOperation interface {
    Create(ctx context.Context, name string, options *CreateOptions) error
    Get(ctx context.Context, name string, options *GetOptions) (*Cluster, error)
    List(ctx context.Context, options *ListOptions) ([]*Cluster, error)
    Update(ctx context.Context, options *UpdateOptions)
    Connect(ctx context.Context, options *ConnectOptions)
}

We can implement the K8s and bare-metal clusteroption and provide the factory method. For K8s mode, the creation of an etcd cluster and operator can be hidden in Create().

For this PR, IMHO:

  1. pkg/api: I think it's better to maintain in pkg/cluster. api is more like the interface for cli users. But in this scenario, it's the apis for internal usage.
  2. pkg/api/scale and pkg/api/query: maybe the two apis are too small, and it's unnecessary to split them from the parent interface. Keep in one interface will be clean;

great idea, made some changes, PTAL @zyy17

Copy link
Collaborator

@zyy17 zyy17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zyy17 zyy17 merged commit 3e1de26 into GreptimeTeam:develop Oct 19, 2023
6 checks passed
@shawnh2 shawnh2 deleted the refactor/change-uix-api branch October 20, 2023 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants