Skip to content

Commit

Permalink
Merge pull request #5 from lyft/datacatalog-cache
Browse files Browse the repository at this point in the history
Datacatalog cache
  • Loading branch information
chanadian authored Sep 11, 2019
2 parents 8de0681 + 4366de7 commit 2a9e28f
Show file tree
Hide file tree
Showing 16 changed files with 1,270 additions and 82 deletions.
14 changes: 14 additions & 0 deletions Gopkg.lock

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

5 changes: 5 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ required = [
source = "https://github.com/lyft/flyteidl"
version = "^0.14.x"

[[constraint]]
name = "github.com/lyft/datacatalog"
source = "https://github.com/lyft/datacatalog"
version = "^0.1.x"

[[constraint]]
name = "github.com/lyft/flyteplugins"
source = "https://github.com/lyft/flyteplugins"
Expand Down
4 changes: 4 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ event:
admin:
endpoint: localhost:8089
insecure: true
catalog-cache:
type: catalog
endpoint: datacatalog:8089
insecure: true
errors:
show-source: true
logger:
Expand Down
20 changes: 16 additions & 4 deletions pkg/controller/catalog/catalog_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package catalog
import (
"context"

"fmt"

"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core"
"github.com/lyft/flytepropeller/pkg/controller/catalog/datacatalog"
"github.com/lyft/flytestdlib/logger"
"github.com/lyft/flytestdlib/storage"
)
Expand All @@ -13,16 +16,25 @@ type Client interface {
Put(ctx context.Context, task *core.TaskTemplate, execID *core.TaskExecutionIdentifier, inputPath storage.DataReference, outputPath storage.DataReference) error
}

func NewCatalogClient(store storage.ProtobufStore) Client {
func NewCatalogClient(ctx context.Context, store storage.ProtobufStore) (Client, error) {
catalogConfig := GetConfig()

var catalogClient Client
if catalogConfig.Type == LegacyDiscoveryType {
var err error
switch catalogConfig.Type {
case LegacyDiscoveryType:
catalogClient = NewLegacyDiscovery(catalogConfig.Endpoint, store)
} else if catalogConfig.Type == NoOpDiscoveryType {
case DataCatalogType:
catalogClient, err = datacatalog.NewDataCatalog(ctx, catalogConfig.Endpoint, catalogConfig.Insecure, store)
if err != nil {
return nil, err
}
case NoOpDiscoveryType, "":
catalogClient = NewNoOpDiscovery()
default:
return nil, fmt.Errorf("No such catalog type available: %v", catalogConfig.Type)
}

logger.Infof(context.Background(), "Created Catalog client, type: %v", catalogConfig.Type)
return catalogClient
return catalogClient, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ type DiscoveryType = string
const (
NoOpDiscoveryType DiscoveryType = "noop"
LegacyDiscoveryType DiscoveryType = "legacy"
DataCatalogType DiscoveryType = "datacatalog"
)

type Config struct {
Type DiscoveryType `json:"type" pflag:"\"noop\",Discovery Implementation to use"`
Endpoint string `json:"endpoint" pflag:"\"\", Endpoint for discovery service"`
Type DiscoveryType `json:"type" pflag:"\"noop\", Catalog Implementation to use"`
Endpoint string `json:"endpoint" pflag:"\"\", Endpoint for catalog service"`
Insecure bool `json:"insecure" pflag:"false, Use insecure grpc connection"`
}

// Gets loaded config for Discovery
Expand Down
38 changes: 6 additions & 32 deletions pkg/controller/catalog/config_flags.go

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

46 changes: 26 additions & 20 deletions pkg/controller/catalog/config_flags_test.go

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

Loading

0 comments on commit 2a9e28f

Please sign in to comment.