Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit ded77ff

Browse files
author
Nick Müller
committed
Migrated CatalogClient from propeller to stdlib
Implemented new datacatalog functionality required for cache eviction Updated to latest unreleased version of flyteidl and flyteplugins Signed-off-by: Nick Müller <[email protected]>
1 parent 1736864 commit ded77ff

File tree

11 files changed

+3588
-34
lines changed

11 files changed

+3588
-34
lines changed

catalog/client.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package catalog
2+
3+
import (
4+
"context"
5+
"fmt"
6+
7+
"google.golang.org/grpc"
8+
9+
pluginCatalog "github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/catalog"
10+
"github.com/flyteorg/flytestdlib/catalog/datacatalog"
11+
)
12+
13+
func NewClient(ctx context.Context, authOpt ...grpc.DialOption) (pluginCatalog.Client, error) {
14+
catalogConfig := GetConfig()
15+
16+
switch catalogConfig.Type {
17+
case TypeDataCatalog:
18+
return datacatalog.NewDataCatalog(ctx, catalogConfig.Endpoint, catalogConfig.Insecure,
19+
catalogConfig.MaxCacheAge.Duration, catalogConfig.UseAdminAuth, catalogConfig.DefaultServiceConfig,
20+
authOpt...)
21+
case TypeNoOp, "":
22+
return NOOPCatalog{}, nil
23+
}
24+
25+
return nil, fmt.Errorf("invalid catalog type %q", catalogConfig.Type)
26+
}

catalog/config.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package catalog
2+
3+
import (
4+
"github.com/flyteorg/flytestdlib/config"
5+
)
6+
7+
//go:generate pflags Config --default-var defaultConfig
8+
9+
const ConfigSectionKey = "catalog-cache"
10+
11+
var (
12+
defaultConfig = &Config{
13+
Type: TypeNoOp,
14+
}
15+
16+
configSection = config.MustRegisterSection(ConfigSectionKey, defaultConfig)
17+
)
18+
19+
type Type = string
20+
21+
const (
22+
TypeNoOp Type = "noop"
23+
TypeDataCatalog Type = "datacatalog"
24+
)
25+
26+
type Config struct {
27+
Type Type `json:"type" pflag:"\"noop\", Catalog Implementation to use"`
28+
Endpoint string `json:"endpoint" pflag:"\"\", Endpoint for catalog service"`
29+
Insecure bool `json:"insecure" pflag:"false, Use insecure grpc connection"`
30+
MaxCacheAge config.Duration `json:"max-cache-age" pflag:", Cache entries past this age will incur cache miss. 0 means cache never expires"`
31+
UseAdminAuth bool `json:"use-admin-auth" pflag:"false, Use the same gRPC credentials option as the flyteadmin client"`
32+
33+
// Set the gRPC service config formatted as a json string https://github.com/grpc/grpc/blob/master/doc/service_config.md
34+
// eg. {"loadBalancingConfig": [{"round_robin":{}}], "methodConfig": [{"name":[{"service": "foo", "method": "bar"}, {"service": "baz"}], "timeout": "1.000000001s"}]}
35+
// find the full schema here https://github.com/grpc/grpc-proto/blob/master/grpc/service_config/service_config.proto#L625
36+
// Note that required packages may need to be preloaded to support certain service config. For example "google.golang.org/grpc/balancer/roundrobin" should be preloaded to have round-robin policy supported.
37+
DefaultServiceConfig string `json:"default-service-config" pflag:"\"\", Set the default service config for the catalog gRPC client"`
38+
}
39+
40+
// GetConfig returns the parsed Catalog configuration
41+
func GetConfig() *Config {
42+
return configSection.GetConfig().(*Config)
43+
}

catalog/config_flags.go

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

catalog/config_flags_test.go

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)