Skip to content

Commit

Permalink
feat: add manager client list scheduler interface (#694)
Browse files Browse the repository at this point in the history
* feat: add manager client list scheduler interface

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Sep 28, 2021
1 parent 7dbb9ee commit e9fdf71
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
33 changes: 26 additions & 7 deletions pkg/rpc/manager/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,23 @@ const (
)

type Client interface {
Close() error
// Get Scheduler and Scheduler cluster configuration
GetScheduler(*manager.GetSchedulerRequest) (*manager.Scheduler, error)

// Update scheduler configuration
UpdateScheduler(*manager.UpdateSchedulerRequest) (*manager.Scheduler, error)

// Update CDN configuration
UpdateCDN(*manager.UpdateCDNRequest) (*manager.CDN, error)

// List acitve schedulers configuration
ListSchedulers(*manager.ListSchedulersRequest) (*manager.ListSchedulersResponse, error)

// KeepAlive with manager
KeepAlive(time.Duration, *manager.KeepAliveRequest)

// Close client connect
Close() error
}

type client struct {
Expand Down Expand Up @@ -79,25 +91,32 @@ func New(target string) (Client, error) {
}, nil
}

func (c *client) GetScheduler(scheduler *manager.GetSchedulerRequest) (*manager.Scheduler, error) {
func (c *client) GetScheduler(req *manager.GetSchedulerRequest) (*manager.Scheduler, error) {
ctx, cancel := context.WithTimeout(context.Background(), contextTimeout)
defer cancel()

return c.ManagerClient.GetScheduler(ctx, req)
}

func (c *client) UpdateScheduler(req *manager.UpdateSchedulerRequest) (*manager.Scheduler, error) {
ctx, cancel := context.WithTimeout(context.Background(), contextTimeout)
defer cancel()

return c.ManagerClient.GetScheduler(ctx, scheduler)
return c.ManagerClient.UpdateScheduler(ctx, req)
}

func (c *client) UpdateScheduler(scheduler *manager.UpdateSchedulerRequest) (*manager.Scheduler, error) {
func (c *client) UpdateCDN(req *manager.UpdateCDNRequest) (*manager.CDN, error) {
ctx, cancel := context.WithTimeout(context.Background(), contextTimeout)
defer cancel()

return c.ManagerClient.UpdateScheduler(ctx, scheduler)
return c.ManagerClient.UpdateCDN(ctx, req)
}

func (c *client) UpdateCDN(cdn *manager.UpdateCDNRequest) (*manager.CDN, error) {
func (c *client) ListSchedulers(req *manager.ListSchedulersRequest) (*manager.ListSchedulersResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), contextTimeout)
defer cancel()

return c.ManagerClient.UpdateCDN(ctx, cdn)
return c.ManagerClient.ListSchedulers(ctx, req)
}

func (c *client) KeepAlive(interval time.Duration, keepalive *manager.KeepAliveRequest) {
Expand Down
15 changes: 15 additions & 0 deletions scheduler/config/mocks/manager_client_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e9fdf71

Please sign in to comment.