Skip to content

Commit

Permalink
feat(lineage): fetch lineage with level and direction (#157)
Browse files Browse the repository at this point in the history
* feat(lineage): fetch lineage with level and direction

* fix: test name not capitalised
  • Loading branch information
StewartJingga authored Jul 12, 2022
1 parent e352553 commit ebbabe7
Show file tree
Hide file tree
Showing 17 changed files with 1,559 additions and 1,342 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NAME="github.com/odpf/compass"
VERSION=$(shell git describe --always --tags 2>/dev/null)
COVERFILE="/tmp/compass.coverprofile"
PROTON_COMMIT := "a5cae3d372dc9741659b19f20a203b9278431356"
PROTON_COMMIT := "9eaca223dfd5ca0297abdb593fa73e8522d8ef62"
.PHONY: all build test clean install proto

all: build
Expand Down Expand Up @@ -50,4 +50,4 @@ install: ## install required dependencies
go install github.com/envoyproxy/[email protected]

update-swagger-md:
npx swagger-markdown -i third_party/OpenAPI/compass.swagger.yaml -o docs/reference/api.md
npx swagger-markdown -i third_party/OpenAPI/compass.swagger.yaml -o docs/docs/reference/api.md
2,368 changes: 1,195 additions & 1,173 deletions api/proto/odpf/compass/v1beta1/service.pb.go

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions api/proto/odpf/compass/v1beta1/service.pb.gw.go

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

19 changes: 19 additions & 0 deletions api/proto/odpf/compass/v1beta1/service.pb.validate.go

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

25 changes: 23 additions & 2 deletions core/asset/lineage.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@ import (
"context"
)

//go:generate mockery --name=LineageRepository -r --case underscore --with-expecter --structname LineageRepository --filename lineage_repository.go --output=./mocks
type LineageDirection string

func (dir LineageDirection) IsValid() bool {
switch dir {
case LineageDirectionUpstream, LineageDirectionDownstream, "":
return true
default:
return false
}
}

const (
LineageDirectionUpstream LineageDirection = "upstream"
LineageDirectionDownstream LineageDirection = "downstream"
)

type LineageQuery struct {
Level int
Direction LineageDirection
}

//go:generate mockery --name=LineageRepository -r --case underscore --with-expecter --structname=LineageRepository --filename=lineage_repository.go --output=./mocks
type LineageRepository interface {
GetGraph(ctx context.Context, node LineageNode) (LineageGraph, error)
GetGraph(ctx context.Context, node LineageNode, query LineageQuery) (LineageGraph, error)
Upsert(ctx context.Context, node LineageNode, upstreams, downstreams []LineageNode) error
}

Expand Down
23 changes: 12 additions & 11 deletions core/asset/mocks/lineage_repository.go

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

4 changes: 2 additions & 2 deletions core/asset/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func (s *Service) GetAssetVersionHistory(ctx context.Context, flt Filter, id str
return s.assetRepository.GetVersionHistory(ctx, flt, id)
}

func (s *Service) GetLineage(ctx context.Context, node LineageNode) (LineageGraph, error) {
return s.lineageRepository.GetGraph(ctx, node)
func (s *Service) GetLineage(ctx context.Context, node LineageNode, query LineageQuery) (LineageGraph, error) {
return s.lineageRepository.GetGraph(ctx, node, query)
}

func (s *Service) GetTypes(ctx context.Context, flt Filter) (map[Type]int, error) {
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ Returns the lineage graph. Each entry in the graph describes a (edge) directed r
| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| urn | path | | Yes | string |
| level | query | | No | long |
| direction | query | | No | string |

##### Responses

Expand Down
27 changes: 16 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ require (
github.com/elastic/go-elasticsearch v0.0.0
github.com/elastic/go-elasticsearch/v7 v7.16.0
github.com/envoyproxy/protoc-gen-validate v0.6.7
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-playground/locales v0.14.0
github.com/go-playground/universal-translator v0.18.0
github.com/go-playground/validator/v10 v10.10.0
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/golang-migrate/migrate/v4 v4.15.0
github.com/google/go-cmp v0.5.7
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.9.0
Expand All @@ -27,32 +28,36 @@ require (
github.com/jmoiron/sqlx v1.3.4
github.com/lib/pq v1.10.2
github.com/mattn/go-sqlite3 v1.14.9 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/newrelic/go-agent/v3 v3.15.2
github.com/newrelic/go-agent/v3/integrations/nrelasticsearch-v7 v1.0.1
github.com/newrelic/go-agent/v3/integrations/nrgrpc v1.3.1
github.com/odpf/salt v0.0.0-20220614042821-c5613a78b4d6
github.com/olivere/elastic/v7 v7.0.31
github.com/ory/dockertest/v3 v3.8.1
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/peterbourgon/mergemap v0.0.1
github.com/r3labs/diff/v2 v2.15.0
github.com/spf13/afero v1.8.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.4.0
github.com/spf13/viper v1.10.1 // indirect
github.com/stretchr/testify v1.7.1
github.com/spf13/viper v1.11.0 // indirect
github.com/stretchr/testify v1.7.2
github.com/subosito/gotenv v1.4.0 // indirect
github.com/yuin/goldmark v1.4.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
golang.org/x/net v0.0.0-20220412020605-290c469a71a5
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/grpc v1.46.0
google.golang.org/protobuf v1.28.0
gopkg.in/ini.v1 v1.66.3 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
)
Loading

0 comments on commit ebbabe7

Please sign in to comment.