Skip to content

Commit f01ec6f

Browse files
feat: serve grpc on different port (#189)
* feat: install latest salt version * feat: use salt/mux package to server grpc * chore: update config example * feat: remove goroutines usage with mux.Serve * refactor: starting server
1 parent a632c15 commit f01ec6f

File tree

8 files changed

+472
-225
lines changed

8 files changed

+472
-225
lines changed

cli/assets.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func listAllAssetsCommand() *cobra.Command {
5454
RunE: func(cmd *cobra.Command, args []string) error {
5555
spinner := printer.Spin("")
5656
defer spinner.Stop()
57-
cs := term.NewColorScheme()
57+
5858
clnt, cancel, err := client.Create(cmd.Context())
5959
if err != nil {
6060
return err
@@ -71,14 +71,14 @@ func listAllAssetsCommand() *cobra.Command {
7171
report = append(report, []string{"ID", "TYPE", "SERVICE", "URN", "NAME", "VERSION"})
7272
index := 1
7373
for _, i := range res.GetData() {
74-
report = append(report, []string{i.Id, i.Type, i.Service, i.Urn, cs.Bluef(i.Name), i.Version})
74+
report = append(report, []string{i.Id, i.Type, i.Service, i.Urn, term.Bluef(i.Name), i.Version})
7575
index++
7676
}
7777
printer.Table(os.Stdout, report)
7878

79-
fmt.Println(cs.Cyanf("To view all the data in JSON format, use flag `-o json`"))
79+
fmt.Println(term.Cyanf("To view all the data in JSON format, use flag `-o json`"))
8080
} else {
81-
fmt.Println(cs.Bluef(prettyPrint(res.GetData())))
81+
fmt.Println(term.Bluef(prettyPrint(res.GetData())))
8282
}
8383

8484
return nil
@@ -140,7 +140,6 @@ func viewAssetByIDCommand() *cobra.Command {
140140
RunE: func(cmd *cobra.Command, args []string) error {
141141
spinner := printer.Spin("")
142142
defer spinner.Stop()
143-
cs := term.NewColorScheme()
144143

145144
clnt, cancel, err := client.Create(cmd.Context())
146145
if err != nil {
@@ -158,7 +157,7 @@ func viewAssetByIDCommand() *cobra.Command {
158157
}
159158
spinner.Stop()
160159

161-
fmt.Println(cs.Bluef(prettyPrint(res.GetData())))
160+
fmt.Println(term.Bluef(prettyPrint(res.GetData())))
162161
return nil
163162
},
164163
}
@@ -181,7 +180,6 @@ func editAssetCommand() *cobra.Command {
181180
RunE: func(cmd *cobra.Command, args []string) error {
182181
spinner := printer.Spin("")
183182
defer spinner.Stop()
184-
cs := term.NewColorScheme()
185183

186184
var reqBody compassv1beta1.UpsertPatchAssetRequest
187185
if err := parseFile(filePath, &reqBody); err != nil {
@@ -210,7 +208,7 @@ func editAssetCommand() *cobra.Command {
210208
}
211209
spinner.Stop()
212210

213-
fmt.Println("ID: \t", cs.Greenf(res.Id))
211+
fmt.Println("ID: \t", term.Greenf(res.Id))
214212
return nil
215213
},
216214
}
@@ -235,7 +233,6 @@ func deleteAssetByIDCommand() *cobra.Command {
235233
RunE: func(cmd *cobra.Command, args []string) error {
236234
spinner := printer.Spin("")
237235
defer spinner.Stop()
238-
cs := term.NewColorScheme()
239236

240237
clnt, cancel, err := client.Create(cmd.Context())
241238
if err != nil {
@@ -252,7 +249,7 @@ func deleteAssetByIDCommand() *cobra.Command {
252249
return err
253250
}
254251
spinner.Stop()
255-
fmt.Println("Asset ", cs.Redf(assetID), " Deleted Successfully")
252+
fmt.Println("Asset ", term.Redf(assetID), " Deleted Successfully")
256253
return nil
257254
},
258255
}

cli/discussions.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func listAllDiscussionsCommand() *cobra.Command {
5151
RunE: func(cmd *cobra.Command, args []string) error {
5252
spinner := printer.Spin("")
5353
defer spinner.Stop()
54-
cs := term.NewColorScheme()
5554

5655
clnt, cancel, err := client.Create(cmd.Context())
5756
if err != nil {
@@ -75,9 +74,9 @@ func listAllDiscussionsCommand() *cobra.Command {
7574
}
7675
printer.Table(os.Stdout, report)
7776

78-
fmt.Println(cs.Cyanf("To view all the data in JSON format, use flag `-o json`"))
77+
fmt.Println(term.Cyanf("To view all the data in JSON format, use flag `-o json`"))
7978
} else {
80-
fmt.Println(cs.Bluef(prettyPrint(res.GetData())))
79+
fmt.Println(term.Bluef(prettyPrint(res.GetData())))
8180
}
8281

8382
return nil
@@ -102,7 +101,6 @@ func viewDiscussionByIDCommand() *cobra.Command {
102101
RunE: func(cmd *cobra.Command, args []string) error {
103102
spinner := printer.Spin("")
104103
defer spinner.Stop()
105-
cs := term.NewColorScheme()
106104

107105
clnt, cancel, err := client.Create(cmd.Context())
108106
if err != nil {
@@ -120,7 +118,7 @@ func viewDiscussionByIDCommand() *cobra.Command {
120118
}
121119
spinner.Stop()
122120

123-
fmt.Println(cs.Bluef(prettyPrint(res.GetData())))
121+
fmt.Println(term.Bluef(prettyPrint(res.GetData())))
124122
return nil
125123
},
126124
}
@@ -143,7 +141,6 @@ func postDiscussionCommand() *cobra.Command {
143141
RunE: func(cmd *cobra.Command, args []string) error {
144142
spinner := printer.Spin("")
145143
defer spinner.Stop()
146-
cs := term.NewColorScheme()
147144

148145
var reqBody compassv1beta1.Discussion
149146
if err := parseFile(filePath, &reqBody); err != nil {
@@ -175,7 +172,7 @@ func postDiscussionCommand() *cobra.Command {
175172
}
176173
spinner.Stop()
177174

178-
fmt.Println("ID: \t", cs.Greenf(res.Id))
175+
fmt.Println("ID: \t", term.Greenf(res.Id))
179176
return nil
180177
},
181178
}

cli/lineage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func lineageCommand() *cobra.Command {
2727
RunE: func(cmd *cobra.Command, args []string) error {
2828
spinner := printer.Spin("")
2929
defer spinner.Stop()
30-
cs := term.NewColorScheme()
30+
3131
clnt, cancel, err := client.Create(cmd.Context())
3232
if err != nil {
3333
return err
@@ -43,7 +43,7 @@ func lineageCommand() *cobra.Command {
4343
return err
4444
}
4545

46-
fmt.Println(cs.Bluef(prettyPrint(res.GetData())))
46+
fmt.Println(term.Bluef(prettyPrint(res.GetData())))
4747

4848
return nil
4949
},

cli/search.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func searchCommand() *cobra.Command {
2929
RunE: func(cmd *cobra.Command, args []string) error {
3030
spinner := printer.Spin("")
3131
defer spinner.Stop()
32-
cs := term.NewColorScheme()
32+
3333
clnt, cancel, err := client.Create(cmd.Context())
3434
if err != nil {
3535
return err
@@ -42,7 +42,7 @@ func searchCommand() *cobra.Command {
4242
return err
4343
}
4444

45-
fmt.Println(cs.Bluef(prettyPrint(res.GetData())))
45+
fmt.Println(term.Bluef(prettyPrint(res.GetData())))
4646

4747
return nil
4848
},

compass.yaml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ db:
2424
service:
2525
host: localhost
2626
port: 8080
27+
grpc_port: 8081
2728
identity:
2829
headerkey_uuid: Compass-User-UUID
2930
headerkey_email: Compass-User-Email

go.mod

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ require (
88
github.com/Masterminds/semver/v3 v3.1.1
99
github.com/Masterminds/squirrel v1.5.2
1010
github.com/benbjohnson/clock v1.3.0 // indirect
11-
github.com/dhui/dktest v0.3.7 // indirect
1211
github.com/elastic/go-elasticsearch v0.0.0
1312
github.com/elastic/go-elasticsearch/v7 v7.16.0
1413
github.com/envoyproxy/protoc-gen-validate v0.6.7
@@ -17,47 +16,42 @@ require (
1716
github.com/go-playground/universal-translator v0.18.0
1817
github.com/go-playground/validator/v10 v10.10.0
1918
github.com/gofrs/uuid v4.2.0+incompatible // indirect
20-
github.com/golang-migrate/migrate/v4 v4.15.0
19+
github.com/golang-migrate/migrate/v4 v4.15.2
2120
github.com/golang-module/carbon/v2 v2.1.8
2221
github.com/google/go-cmp v0.5.8
2322
github.com/google/uuid v1.3.0
2423
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
25-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.9.0
24+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3
2625
github.com/jackc/pgconn v1.8.0
2726
github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451
2827
github.com/jackc/pgx/v4 v4.10.1
29-
github.com/jmoiron/sqlx v1.3.4
28+
github.com/jmoiron/sqlx v1.3.5
3029
github.com/lib/pq v1.10.2
31-
github.com/mattn/go-sqlite3 v1.14.9 // indirect
3230
github.com/mitchellh/mapstructure v1.5.0 // indirect
33-
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
3431
github.com/newrelic/go-agent/v3 v3.15.2
3532
github.com/newrelic/go-agent/v3/integrations/nrelasticsearch-v7 v1.0.1
3633
github.com/newrelic/go-agent/v3/integrations/nrgrpc v1.3.1
37-
github.com/odpf/salt v0.0.0-20220614042821-c5613a78b4d6
34+
github.com/odpf/salt v0.2.5-0.20221130085531-51c81815f7d6
3835
github.com/olivere/elastic/v7 v7.0.31
39-
github.com/ory/dockertest/v3 v3.8.1
36+
github.com/ory/dockertest/v3 v3.9.1
4037
github.com/pelletier/go-toml v1.9.5 // indirect
4138
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
4239
github.com/peterbourgon/mergemap v0.0.1
4340
github.com/r3labs/diff/v2 v2.15.0
4441
github.com/spf13/cast v1.5.0 // indirect
4542
github.com/spf13/cobra v1.4.0
4643
github.com/spf13/viper v1.11.0 // indirect
47-
github.com/stretchr/testify v1.7.2
44+
github.com/stretchr/testify v1.8.0
4845
github.com/subosito/gotenv v1.4.0 // indirect
49-
github.com/yuin/goldmark v1.4.1 // indirect
5046
go.uber.org/atomic v1.9.0 // indirect
5147
go.uber.org/multierr v1.8.0 // indirect
5248
go.uber.org/zap v1.21.0 // indirect
5349
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
54-
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2
55-
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
50+
golang.org/x/net v0.0.0-20220919232410-f2f64ebce3c1
5651
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
57-
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
58-
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
59-
google.golang.org/grpc v1.46.0
60-
google.golang.org/protobuf v1.28.0
52+
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc
53+
google.golang.org/grpc v1.49.0
54+
google.golang.org/protobuf v1.28.1
6155
gopkg.in/ini.v1 v1.66.6 // indirect
6256
gopkg.in/yaml.v2 v2.4.0
6357
gotest.tools v2.2.0+incompatible

0 commit comments

Comments
 (0)