-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathplacement_group_service.go
86 lines (66 loc) · 2.09 KB
/
placement_group_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package facade
import (
"context"
disk_manager "github.com/ydb-platform/nbs/cloud/disk_manager/api"
"github.com/ydb-platform/nbs/cloud/disk_manager/internal/pkg/services/placementgroup"
"github.com/ydb-platform/nbs/cloud/tasks"
"google.golang.org/grpc"
)
////////////////////////////////////////////////////////////////////////////////
type placementGroupService struct {
taskScheduler tasks.Scheduler
service placementgroup.Service
}
func (s *placementGroupService) Create(
ctx context.Context,
req *disk_manager.CreatePlacementGroupRequest,
) (*disk_manager.Operation, error) {
taskID, err := s.service.CreatePlacementGroup(ctx, req)
if err != nil {
return nil, err
}
return getOperation(ctx, s.taskScheduler, taskID)
}
func (s *placementGroupService) Delete(
ctx context.Context,
req *disk_manager.DeletePlacementGroupRequest,
) (*disk_manager.Operation, error) {
taskID, err := s.service.DeletePlacementGroup(ctx, req)
if err != nil {
return nil, err
}
return getOperation(ctx, s.taskScheduler, taskID)
}
func (s *placementGroupService) Alter(
ctx context.Context,
req *disk_manager.AlterPlacementGroupMembershipRequest,
) (*disk_manager.Operation, error) {
taskID, err := s.service.AlterPlacementGroupMembership(ctx, req)
if err != nil {
return nil, err
}
return getOperation(ctx, s.taskScheduler, taskID)
}
func (s *placementGroupService) List(
ctx context.Context,
req *disk_manager.ListPlacementGroupsRequest,
) (*disk_manager.ListPlacementGroupsResponse, error) {
return s.service.ListPlacementGroups(ctx, req)
}
func (s *placementGroupService) Describe(
ctx context.Context,
req *disk_manager.DescribePlacementGroupRequest,
) (*disk_manager.PlacementGroup, error) {
return s.service.DescribePlacementGroup(ctx, req)
}
////////////////////////////////////////////////////////////////////////////////
func RegisterPlacementGroupService(
server *grpc.Server,
taskScheduler tasks.Scheduler,
service placementgroup.Service,
) {
disk_manager.RegisterPlacementGroupServiceServer(server, &placementGroupService{
taskScheduler: taskScheduler,
service: service,
})
}