Skip to content

Commit ebbabe7

Browse files
feat(lineage): fetch lineage with level and direction (#157)
* feat(lineage): fetch lineage with level and direction * fix: test name not capitalised
1 parent e352553 commit ebbabe7

File tree

17 files changed

+1559
-1342
lines changed

17 files changed

+1559
-1342
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
NAME="github.com/odpf/compass"
22
VERSION=$(shell git describe --always --tags 2>/dev/null)
33
COVERFILE="/tmp/compass.coverprofile"
4-
PROTON_COMMIT := "a5cae3d372dc9741659b19f20a203b9278431356"
4+
PROTON_COMMIT := "9eaca223dfd5ca0297abdb593fa73e8522d8ef62"
55
.PHONY: all build test clean install proto
66

77
all: build
@@ -50,4 +50,4 @@ install: ## install required dependencies
5050
go install github.com/envoyproxy/[email protected]
5151

5252
update-swagger-md:
53-
npx swagger-markdown -i third_party/OpenAPI/compass.swagger.yaml -o docs/reference/api.md
53+
npx swagger-markdown -i third_party/OpenAPI/compass.swagger.yaml -o docs/docs/reference/api.md

api/proto/odpf/compass/v1beta1/service.pb.go

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

api/proto/odpf/compass/v1beta1/service.pb.gw.go

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

api/proto/odpf/compass/v1beta1/service.pb.validate.go

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

core/asset/lineage.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,30 @@ import (
44
"context"
55
)
66

7-
//go:generate mockery --name=LineageRepository -r --case underscore --with-expecter --structname LineageRepository --filename lineage_repository.go --output=./mocks
7+
type LineageDirection string
8+
9+
func (dir LineageDirection) IsValid() bool {
10+
switch dir {
11+
case LineageDirectionUpstream, LineageDirectionDownstream, "":
12+
return true
13+
default:
14+
return false
15+
}
16+
}
17+
18+
const (
19+
LineageDirectionUpstream LineageDirection = "upstream"
20+
LineageDirectionDownstream LineageDirection = "downstream"
21+
)
22+
23+
type LineageQuery struct {
24+
Level int
25+
Direction LineageDirection
26+
}
27+
28+
//go:generate mockery --name=LineageRepository -r --case underscore --with-expecter --structname=LineageRepository --filename=lineage_repository.go --output=./mocks
829
type LineageRepository interface {
9-
GetGraph(ctx context.Context, node LineageNode) (LineageGraph, error)
30+
GetGraph(ctx context.Context, node LineageNode, query LineageQuery) (LineageGraph, error)
1031
Upsert(ctx context.Context, node LineageNode, upstreams, downstreams []LineageNode) error
1132
}
1233

core/asset/mocks/lineage_repository.go

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

core/asset/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ func (s *Service) GetAssetVersionHistory(ctx context.Context, flt Filter, id str
9090
return s.assetRepository.GetVersionHistory(ctx, flt, id)
9191
}
9292

93-
func (s *Service) GetLineage(ctx context.Context, node LineageNode) (LineageGraph, error) {
94-
return s.lineageRepository.GetGraph(ctx, node)
93+
func (s *Service) GetLineage(ctx context.Context, node LineageNode, query LineageQuery) (LineageGraph, error) {
94+
return s.lineageRepository.GetGraph(ctx, node, query)
9595
}
9696

9797
func (s *Service) GetTypes(ctx context.Context, flt Filter) (map[Type]int, error) {

docs/docs/reference/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ Returns the lineage graph. Each entry in the graph describes a (edge) directed r
452452
| Name | Located in | Description | Required | Schema |
453453
| ---- | ---------- | ----------- | -------- | ---- |
454454
| urn | path | | Yes | string |
455+
| level | query | | No | long |
456+
| direction | query | | No | string |
455457

456458
##### Responses
457459

go.mod

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ require (
1212
github.com/elastic/go-elasticsearch v0.0.0
1313
github.com/elastic/go-elasticsearch/v7 v7.16.0
1414
github.com/envoyproxy/protoc-gen-validate v0.6.7
15+
github.com/fsnotify/fsnotify v1.5.4 // indirect
1516
github.com/go-playground/locales v0.14.0
1617
github.com/go-playground/universal-translator v0.18.0
1718
github.com/go-playground/validator/v10 v10.10.0
1819
github.com/gofrs/uuid v4.2.0+incompatible // indirect
1920
github.com/golang-migrate/migrate/v4 v4.15.0
20-
github.com/google/go-cmp v0.5.7
21+
github.com/google/go-cmp v0.5.8
2122
github.com/google/uuid v1.3.0
2223
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
2324
github.com/grpc-ecosystem/grpc-gateway/v2 v2.9.0
@@ -27,32 +28,36 @@ require (
2728
github.com/jmoiron/sqlx v1.3.4
2829
github.com/lib/pq v1.10.2
2930
github.com/mattn/go-sqlite3 v1.14.9 // indirect
31+
github.com/mitchellh/mapstructure v1.5.0 // indirect
3032
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
3133
github.com/newrelic/go-agent/v3 v3.15.2
3234
github.com/newrelic/go-agent/v3/integrations/nrelasticsearch-v7 v1.0.1
3335
github.com/newrelic/go-agent/v3/integrations/nrgrpc v1.3.1
3436
github.com/odpf/salt v0.0.0-20220614042821-c5613a78b4d6
3537
github.com/olivere/elastic/v7 v7.0.31
3638
github.com/ory/dockertest/v3 v3.8.1
39+
github.com/pelletier/go-toml v1.9.5 // indirect
40+
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
3741
github.com/peterbourgon/mergemap v0.0.1
3842
github.com/r3labs/diff/v2 v2.15.0
39-
github.com/spf13/afero v1.8.0 // indirect
43+
github.com/spf13/cast v1.5.0 // indirect
4044
github.com/spf13/cobra v1.4.0
41-
github.com/spf13/viper v1.10.1 // indirect
42-
github.com/stretchr/testify v1.7.1
45+
github.com/spf13/viper v1.11.0 // indirect
46+
github.com/stretchr/testify v1.7.2
47+
github.com/subosito/gotenv v1.4.0 // indirect
4348
github.com/yuin/goldmark v1.4.1 // indirect
4449
go.uber.org/atomic v1.9.0 // indirect
4550
go.uber.org/multierr v1.8.0 // indirect
4651
go.uber.org/zap v1.21.0 // indirect
47-
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce // indirect
48-
golang.org/x/net v0.0.0-20220412020605-290c469a71a5
49-
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
50-
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
51-
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
52-
google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4
52+
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
53+
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2
54+
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
55+
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
56+
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
57+
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
5358
google.golang.org/grpc v1.46.0
5459
google.golang.org/protobuf v1.28.0
55-
gopkg.in/ini.v1 v1.66.3 // indirect
60+
gopkg.in/ini.v1 v1.66.6 // indirect
5661
gopkg.in/yaml.v2 v2.4.0
5762
gotest.tools v2.2.0+incompatible
5863
)

0 commit comments

Comments
 (0)