forked from flyteorg/flyteplugins
/
client.go
45 lines (35 loc) · 1.17 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
package catalog
import (
"context"
"fmt"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core"
"github.com/lyft/flyteplugins/go/tasks/pluginmachinery/io"
)
//go:generate mockery -all -case=underscore
// Metadata to be associated with the catalog object
type Metadata struct {
WorkflowExecutionIdentifier *core.WorkflowExecutionIdentifier
NodeExecutionIdentifier *core.NodeExecutionIdentifier
TaskExecutionIdentifier *core.TaskExecutionIdentifier
}
// An identifier for a catalog object.
type Key struct {
Identifier core.Identifier
CacheVersion string
TypedInterface core.TypedInterface
InputReader io.InputReader
}
func (k Key) String() string {
return fmt.Sprintf("%v:%v", k.Identifier, k.CacheVersion)
}
// Default Catalog client that allows memoization and indexing of intermediate data in Flyte
type Client interface {
Get(ctx context.Context, key Key) (io.OutputReader, error)
Put(ctx context.Context, key Key, reader io.OutputReader, metadata Metadata) error
}
func IsNotFound(err error) bool {
taskStatus, ok := status.FromError(err)
return ok && taskStatus.Code() == codes.NotFound
}