This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
/
client.go
46 lines (38 loc) · 1.57 KB
/
client.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
package recovery
import (
"context"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/service"
)
//go:generate mockery -name Client -output=mocks -case=underscore
type Client interface {
RecoverNodeExecution(ctx context.Context, execID *core.WorkflowExecutionIdentifier, id *core.NodeExecutionIdentifier) (*admin.NodeExecution, error)
RecoverNodeExecutionData(ctx context.Context, execID *core.WorkflowExecutionIdentifier, id *core.NodeExecutionIdentifier) (*admin.NodeExecutionGetDataResponse, error)
}
type recoveryClient struct {
adminClient service.AdminServiceClient
}
func (c *recoveryClient) RecoverNodeExecution(ctx context.Context, execID *core.WorkflowExecutionIdentifier, nodeID *core.NodeExecutionIdentifier) (*admin.NodeExecution, error) {
origNodeID := &core.NodeExecutionIdentifier{
ExecutionId: execID,
NodeId: nodeID.NodeId,
}
return c.adminClient.GetNodeExecution(ctx, &admin.NodeExecutionGetRequest{
Id: origNodeID,
})
}
func (c *recoveryClient) RecoverNodeExecutionData(ctx context.Context, execID *core.WorkflowExecutionIdentifier, nodeID *core.NodeExecutionIdentifier) (*admin.NodeExecutionGetDataResponse, error) {
origNodeID := &core.NodeExecutionIdentifier{
ExecutionId: execID,
NodeId: nodeID.NodeId,
}
return c.adminClient.GetNodeExecutionData(ctx, &admin.NodeExecutionGetDataRequest{
Id: origNodeID,
})
}
func NewClient(adminClient service.AdminServiceClient) Client {
return &recoveryClient{
adminClient: adminClient,
}
}