From df07d8bfda435ac89440bd7adebb3c3f8c19115d Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Tue, 19 Nov 2019 11:00:33 +0100 Subject: [PATCH] chore: dvserver package --- Makefile | 5 +- api/dvmodel.proto | 14 +- api/dvserver.proto | 39 + cmd/depviz/main.go | 86 +- gen.sum | 5 +- go.mod | 8 +- go.sum | 16 +- internal/dvcore/run.go | 6 +- internal/dvcore/server.go | 135 --- internal/dvcore/store.go | 38 +- internal/dvmodel/dvmodel.pb.go | 535 ++++++++--- internal/dvmodel/model.go | 6 - internal/dvserver/api.go | 60 ++ internal/dvserver/doc.go | 1 + internal/dvserver/dvserver.pb.go | 1390 +++++++++++++++++++++++++++ internal/dvserver/dvserver.pb.gw.go | 221 +++++ internal/dvserver/server.go | 215 +++++ internal/githubprovider/model.go | 18 +- 18 files changed, 2497 insertions(+), 301 deletions(-) create mode 100644 api/dvserver.proto delete mode 100644 internal/dvcore/server.go create mode 100644 internal/dvserver/api.go create mode 100644 internal/dvserver/doc.go create mode 100644 internal/dvserver/dvserver.pb.go create mode 100644 internal/dvserver/dvserver.pb.gw.go create mode 100644 internal/dvserver/server.go diff --git a/Makefile b/Makefile index ff99fba1d..51cfeac33 100644 --- a/Makefile +++ b/Makefile @@ -49,10 +49,13 @@ gen.sum: $(GEN_SRC) ) +PROTOC_OPTS = -I ./vendor/github.com/grpc-ecosystem/grpc-gateway:./api:./vendor:/protobuf .PHONY: generate_local generate_local: @set -e; for proto in $(PROTOS_SRC); do ( set -xe; \ - protoc -I ./api:./vendor:/protobuf --grpc-gateway_out=logtostderr=true:"$(GOPATH)/src" --gogofaster_out="plugins=grpc:$(GOPATH)/src" "$$proto" \ + protoc $(PROTOC_OPTS) \ + --grpc-gateway_out=logtostderr=true:"$(GOPATH)/src" \ + --gogofaster_out="plugins=grpc:$(GOPATH)/src" "$$proto" \ ); done goimports -w ./pkg ./cmd ./internal shasum $(GEN_SRC) | sort > gen.sum.tmp diff --git a/api/dvmodel.proto b/api/dvmodel.proto index d0090530d..288cb4b00 100644 --- a/api/dvmodel.proto +++ b/api/dvmodel.proto @@ -82,8 +82,8 @@ message Task { } string id = 1 [(gogoproto.casttype) = "github.com/cayleygraph/quad.IRI", (gogoproto.moretags) = "quad:\"@id\"", (gogoproto.customname) = "ID"]; // canonical URI - google.protobuf.Timestamp created_at = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "quad:\"schema:createdAt,optional\""]; - google.protobuf.Timestamp updated_at = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "quad:\"schema:updatedAt,optional\""]; + google.protobuf.Timestamp created_at = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true, (gogoproto.moretags) = "quad:\"schema:createdAt,optional\""]; + google.protobuf.Timestamp updated_at = 4 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true, (gogoproto.moretags) = "quad:\"schema:updatedAt,optional\""]; string local_id = 5 [(gogoproto.customname) = "LocalID", (gogoproto.moretags) = "quad:\"schema:localId,optional\""]; Kind kind = 10 [(gogoproto.moretags) = "quad:\"schema:kind,optional\""]; @@ -148,3 +148,13 @@ enum Driver { Trello = 3; Jira = 4; } + +// +// internal +// + +message Batch { + repeated Task tasks = 1; + repeated Owner owners = 2; + repeated Topic topics = 3; +} \ No newline at end of file diff --git a/api/dvserver.proto b/api/dvserver.proto new file mode 100644 index 000000000..f871941e8 --- /dev/null +++ b/api/dvserver.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package depviz.server; + +import "google/api/annotations.proto"; +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options/annotations.proto"; + +import "dvmodel.proto"; + +option go_package = "moul.io/depviz/internal/dvserver"; +option (gogoproto.sizer_all) = true; +option (gogoproto.marshaler_all) = true; +option (gogoproto.unmarshaler_all) = true; + +service DepvizService { + rpc Graph(Graph.Input) returns (Graph.Output) { option (google.api.http) = {get: "/graph"}; }; + rpc StoreDump(StoreDump.Input) returns (StoreDump.Output) { option (google.api.http) = {get: "/store/dump"}; }; +} + +message Graph { + message Input { + repeated string targets = 1; + bool with_closed = 2; + bool without_isolated = 3; + bool without_prs = 4 [(gogoproto.customname) = "WithoutPRs"]; + bool without_external_deps = 5; + } + message Output { + repeated depviz.model.Task tasks = 1; + } +} + +message StoreDump { + message Input {} + message Output { + depviz.model.Batch batch = 1; + } +} diff --git a/cmd/depviz/main.go b/cmd/depviz/main.go index 030c6b753..8ca4b5eb4 100644 --- a/cmd/depviz/main.go +++ b/cmd/depviz/main.go @@ -1,24 +1,29 @@ package main // import "moul.io/depviz" import ( + "context" "errors" "flag" "fmt" "log" "math/rand" "os" + "os/signal" "time" "github.com/cayleygraph/cayley" "github.com/cayleygraph/cayley/graph" _ "github.com/cayleygraph/cayley/graph/kv/bolt" "github.com/cayleygraph/cayley/schema" + "github.com/oklog/run" "github.com/peterbourgon/ff" "github.com/peterbourgon/ff/ffcli" "go.uber.org/zap" "go.uber.org/zap/zapcore" "moul.io/depviz/internal/dvcore" + "moul.io/depviz/internal/dvserver" "moul.io/depviz/internal/dvstore" + "moul.io/godev" ) var ( @@ -36,9 +41,15 @@ var ( airtableTasksTab = airtableFlags.String("tasks", "Tasks", `"Tasks" tab name`) airtableTopicsTab = airtableFlags.String("topics", "Topics", `"Topics" tab name`) - serverFlags = flag.NewFlagSet("server", flag.ExitOnError) - serverBind = serverFlags.String("bind", ":8000", "server bind address") - serverGodmode = serverFlags.Bool("godmode", false, "enable dangerous API calls") + serverFlags = flag.NewFlagSet("server", flag.ExitOnError) + serverHTTPBind = serverFlags.String("http-bind", ":8000", "HTTP bind address") + serverGRPCBInd = serverFlags.String("grpc-bind", ":9000", "gRPC bind address") + serverRequestTimeout = serverFlags.Duration("request-timeout", 5*time.Second, "request timeout") + serverShutdownTimeout = serverFlags.Duration("shutdowm-timeout", 6*time.Second, "shutdown timeout") + serverCORSAllowedOrigins = serverFlags.String("cors-allowed-origins", "*", "allowed CORS origins") + serverGodmode = serverFlags.Bool("godmode", false, "enable dangerous API calls") + serverWithPprof = serverFlags.Bool("with-pprof", false, "enable pprof endpoints") + serverWithoutRecovery = serverFlags.Bool("without-recovery", false, "disable panic recovery (dev)") runFlags = flag.NewFlagSet("run", flag.ExitOnError) runNoPull = runFlags.Bool("no-pull", false, "don't pull providers (graph only)") @@ -201,7 +212,14 @@ func execStoreDumpJSON(args []string) error { return fmt.Errorf("init store: %w", err) } - return dvcore.StoreDumpJSON(store, schemaConfig) + ctx := context.Background() + batch, err := dvcore.GetStoreDump(ctx, store, schemaConfig) + if err != nil { + return fmt.Errorf("get store dump: %w", err) + } + + fmt.Println(godev.PrettyJSON(batch)) + return nil } func execStoreInfo(args []string) error { @@ -251,12 +269,64 @@ func execServer(args []string) error { return err } - store, err := storeFromArgs() - if err != nil { - return fmt.Errorf("init store: %w", err) + var ( + ctx = context.Background() + g run.Group + svc dvserver.Service + ) + + { // server + store, err := storeFromArgs() + if err != nil { + return fmt.Errorf("init store: %w", err) + } + + opts := dvserver.Opts{ + Logger: logger, + HTTPBind: *serverHTTPBind, + GRPCBind: *serverGRPCBInd, + CORSAllowedOrigins: *serverCORSAllowedOrigins, + RequestTimeout: *serverRequestTimeout, + ShutdownTimeout: *serverShutdownTimeout, + WithPprof: *serverWithPprof, + WithoutRecovery: *serverWithoutRecovery, + Godmode: *serverGodmode, + } + svc, err = dvserver.New(ctx, store, schemaConfig, opts) + if err != nil { + return fmt.Errorf("init server: %w", err) + } + + g.Add( + svc.Run, + func(error) { svc.Close() }, + ) } - return dvcore.Server(*serverBind, *serverGodmode, store, logger, schemaConfig) + { // signal handling + ctx, cancel := context.WithCancel(ctx) + g.Add(func() error { + sigch := make(chan os.Signal, 1) + signal.Notify(sigch, os.Interrupt) + select { + case <-sigch: + case <-ctx.Done(): + } + return nil + }, func(error) { + cancel() + }) + } + + logger.Info("server started", + zap.String("http-bind", svc.HTTPListenerAddr()), + zap.String("grpc-bind", svc.GRPCListenerAddr()), + ) + + if err := g.Run(); err != nil { + return fmt.Errorf("group terminated: %w", err) + } + return nil } func storeFromArgs() (*cayley.Handle, error) { diff --git a/gen.sum b/gen.sum index 436b78432..dbc3f999b 100644 --- a/gen.sum +++ b/gen.sum @@ -1,2 +1,3 @@ -05b322877b51a94ad03f713faf16b1e526187fc9 Makefile -71d86eb1c5b188eae29633ae85c4e9795fd9d152 ./api/dvmodel.proto +32ff25c90d1d2680a429d90a796d7152f3bb7e6d Makefile +b5fbeef6563e56622e63d86a1b0d822237f1b305 ./api/dvmodel.proto +d8a569f515deddba8c2bbdcac334afee3529eee5 ./api/dvserver.proto diff --git a/go.mod b/go.mod index ab1ee8715..b2fa02fc8 100644 --- a/go.mod +++ b/go.mod @@ -11,14 +11,18 @@ require ( github.com/go-chi/chi v4.0.2+incompatible github.com/go-chi/render v1.0.1 github.com/gobuffalo/packr/v2 v2.7.1 + github.com/gogo/gateway v1.1.0 github.com/gogo/protobuf v1.3.1 github.com/golang/protobuf v1.3.2 github.com/google/go-github/v28 v28.1.1 - github.com/gorilla/schema v1.1.0 + github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 github.com/grpc-ecosystem/grpc-gateway v1.12.1 + github.com/oklog/run v1.0.0 github.com/peterbourgon/ff v1.6.1-0.20190916204019-6cd704ec2eeb github.com/prometheus/client_golang v1.2.1 // indirect github.com/prometheus/procfs v0.0.7 // indirect + github.com/rs/cors v1.7.0 + github.com/treastech/logger v0.0.0-20180705232552-e381e9ecf2e3 go.uber.org/multierr v1.4.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f // indirect @@ -27,6 +31,8 @@ require ( golang.org/x/sys v0.0.0-20191115151921-52ab43148777 // indirect golang.org/x/tools v0.0.0-20191116214431-80313e1ba718 // indirect google.golang.org/appengine v1.6.5 // indirect + google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c + google.golang.org/grpc v1.24.0 gopkg.in/yaml.v2 v2.2.5 gopkg.in/yaml.v3 v3.0.0-20191107175235-0b070bb63a18 // indirect moul.io/godev v1.3.0 diff --git a/go.sum b/go.sum index 530778c1b..086417883 100644 --- a/go.sum +++ b/go.sum @@ -113,6 +113,8 @@ github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4 github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q= github.com/gobuffalo/packr/v2 v2.7.1 h1:n3CIW5T17T8v4GGK5sWXLVWJhCz7b5aNLSxW6gYim4o= github.com/gobuffalo/packr/v2 v2.7.1/go.mod h1:qYEvAazPaVxy7Y7KR0W8qYEE+RymX74kETFqjFoFlOc= +github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= +github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= @@ -120,6 +122,7 @@ github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE= github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -156,12 +159,12 @@ github.com/gopherjs/gopherjs v0.0.0-20190812055157-5d271430af9f/go.mod h1:wJfORR github.com/gopherjs/jsbuiltin v0.0.0-20180426082241-50091555e127/go.mod h1:7X1acUyFRf+oVFTU6SWw9mnb57Vxn+Nbh8iPbKg95hs= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY= -github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.0 h1:bM6ZAFZmc/wPFaRDi0d5L7hGEZEx/2u+Tmr2evNHDiI= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.12.1 h1:zCy2xE9ablevUOrUZc3Dl72Dt+ya2FNAvC2yLYMHzi4= @@ -222,6 +225,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -285,6 +290,8 @@ github.com/rogpeppe/go-internal v1.3.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.4.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.5.0 h1:Usqs0/lDK/NqTkvrmKSwA/3XkZAs7ZAW/eLeQ2MVBTw= github.com/rogpeppe/go-internal v1.5.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= @@ -325,6 +332,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/treastech/logger v0.0.0-20180705232552-e381e9ecf2e3 h1:0SnC9653NEySn3YUL1UV9o45KfQzszcOpIJ2f2BlrVg= +github.com/treastech/logger v0.0.0-20180705232552-e381e9ecf2e3/go.mod h1:duKQLZRLkdeZQlw8QfGYqhBQrjThZ2qRBwA8HYjARn8= github.com/tylertreat/BoomFilters v0.0.0-20181028192813-611b3dbe80e8 h1:7X4KYG3guI2mPQGxm/ZNNsiu4BjKnef0KG0TblMC+Z8= github.com/tylertreat/BoomFilters v0.0.0-20181028192813-611b3dbe80e8/go.mod h1:OYRfF6eb5wY9VRFkXJH8FFBi3plw2v+giaIu7P054pM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -462,11 +471,14 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c h1:hrpEMCZ2O7DR5gC1n2AJGVhrwiEjOi35+jxtIuZpTMo= google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.24.0 h1:vb/1TCsVn3DcJlQ0Gs1yB1pKI6Do2/QNwxdKqmc/b0s= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/dvcore/run.go b/internal/dvcore/run.go index 137492cef..ffffdf86b 100644 --- a/internal/dvcore/run.go +++ b/internal/dvcore/run.go @@ -221,7 +221,7 @@ func saveBatches(h *cayley.Handle, schema *schema.Config, batches []dvmodel.Batc _, _ = schema.WriteAsQuads(dw, working) } - working = owner + working = *owner if _, err := schema.WriteAsQuads(iw, working); err != nil { return fmt.Errorf("write as quads: %w", err) } @@ -232,7 +232,7 @@ func saveBatches(h *cayley.Handle, schema *schema.Config, batches []dvmodel.Batc _, _ = schema.WriteAsQuads(dw, working) } - working = task + working = *task if _, err := schema.WriteAsQuads(iw, working); err != nil { return fmt.Errorf("write as quads: %w", err) } @@ -243,7 +243,7 @@ func saveBatches(h *cayley.Handle, schema *schema.Config, batches []dvmodel.Batc _, _ = schema.WriteAsQuads(dw, working) } - working = topic + working = *topic if _, err := schema.WriteAsQuads(iw, working); err != nil { return fmt.Errorf("write as quads: %w", err) } diff --git a/internal/dvcore/server.go b/internal/dvcore/server.go deleted file mode 100644 index aa6acea28..000000000 --- a/internal/dvcore/server.go +++ /dev/null @@ -1,135 +0,0 @@ -package dvcore - -import ( - "fmt" - "net/http" - "strings" - "time" - - "github.com/cayleygraph/cayley" - "github.com/cayleygraph/cayley/schema" - "github.com/go-chi/chi" - "github.com/go-chi/chi/middleware" - "github.com/go-chi/render" - "github.com/gobuffalo/packr/v2" - gschema "github.com/gorilla/schema" - "go.uber.org/zap" - "moul.io/depviz/internal/chiutil" - "moul.io/depviz/internal/dvparser" - "moul.io/depviz/internal/dvstore" -) - -func Server(bind string, godmode bool, h *cayley.Handle, logger *zap.Logger, schema *schema.Config) error { - logger.Debug("Server called", zap.String("bind", bind), zap.Bool("godmode", godmode)) - - r := chi.NewRouter() - - //r.Use(middleware.RequestID) - //r.Use(middleware.RealIP) - //r.Use(middleware.URLFormat) - r.Use(middleware.Logger) - r.Use(middleware.Recoverer) - r.Use(middleware.Timeout(5 * time.Second)) - // FIXME: add caching - - a := api{ - logger: logger, - h: h, - schema: schema, - } - - r.Route("/api", func(r chi.Router) { - r.Route("/", func(r chi.Router) { - r.Use(render.SetContentType(render.ContentTypeJSON)) - if godmode { - r.Get("/store/dump.json", a.storeDumpJSON) - } - r.Get("/graph.json", a.graphJSON) - }) - }) - - box := packr.New("static", "./static") - chiutil.FileServer(r, "/", box) - - { // print listeners and routes - logger.Info("HTTP API listening", zap.String("bind", bind)) - walkFunc := func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error { - logger.Debug(fmt.Sprintf(" %s %s", method, route)) - return nil - } - if err := chi.Walk(r, walkFunc); err != nil { - logger.Warn("chi walk", zap.Error(err)) - } - } - - return http.ListenAndServe(bind, r) -} - -type api struct { - logger *zap.Logger - h *cayley.Handle - schema *schema.Config -} - -func (api *api) storeDumpJSON(w http.ResponseWriter, r *http.Request) { - dump, err := getStoreDump(api.h, api.schema) - if err != nil { - _ = render.Render(w, r, chiutil.ErrRender(err)) - return - } - - if err := render.Render(w, r, dump); err != nil { - _ = render.Render(w, r, chiutil.ErrRender(err)) - return - } -} - -func (api *api) graphJSON(w http.ResponseWriter, r *http.Request) { - // parsing - var decoder = gschema.NewDecoder() - type Opts struct { - Targets string `schema:"targets"` - WithClosed bool `schema:"with-closed"` - WithoutIsolated bool `schema:"without-isolated"` - WithoutPRs bool `schema:"without-prs"` - WithoutExternalDeps bool `schema:"without-external-deps"` - } - opts := Opts{} - - err := decoder.Decode(&opts, r.URL.Query()) - if err != nil { - _ = render.Render(w, r, chiutil.ErrRender(err)) - return - } - - // validation - if opts.Targets == "" { - _ = render.Render(w, r, chiutil.ErrRender(fmt.Errorf("missing ?targets="))) - return - } - filters := dvstore.LoadTasksFilters{ - WithClosed: opts.WithClosed, - WithoutIsolated: opts.WithoutIsolated, - WithoutPRs: opts.WithoutPRs, - WithoutExternalDeps: opts.WithoutExternalDeps, - } - targets, err := dvparser.ParseTargets(strings.Split(opts.Targets, ",")) - if err != nil { - _ = render.Render(w, r, chiutil.ErrRender(err)) - return - } - filters.Targets = targets - - // load tasks - tasks, err := dvstore.LoadTasks(api.h, api.schema, filters) - if err != nil { - _ = render.Render(w, r, chiutil.ErrRender(err)) - return - } - - // return JSON - if err := render.Render(w, r, tasks); err != nil { - _ = render.Render(w, r, chiutil.ErrRender(err)) - return - } -} diff --git a/internal/dvcore/store.go b/internal/dvcore/store.go index 333459e23..d3e3a8807 100644 --- a/internal/dvcore/store.go +++ b/internal/dvcore/store.go @@ -7,7 +7,6 @@ import ( "github.com/cayleygraph/cayley" "github.com/cayleygraph/cayley/schema" "moul.io/depviz/internal/dvmodel" - "moul.io/godev" ) func StoreDumpQuads(h *cayley.Handle) error { @@ -21,31 +20,36 @@ func StoreDumpQuads(h *cayley.Handle) error { return nil } -func getStoreDump(h *cayley.Handle, schema *schema.Config) (*dvmodel.Batch, error) { - dump := dvmodel.Batch{} - ctx := context.TODO() - - if err := schema.LoadTo(ctx, h, &dump.Owners); err != nil { +func GetStoreDump(ctx context.Context, h *cayley.Handle, schema *schema.Config) (*dvmodel.Batch, error) { + owners := []dvmodel.Owner{} + if err := schema.LoadTo(ctx, h, &owners); err != nil { return nil, fmt.Errorf("load owners: %w", err) } - if err := schema.LoadTo(ctx, h, &dump.Tasks); err != nil { + tasks := []dvmodel.Task{} + if err := schema.LoadTo(ctx, h, &tasks); err != nil { return nil, fmt.Errorf("load tasks: %w", err) } - if err := schema.LoadTo(ctx, h, &dump.Topics); err != nil { + topics := []dvmodel.Topic{} + if err := schema.LoadTo(ctx, h, &topics); err != nil { return nil, fmt.Errorf("load topics: %w", err) } - return &dump, nil -} - -func StoreDumpJSON(h *cayley.Handle, schema *schema.Config) error { - dump, err := getStoreDump(h, schema) - if err != nil { - return err + dump := dvmodel.Batch{ + Owners: make([]*dvmodel.Owner, len(owners)), + Tasks: make([]*dvmodel.Task, len(tasks)), + Topics: make([]*dvmodel.Topic, len(topics)), + } + for idx, owner := range owners { + dump.Owners[idx] = &owner + } + for idx, task := range tasks { + dump.Tasks[idx] = &task + } + for idx, topic := range topics { + dump.Topics[idx] = &topic } - fmt.Println(godev.PrettyJSON(dump)) - return nil + return &dump, nil } func StoreInfo(h *cayley.Handle) error { diff --git a/internal/dvmodel/dvmodel.pb.go b/internal/dvmodel/dvmodel.pb.go index b589d153e..f1ce770c6 100644 --- a/internal/dvmodel/dvmodel.pb.go +++ b/internal/dvmodel/dvmodel.pb.go @@ -284,8 +284,8 @@ var xxx_messageInfo_Owner proto.InternalMessageInfo // It's the entity used for Issues, Pull Requests, Merge Requests, Cards, Epics, Milestones, Stories. type Task struct { ID github_com_cayleygraph_quad.IRI `protobuf:"bytes,1,opt,name=id,proto3,casttype=github.com/cayleygraph/quad.IRI" json:"id,omitempty" quad:"@id"` - CreatedAt time.Time `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at" quad:"schema:createdAt,optional"` - UpdatedAt time.Time `protobuf:"bytes,4,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at" quad:"schema:updatedAt,optional"` + CreatedAt *time.Time `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at,omitempty" quad:"schema:createdAt,optional"` + UpdatedAt *time.Time `protobuf:"bytes,4,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at,omitempty" quad:"schema:updatedAt,optional"` LocalID string `protobuf:"bytes,5,opt,name=local_id,json=localId,proto3" json:"local_id,omitempty" quad:"schema:localId,optional"` Kind Task_Kind `protobuf:"varint,10,opt,name=kind,proto3,enum=depviz.model.Task_Kind" json:"kind,omitempty" quad:"schema:kind,optional"` Title string `protobuf:"bytes,11,opt,name=title,proto3" json:"title,omitempty" quad:"schema:title,optional"` @@ -392,6 +392,45 @@ func (m *Topic) XXX_DiscardUnknown() { var xxx_messageInfo_Topic proto.InternalMessageInfo +type Batch struct { + Tasks []*Task `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"` + Owners []*Owner `protobuf:"bytes,2,rep,name=owners,proto3" json:"owners,omitempty"` + Topics []*Topic `protobuf:"bytes,3,rep,name=topics,proto3" json:"topics,omitempty"` +} + +func (m *Batch) Reset() { *m = Batch{} } +func (m *Batch) String() string { return proto.CompactTextString(m) } +func (*Batch) ProtoMessage() {} +func (*Batch) Descriptor() ([]byte, []int) { + return fileDescriptor_106647ce772da30c, []int{3} +} +func (m *Batch) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Batch) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Batch.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Batch) XXX_Merge(src proto.Message) { + xxx_messageInfo_Batch.Merge(m, src) +} +func (m *Batch) XXX_Size() int { + return m.Size() +} +func (m *Batch) XXX_DiscardUnknown() { + xxx_messageInfo_Batch.DiscardUnknown(m) +} + +var xxx_messageInfo_Batch proto.InternalMessageInfo + func init() { proto.RegisterEnum("depviz.model.Driver", Driver_name, Driver_value) golang_proto.RegisterEnum("depviz.model.Driver", Driver_name, Driver_value) @@ -411,104 +450,109 @@ func init() { golang_proto.RegisterType((*Task)(nil), "depviz.model.Task") proto.RegisterType((*Topic)(nil), "depviz.model.Topic") golang_proto.RegisterType((*Topic)(nil), "depviz.model.Topic") + proto.RegisterType((*Batch)(nil), "depviz.model.Batch") + golang_proto.RegisterType((*Batch)(nil), "depviz.model.Batch") } func init() { proto.RegisterFile("dvmodel.proto", fileDescriptor_106647ce772da30c) } func init() { golang_proto.RegisterFile("dvmodel.proto", fileDescriptor_106647ce772da30c) } var fileDescriptor_106647ce772da30c = []byte{ - // 1448 bytes of a gzipped FileDescriptorProto + // 1500 bytes of a gzipped FileDescript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, 0x04, 0xa5, 0xb8, 0xaa, 0x69, 0x3b, 0xec, 0x03, 0x20, 0x74, 0x1c, 0x05, + 0xdc, 0xa2, 0x89, 0x90, 0xdf, 0x19, 0x87, 0xfa, 0x7f, 0x26, 0x42, 0xbe, 0x2a, 0x5d, 0xf3, 0x29, + 0x79, 0x79, 0x82, 0xcb, 0xfe, 0x50, 0xe0, 0x33, 0xfe, 0xa1, 0x80, 0x16, 0x58, 0x12, 0xec, 0x0e, + 0xb1, 0x31, 0xe3, 0xd4, 0xc5, 0xda, 0xae, 0xcc, 0xb0, 0x36, 0x3d, 0x25, 0x16, 0x62, 0x0f, 0x12, + 0xef, 0x7c, 0x59, 0xaa, 0x69, 0x28, 0xc4, 0xa0, 0x2a, 0x37, 0x8a, 0x31, 0x62, 0xba, 0x18, 0x6b, + 0x66, 0x7d, 0xa1, 0x59, 0xee, 0x74, 0xa6, 0xea, 0x23, 0x96, 0x1c, 0x3b, 0xe7, 0xcb, 0x53, 0x49, + 0x21, 0x93, 0x34, 0x3e, 0xde, 0x23, 0x78, 0x1f, 0xfb, 0x9a, 0x35, 0x23, 0x4d, 0x2f, 0x76, 0xce, + 0x9f, 0x26, 0x41, 0x26, 0x5d, 0xb1, 0xd1, 0x00, 0xdb, 0x1a, 0x91, 0x39, 0xb2, 0x5d, 0xd9, 0x10, + 0x9e, 0xf9, 0xbb, 0x22, 0x61, 0xd0, 0x06, 0xcb, 0x84, 0xf5, 0x0d, 0xec, 0x61, 0xd7, 0x20, 0xae, + 0x29, 0x24, 0xea, 0x3b, 0x99, 0x63, 0x7d, 0xaa, 0x6e, 0x84, 0xad, 0x27, 0xfe, 0xb4, 0x06, 0xbd, + 0x4a, 0xa2, 0xa5, 0x0c, 0x16, 0x0e, 0x40, 0x85, 0xb0, 0xfe, 0x40, 0x5c, 0x75, 0xe2, 0x9a, 0xda, + 0x48, 0x66, 0x5a, 0x1d, 0x87, 0xfa, 0x4a, 0x92, 0xa9, 0x13, 0xfb, 0xe6, 0x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7, 0xe3, 0xbf, 0xdd, 0x06, 0x25, 0x79, 0x2d, 0x3f, 0xfa, 0x33, + 0x00, 0x00, 0xff, 0xff, 0x09, 0x11, 0xab, 0xc3, 0x88, 0x13, 0x00, 0x00, } func (m *Owner) Marshal() (dAtA []byte, err error) { @@ -857,22 +901,26 @@ func (m *Task) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a } - n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt):]) - if err5 != nil { - return 0, err5 - } - i -= n5 - i = encodeVarintDvmodel(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0x22 - n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CreatedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CreatedAt):]) - if err6 != nil { - return 0, err6 - } - i -= n6 - i = encodeVarintDvmodel(dAtA, i, uint64(n6)) - i-- - dAtA[i] = 0x1a + if m.UpdatedAt != nil { + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.UpdatedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.UpdatedAt):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintDvmodel(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x22 + } + if m.CreatedAt != nil { + n6, err6 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.CreatedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.CreatedAt):]) + if err6 != nil { + return 0, err6 + } + i -= n6 + i = encodeVarintDvmodel(dAtA, i, uint64(n6)) + i-- + dAtA[i] = 0x1a + } if len(m.ID) > 0 { i -= len(m.ID) copy(dAtA[i:], m.ID) @@ -980,6 +1028,71 @@ func (m *Topic) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Batch) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Batch) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Batch) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Topics) > 0 { + for iNdEx := len(m.Topics) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Topics[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDvmodel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Owners) > 0 { + for iNdEx := len(m.Owners) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Owners[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDvmodel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Tasks) > 0 { + for iNdEx := len(m.Tasks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tasks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDvmodel(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintDvmodel(dAtA []byte, offset int, v uint64) int { offset -= sovDvmodel(v) base := offset @@ -1059,10 +1172,14 @@ func (m *Task) Size() (n int) { if l > 0 { n += 1 + l + sovDvmodel(uint64(l)) } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CreatedAt) - n += 1 + l + sovDvmodel(uint64(l)) - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt) - n += 1 + l + sovDvmodel(uint64(l)) + if m.CreatedAt != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.CreatedAt) + n += 1 + l + sovDvmodel(uint64(l)) + } + if m.UpdatedAt != nil { + l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.UpdatedAt) + n += 1 + l + sovDvmodel(uint64(l)) + } l = len(m.LocalID) if l > 0 { n += 1 + l + sovDvmodel(uint64(l)) @@ -1214,6 +1331,33 @@ func (m *Topic) Size() (n int) { return n } +func (m *Batch) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Tasks) > 0 { + for _, e := range m.Tasks { + l = e.Size() + n += 1 + l + sovDvmodel(uint64(l)) + } + } + if len(m.Owners) > 0 { + for _, e := range m.Owners { + l = e.Size() + n += 1 + l + sovDvmodel(uint64(l)) + } + } + if len(m.Topics) > 0 { + for _, e := range m.Topics { + l = e.Size() + n += 1 + l + sovDvmodel(uint64(l)) + } + } + return n +} + func sovDvmodel(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1748,7 +1892,10 @@ func (m *Task) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CreatedAt, dAtA[iNdEx:postIndex]); err != nil { + if m.CreatedAt == nil { + m.CreatedAt = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.CreatedAt, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1781,7 +1928,10 @@ func (m *Task) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { + if m.UpdatedAt == nil { + m.UpdatedAt = new(time.Time) + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -2818,6 +2968,161 @@ func (m *Topic) Unmarshal(dAtA []byte) error { } return nil } +func (m *Batch) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvmodel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Batch: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Batch: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tasks", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvmodel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDvmodel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDvmodel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tasks = append(m.Tasks, &Task{}) + if err := m.Tasks[len(m.Tasks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owners", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvmodel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDvmodel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDvmodel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owners = append(m.Owners, &Owner{}) + if err := m.Owners[len(m.Owners)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Topics", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvmodel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDvmodel + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDvmodel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Topics = append(m.Topics, &Topic{}) + if err := m.Topics[len(m.Topics)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDvmodel(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDvmodel + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDvmodel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipDvmodel(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/internal/dvmodel/model.go b/internal/dvmodel/model.go index 8c3331e53..f07c14f81 100644 --- a/internal/dvmodel/model.go +++ b/internal/dvmodel/model.go @@ -1,9 +1,3 @@ package dvmodel -type Batch struct { - Owners []Owner - Tasks []Task - Topics []Topic -} - type Tasks []Task diff --git a/internal/dvserver/api.go b/internal/dvserver/api.go new file mode 100644 index 000000000..e51ca8fd1 --- /dev/null +++ b/internal/dvserver/api.go @@ -0,0 +1,60 @@ +package dvserver + +import ( + "context" + "fmt" + + "moul.io/depviz/internal/dvcore" + "moul.io/depviz/internal/dvmodel" + "moul.io/depviz/internal/dvparser" + "moul.io/depviz/internal/dvstore" +) + +func (s *service) Graph(ctx context.Context, in *Graph_Input) (*Graph_Output, error) { + // validation + if len(in.Targets) == 0 { + return nil, fmt.Errorf("targets is required") + } + + targets, err := dvparser.ParseTargets(in.Targets) + if err != nil { + return nil, fmt.Errorf("parse targets: %w", err) + } + filters := dvstore.LoadTasksFilters{ + WithClosed: in.WithClosed, + WithoutIsolated: in.WithoutIsolated, + WithoutPRs: in.WithoutPRs, + WithoutExternalDeps: in.WithoutExternalDeps, + Targets: targets, + } + + // load tasks + tasks, err := dvstore.LoadTasks(s.h, s.schema, filters) + if err != nil { + return nil, fmt.Errorf("load tasks: %w", err) + } + + // build output + ret := Graph_Output{ + Tasks: make([]*dvmodel.Task, len(tasks)), + } + for idx, task := range tasks { + ret.Tasks[idx] = &task + } + return &ret, nil +} + +func (s *service) StoreDump(ctx context.Context, in *StoreDump_Input) (*StoreDump_Output, error) { + if !s.opts.Godmode { + return nil, fmt.Errorf("permission denied (--god-mode required)") + } + batch, err := dvcore.GetStoreDump(ctx, s.h, s.schema) + if err != nil { + return nil, fmt.Errorf("store dump: %w", err) + } + + ret := StoreDump_Output{ + Batch: batch, + } + return &ret, nil +} diff --git a/internal/dvserver/doc.go b/internal/dvserver/doc.go new file mode 100644 index 000000000..351df45fa --- /dev/null +++ b/internal/dvserver/doc.go @@ -0,0 +1 @@ +package dvserver // import "moul.io/depviz/internal/dvserver" diff --git a/internal/dvserver/dvserver.pb.go b/internal/dvserver/dvserver.pb.go new file mode 100644 index 000000000..99f622452 --- /dev/null +++ b/internal/dvserver/dvserver.pb.go @@ -0,0 +1,1390 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: dvserver.proto + +package dvserver + +import ( + context "context" + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + dvmodel "moul.io/depviz/internal/dvmodel" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type Graph struct { +} + +func (m *Graph) Reset() { *m = Graph{} } +func (m *Graph) String() string { return proto.CompactTextString(m) } +func (*Graph) ProtoMessage() {} +func (*Graph) Descriptor() ([]byte, []int) { + return fileDescriptor_af3aef303a4c4cd2, []int{0} +} +func (m *Graph) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Graph) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Graph.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Graph) XXX_Merge(src proto.Message) { + xxx_messageInfo_Graph.Merge(m, src) +} +func (m *Graph) XXX_Size() int { + return m.Size() +} +func (m *Graph) XXX_DiscardUnknown() { + xxx_messageInfo_Graph.DiscardUnknown(m) +} + +var xxx_messageInfo_Graph proto.InternalMessageInfo + +type Graph_Input struct { + Targets []string `protobuf:"bytes,1,rep,name=targets,proto3" json:"targets,omitempty"` + WithClosed bool `protobuf:"varint,2,opt,name=with_closed,json=withClosed,proto3" json:"with_closed,omitempty"` + WithoutIsolated bool `protobuf:"varint,3,opt,name=without_isolated,json=withoutIsolated,proto3" json:"without_isolated,omitempty"` + WithoutPRs bool `protobuf:"varint,4,opt,name=without_prs,json=withoutPrs,proto3" json:"without_prs,omitempty"` + WithoutExternalDeps bool `protobuf:"varint,5,opt,name=without_external_deps,json=withoutExternalDeps,proto3" json:"without_external_deps,omitempty"` +} + +func (m *Graph_Input) Reset() { *m = Graph_Input{} } +func (m *Graph_Input) String() string { return proto.CompactTextString(m) } +func (*Graph_Input) ProtoMessage() {} +func (*Graph_Input) Descriptor() ([]byte, []int) { + return fileDescriptor_af3aef303a4c4cd2, []int{0, 0} +} +func (m *Graph_Input) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Graph_Input) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Graph_Input.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Graph_Input) XXX_Merge(src proto.Message) { + xxx_messageInfo_Graph_Input.Merge(m, src) +} +func (m *Graph_Input) XXX_Size() int { + return m.Size() +} +func (m *Graph_Input) XXX_DiscardUnknown() { + xxx_messageInfo_Graph_Input.DiscardUnknown(m) +} + +var xxx_messageInfo_Graph_Input proto.InternalMessageInfo + +func (m *Graph_Input) GetTargets() []string { + if m != nil { + return m.Targets + } + return nil +} + +func (m *Graph_Input) GetWithClosed() bool { + if m != nil { + return m.WithClosed + } + return false +} + +func (m *Graph_Input) GetWithoutIsolated() bool { + if m != nil { + return m.WithoutIsolated + } + return false +} + +func (m *Graph_Input) GetWithoutPRs() bool { + if m != nil { + return m.WithoutPRs + } + return false +} + +func (m *Graph_Input) GetWithoutExternalDeps() bool { + if m != nil { + return m.WithoutExternalDeps + } + return false +} + +type Graph_Output struct { + Tasks []*dvmodel.Task `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"` +} + +func (m *Graph_Output) Reset() { *m = Graph_Output{} } +func (m *Graph_Output) String() string { return proto.CompactTextString(m) } +func (*Graph_Output) ProtoMessage() {} +func (*Graph_Output) Descriptor() ([]byte, []int) { + return fileDescriptor_af3aef303a4c4cd2, []int{0, 1} +} +func (m *Graph_Output) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Graph_Output) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Graph_Output.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Graph_Output) XXX_Merge(src proto.Message) { + xxx_messageInfo_Graph_Output.Merge(m, src) +} +func (m *Graph_Output) XXX_Size() int { + return m.Size() +} +func (m *Graph_Output) XXX_DiscardUnknown() { + xxx_messageInfo_Graph_Output.DiscardUnknown(m) +} + +var xxx_messageInfo_Graph_Output proto.InternalMessageInfo + +func (m *Graph_Output) GetTasks() []*dvmodel.Task { + if m != nil { + return m.Tasks + } + return nil +} + +type StoreDump struct { +} + +func (m *StoreDump) Reset() { *m = StoreDump{} } +func (m *StoreDump) String() string { return proto.CompactTextString(m) } +func (*StoreDump) ProtoMessage() {} +func (*StoreDump) Descriptor() ([]byte, []int) { + return fileDescriptor_af3aef303a4c4cd2, []int{1} +} +func (m *StoreDump) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreDump) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreDump.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreDump) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreDump.Merge(m, src) +} +func (m *StoreDump) XXX_Size() int { + return m.Size() +} +func (m *StoreDump) XXX_DiscardUnknown() { + xxx_messageInfo_StoreDump.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreDump proto.InternalMessageInfo + +type StoreDump_Input struct { +} + +func (m *StoreDump_Input) Reset() { *m = StoreDump_Input{} } +func (m *StoreDump_Input) String() string { return proto.CompactTextString(m) } +func (*StoreDump_Input) ProtoMessage() {} +func (*StoreDump_Input) Descriptor() ([]byte, []int) { + return fileDescriptor_af3aef303a4c4cd2, []int{1, 0} +} +func (m *StoreDump_Input) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreDump_Input) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreDump_Input.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreDump_Input) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreDump_Input.Merge(m, src) +} +func (m *StoreDump_Input) XXX_Size() int { + return m.Size() +} +func (m *StoreDump_Input) XXX_DiscardUnknown() { + xxx_messageInfo_StoreDump_Input.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreDump_Input proto.InternalMessageInfo + +type StoreDump_Output struct { + Batch *dvmodel.Batch `protobuf:"bytes,1,opt,name=batch,proto3" json:"batch,omitempty"` +} + +func (m *StoreDump_Output) Reset() { *m = StoreDump_Output{} } +func (m *StoreDump_Output) String() string { return proto.CompactTextString(m) } +func (*StoreDump_Output) ProtoMessage() {} +func (*StoreDump_Output) Descriptor() ([]byte, []int) { + return fileDescriptor_af3aef303a4c4cd2, []int{1, 1} +} +func (m *StoreDump_Output) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StoreDump_Output) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StoreDump_Output.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *StoreDump_Output) XXX_Merge(src proto.Message) { + xxx_messageInfo_StoreDump_Output.Merge(m, src) +} +func (m *StoreDump_Output) XXX_Size() int { + return m.Size() +} +func (m *StoreDump_Output) XXX_DiscardUnknown() { + xxx_messageInfo_StoreDump_Output.DiscardUnknown(m) +} + +var xxx_messageInfo_StoreDump_Output proto.InternalMessageInfo + +func (m *StoreDump_Output) GetBatch() *dvmodel.Batch { + if m != nil { + return m.Batch + } + return nil +} + +func init() { + proto.RegisterType((*Graph)(nil), "depviz.server.Graph") + proto.RegisterType((*Graph_Input)(nil), "depviz.server.Graph.Input") + proto.RegisterType((*Graph_Output)(nil), "depviz.server.Graph.Output") + proto.RegisterType((*StoreDump)(nil), "depviz.server.StoreDump") + proto.RegisterType((*StoreDump_Input)(nil), "depviz.server.StoreDump.Input") + proto.RegisterType((*StoreDump_Output)(nil), "depviz.server.StoreDump.Output") +} + +func init() { proto.RegisterFile("dvserver.proto", fileDescriptor_af3aef303a4c4cd2) } + +var fileDescriptor_af3aef303a4c4cd2 = []byte{ + // 499 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x9b, 0x8e, 0x76, 0x9b, 0xab, 0x16, 0xe4, 0x0a, 0x29, 0x0a, 0x28, 0xad, 0x7a, 0xea, + 0x0e, 0x8d, 0xa5, 0xee, 0xc6, 0xb1, 0x14, 0xa1, 0x9e, 0x98, 0x5a, 0x24, 0x24, 0x2e, 0x95, 0x9b, + 0x3c, 0xdc, 0x68, 0x69, 0x6c, 0xd9, 0x4e, 0xca, 0x38, 0xf2, 0x09, 0x26, 0xf1, 0x95, 0x38, 0x70, + 0x9c, 0xe0, 0xc2, 0x09, 0xa1, 0x96, 0x0f, 0x82, 0x62, 0xbb, 0xd3, 0x86, 0xc6, 0xcd, 0xef, 0xff, + 0xff, 0xfb, 0xf7, 0xec, 0x17, 0x07, 0x75, 0x92, 0x52, 0x81, 0x2c, 0x41, 0x46, 0x42, 0x72, 0xcd, + 0x71, 0x3b, 0x01, 0x51, 0xa6, 0x9f, 0x22, 0x2b, 0x06, 0xcf, 0x19, 0xe7, 0x2c, 0x03, 0x42, 0x45, + 0x4a, 0x68, 0x9e, 0x73, 0x4d, 0x75, 0xca, 0x73, 0x65, 0xc3, 0xc1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, 0x77, 0x76, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff, 0x87, 0xcc, 0xd0, 0xed, 0x39, + 0x03, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// DepvizServiceClient is the client API for DepvizService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type DepvizServiceClient interface { + Graph(ctx context.Context, in *Graph_Input, opts ...grpc.CallOption) (*Graph_Output, error) + StoreDump(ctx context.Context, in *StoreDump_Input, opts ...grpc.CallOption) (*StoreDump_Output, error) +} + +type depvizServiceClient struct { + cc *grpc.ClientConn +} + +func NewDepvizServiceClient(cc *grpc.ClientConn) DepvizServiceClient { + return &depvizServiceClient{cc} +} + +func (c *depvizServiceClient) Graph(ctx context.Context, in *Graph_Input, opts ...grpc.CallOption) (*Graph_Output, error) { + out := new(Graph_Output) + err := c.cc.Invoke(ctx, "/depviz.server.DepvizService/Graph", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *depvizServiceClient) StoreDump(ctx context.Context, in *StoreDump_Input, opts ...grpc.CallOption) (*StoreDump_Output, error) { + out := new(StoreDump_Output) + err := c.cc.Invoke(ctx, "/depviz.server.DepvizService/StoreDump", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DepvizServiceServer is the server API for DepvizService service. +type DepvizServiceServer interface { + Graph(context.Context, *Graph_Input) (*Graph_Output, error) + StoreDump(context.Context, *StoreDump_Input) (*StoreDump_Output, error) +} + +// UnimplementedDepvizServiceServer can be embedded to have forward compatible implementations. +type UnimplementedDepvizServiceServer struct { +} + +func (*UnimplementedDepvizServiceServer) Graph(ctx context.Context, req *Graph_Input) (*Graph_Output, error) { + return nil, status.Errorf(codes.Unimplemented, "method Graph not implemented") +} +func (*UnimplementedDepvizServiceServer) StoreDump(ctx context.Context, req *StoreDump_Input) (*StoreDump_Output, error) { + return nil, status.Errorf(codes.Unimplemented, "method StoreDump not implemented") +} + +func RegisterDepvizServiceServer(s *grpc.Server, srv DepvizServiceServer) { + s.RegisterService(&_DepvizService_serviceDesc, srv) +} + +func _DepvizService_Graph_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Graph_Input) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepvizServiceServer).Graph(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/depviz.server.DepvizService/Graph", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepvizServiceServer).Graph(ctx, req.(*Graph_Input)) + } + return interceptor(ctx, in, info, handler) +} + +func _DepvizService_StoreDump_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StoreDump_Input) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepvizServiceServer).StoreDump(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/depviz.server.DepvizService/StoreDump", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepvizServiceServer).StoreDump(ctx, req.(*StoreDump_Input)) + } + return interceptor(ctx, in, info, handler) +} + +var _DepvizService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "depviz.server.DepvizService", + HandlerType: (*DepvizServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Graph", + Handler: _DepvizService_Graph_Handler, + }, + { + MethodName: "StoreDump", + Handler: _DepvizService_StoreDump_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "dvserver.proto", +} + +func (m *Graph) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Graph) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Graph) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *Graph_Input) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Graph_Input) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Graph_Input) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.WithoutExternalDeps { + i-- + if m.WithoutExternalDeps { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.WithoutPRs { + i-- + if m.WithoutPRs { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.WithoutIsolated { + i-- + if m.WithoutIsolated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if m.WithClosed { + i-- + if m.WithClosed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.Targets) > 0 { + for iNdEx := len(m.Targets) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Targets[iNdEx]) + copy(dAtA[i:], m.Targets[iNdEx]) + i = encodeVarintDvserver(dAtA, i, uint64(len(m.Targets[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *Graph_Output) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Graph_Output) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Graph_Output) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Tasks) > 0 { + for iNdEx := len(m.Tasks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tasks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDvserver(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *StoreDump) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreDump) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreDump) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *StoreDump_Input) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreDump_Input) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreDump_Input) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *StoreDump_Output) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *StoreDump_Output) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StoreDump_Output) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Batch != nil { + { + size, err := m.Batch.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDvserver(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDvserver(dAtA []byte, offset int, v uint64) int { + offset -= sovDvserver(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Graph) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *Graph_Input) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Targets) > 0 { + for _, s := range m.Targets { + l = len(s) + n += 1 + l + sovDvserver(uint64(l)) + } + } + if m.WithClosed { + n += 2 + } + if m.WithoutIsolated { + n += 2 + } + if m.WithoutPRs { + n += 2 + } + if m.WithoutExternalDeps { + n += 2 + } + return n +} + +func (m *Graph_Output) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Tasks) > 0 { + for _, e := range m.Tasks { + l = e.Size() + n += 1 + l + sovDvserver(uint64(l)) + } + } + return n +} + +func (m *StoreDump) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *StoreDump_Input) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *StoreDump_Output) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Batch != nil { + l = m.Batch.Size() + n += 1 + l + sovDvserver(uint64(l)) + } + return n +} + +func sovDvserver(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDvserver(x uint64) (n int) { + return sovDvserver(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Graph) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Graph: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Graph: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipDvserver(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Graph_Input) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Input: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Input: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Targets", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthDvserver + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDvserver + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Targets = append(m.Targets, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithClosed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.WithClosed = bool(v != 0) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithoutIsolated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.WithoutIsolated = bool(v != 0) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithoutPRs", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.WithoutPRs = bool(v != 0) + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithoutExternalDeps", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.WithoutExternalDeps = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipDvserver(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Graph_Output) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Output: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Output: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tasks", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDvserver + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDvserver + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tasks = append(m.Tasks, &dvmodel.Task{}) + if err := m.Tasks[len(m.Tasks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDvserver(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreDump) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: StoreDump: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StoreDump: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipDvserver(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreDump_Input) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Input: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Input: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipDvserver(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StoreDump_Output) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Output: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Output: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Batch", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDvserver + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDvserver + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDvserver + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Batch == nil { + m.Batch = &dvmodel.Batch{} + } + if err := m.Batch.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDvserver(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthDvserver + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDvserver(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDvserver + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDvserver + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDvserver + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthDvserver + } + iNdEx += length + if iNdEx < 0 { + return 0, ErrInvalidLengthDvserver + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowDvserver + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipDvserver(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + if iNdEx < 0 { + return 0, ErrInvalidLengthDvserver + } + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthDvserver = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDvserver = fmt.Errorf("proto: integer overflow") +) diff --git a/internal/dvserver/dvserver.pb.gw.go b/internal/dvserver/dvserver.pb.gw.go new file mode 100644 index 000000000..4b0f28317 --- /dev/null +++ b/internal/dvserver/dvserver.pb.gw.go @@ -0,0 +1,221 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: dvserver.proto + +/* +Package dvserver is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package dvserver + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray + +var ( + filter_DepvizService_Graph_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_DepvizService_Graph_0(ctx context.Context, marshaler runtime.Marshaler, client DepvizServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq Graph_Input + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepvizService_Graph_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Graph(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_DepvizService_Graph_0(ctx context.Context, marshaler runtime.Marshaler, server DepvizServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq Graph_Input + var metadata runtime.ServerMetadata + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_DepvizService_Graph_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Graph(ctx, &protoReq) + return msg, metadata, err + +} + +func request_DepvizService_StoreDump_0(ctx context.Context, marshaler runtime.Marshaler, client DepvizServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StoreDump_Input + var metadata runtime.ServerMetadata + + msg, err := client.StoreDump(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_DepvizService_StoreDump_0(ctx context.Context, marshaler runtime.Marshaler, server DepvizServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq StoreDump_Input + var metadata runtime.ServerMetadata + + msg, err := server.StoreDump(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterDepvizServiceHandlerServer registers the http handlers for service DepvizService to "mux". +// UnaryRPC :call DepvizServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +func RegisterDepvizServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DepvizServiceServer) error { + + mux.Handle("GET", pattern_DepvizService_Graph_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DepvizService_Graph_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_DepvizService_Graph_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_DepvizService_StoreDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DepvizService_StoreDump_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_DepvizService_StoreDump_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterDepvizServiceHandlerFromEndpoint is same as RegisterDepvizServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterDepvizServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterDepvizServiceHandler(ctx, mux, conn) +} + +// RegisterDepvizServiceHandler registers the http handlers for service DepvizService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterDepvizServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterDepvizServiceHandlerClient(ctx, mux, NewDepvizServiceClient(conn)) +} + +// RegisterDepvizServiceHandlerClient registers the http handlers for service DepvizService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DepvizServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DepvizServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "DepvizServiceClient" to call the correct interceptors. +func RegisterDepvizServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DepvizServiceClient) error { + + mux.Handle("GET", pattern_DepvizService_Graph_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DepvizService_Graph_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_DepvizService_Graph_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_DepvizService_StoreDump_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DepvizService_StoreDump_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_DepvizService_StoreDump_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_DepvizService_Graph_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"graph"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_DepvizService_StoreDump_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"store", "dump"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_DepvizService_Graph_0 = runtime.ForwardResponseMessage + + forward_DepvizService_StoreDump_0 = runtime.ForwardResponseMessage +) diff --git a/internal/dvserver/server.go b/internal/dvserver/server.go new file mode 100644 index 000000000..1d84517e3 --- /dev/null +++ b/internal/dvserver/server.go @@ -0,0 +1,215 @@ +package dvserver + +import ( + "context" + "fmt" + "net" + "net/http" + "net/http/pprof" + "strings" + "time" + + "github.com/cayleygraph/cayley" + "github.com/cayleygraph/cayley/schema" + "github.com/go-chi/chi" + "github.com/go-chi/chi/middleware" + "github.com/gobuffalo/packr/v2" + "github.com/gogo/gateway" + grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware" + grpc_zap "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap" + grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/oklog/run" + "github.com/rs/cors" + chilogger "github.com/treastech/logger" + "go.uber.org/zap" + "google.golang.org/grpc" + "moul.io/depviz/internal/chiutil" +) + +type Opts struct { + Logger *zap.Logger + HTTPBind string + GRPCBind string + CORSAllowedOrigins string + ShutdownTimeout time.Duration + RequestTimeout time.Duration + WithoutRecovery bool + WithPprof bool + Godmode bool +} + +type Service interface { + DepvizServiceServer + Run() error + Close() + HTTPListenerAddr() string + GRPCListenerAddr() string +} + +type service struct { + ctx context.Context + schema *schema.Config + h *cayley.Handle + opts Opts + workers run.Group + grpcServer *grpc.Server + grpcListenerAddr string + httpListenerAddr string +} + +var _ DepvizServiceServer = (*service)(nil) + +func New(ctx context.Context, h *cayley.Handle, schema *schema.Config, opts Opts) (Service, error) { + if opts.Logger == nil { + opts.Logger = zap.NewNop() + } + if opts.HTTPBind == "" { + opts.HTTPBind = ":0" + } + if opts.GRPCBind == "" { + opts.GRPCBind = ":0" + } + if opts.CORSAllowedOrigins == "" { + opts.CORSAllowedOrigins = "*" + } + + svc := service{ + ctx: ctx, + h: h, + schema: schema, + opts: opts, + } + + var ( + grpcLogger = opts.Logger.Named("gRPC") + httpLogger = opts.Logger.Named("HTTP") + ) + + { // local gRPC server + serverStreamOpts := []grpc.StreamServerInterceptor{ + grpc_zap.StreamServerInterceptor(grpcLogger), + // auth + } + serverUnaryOpts := []grpc.UnaryServerInterceptor{ + grpc_zap.UnaryServerInterceptor(grpcLogger), + // auth + } + + if !opts.WithoutRecovery { + serverStreamOpts = append([]grpc.StreamServerInterceptor{grpc_recovery.StreamServerInterceptor()}, serverStreamOpts...) + serverStreamOpts = append(serverStreamOpts, grpc_recovery.StreamServerInterceptor()) + serverUnaryOpts = append([]grpc.UnaryServerInterceptor{grpc_recovery.UnaryServerInterceptor()}, serverUnaryOpts...) + serverUnaryOpts = append(serverUnaryOpts, grpc_recovery.UnaryServerInterceptor()) + } + + grpcServer := grpc.NewServer( + grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(serverStreamOpts...)), + grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(serverUnaryOpts...)), + ) + RegisterDepvizServiceServer(grpcServer, &svc) + svc.grpcServer = grpcServer + } + + if opts.HTTPBind != "" || opts.GRPCBind != "" { // grpcbind is required for grpc-gateway (for now) + grpcListener, err := net.Listen("tcp", opts.GRPCBind) + if err != nil { + return nil, fmt.Errorf("start gRPC listener: %w", err) + } + svc.grpcListenerAddr = grpcListener.Addr().String() + + svc.workers.Add(func() error { + grpcLogger.Debug("starting gRPC server", zap.String("bind", opts.GRPCBind)) + return svc.grpcServer.Serve(grpcListener) + }, func(error) { + if err := grpcListener.Close(); err != nil { + grpcLogger.Warn("close gRPC listener", zap.Error(err)) + } + }) + } + + if opts.HTTPBind != "" { + r := chi.NewRouter() + cors := cors.New(cors.Options{ + AllowedOrigins: strings.Split(opts.CORSAllowedOrigins, ","), + AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"}, + ExposedHeaders: []string{"Link"}, + AllowCredentials: true, + MaxAge: 300, + }) + r.Use(cors.Handler) + r.Use(chilogger.Logger(httpLogger)) + r.Use(middleware.Recoverer) + r.Use(middleware.Timeout(opts.RequestTimeout)) + r.Use(middleware.RealIP) + r.Use(middleware.RequestID) + // FIXME: add caching + gwmux := runtime.NewServeMux( + runtime.WithMarshalerOption(runtime.MIMEWildcard, &gateway.JSONPb{ + EmitDefaults: false, + Indent: " ", + OrigName: true, + }), + runtime.WithProtoErrorHandler(runtime.DefaultHTTPProtoErrorHandler), + ) + grpcOpts := []grpc.DialOption{grpc.WithInsecure()} + if err := RegisterDepvizServiceHandlerFromEndpoint(ctx, gwmux, svc.grpcListenerAddr, grpcOpts); err != nil { + return nil, fmt.Errorf("register service on gateway: %w", err) + } + + // api endpoints + r.Mount("/api", http.StripPrefix("/api", gwmux)) + + // pprof endpoints + if opts.WithPprof { + r.HandleFunc("/debug/pprof/*", pprof.Index) + r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) + r.HandleFunc("/debug/pprof/profile", pprof.Profile) + r.HandleFunc("/debug/pprof/symbol", pprof.Symbol) + r.HandleFunc("/debug/pprof/trace", pprof.Trace) + } + + // static content + box := packr.New("static", "./static") + chiutil.FileServer(r, "/", box) + + http.DefaultServeMux = http.NewServeMux() // disables default handlers registere by importing net/http/pprof for security reasons + listener, err := net.Listen("tcp", opts.HTTPBind) + if err != nil { + return nil, fmt.Errorf("start HTTP listener: %w", err) + } + svc.httpListenerAddr = listener.Addr().String() + srv := http.Server{ + Handler: r, + } + svc.workers.Add(func() error { + httpLogger.Debug("starting HTTP server", zap.String("bind", opts.HTTPBind)) + return srv.Serve(listener) + }, func(error) { + ctx, cancel := context.WithTimeout(ctx, opts.ShutdownTimeout) + if err := srv.Shutdown(ctx); err != nil { + httpLogger.Warn("shutdown HTTP server", zap.Error(err)) + } + defer cancel() + if err := listener.Close(); err != nil { + httpLogger.Warn("close HTTP listener", zap.Error(err)) + } + }) + } + + // FIXME: add grpc-web support? + + return &svc, nil +} + +func (s *service) Run() error { + return s.workers.Run() +} + +func (s *service) Close() { + s.grpcServer.GracefulStop() +} + +func (s service) HTTPListenerAddr() string { return s.httpListenerAddr } +func (s service) GRPCListenerAddr() string { return s.grpcListenerAddr } diff --git a/internal/githubprovider/model.go b/internal/githubprovider/model.go index 1f2ff289b..1b66776b3 100644 --- a/internal/githubprovider/model.go +++ b/internal/githubprovider/model.go @@ -37,8 +37,8 @@ func fromIssue(batch *dvmodel.Batch, input *github.Issue) error { issue := dvmodel.Task{ ID: quad.IRI(entity.String()), LocalID: entity.LocalID(), - CreatedAt: input.GetCreatedAt(), - UpdatedAt: input.GetUpdatedAt(), + CreatedAt: input.CreatedAt, + UpdatedAt: input.UpdatedAt, Title: input.GetTitle(), Description: input.GetBody(), Driver: dvmodel.Driver_GitHub, @@ -140,7 +140,7 @@ func fromIssue(batch *dvmodel.Batch, input *github.Issue) error { } } - batch.Tasks = append(batch.Tasks, issue) + batch.Tasks = append(batch.Tasks, &issue) return nil } @@ -184,7 +184,7 @@ func fromUser(batch *dvmodel.Batch, input *github.User) (*dvmodel.Owner, error) updated := input.GetUpdatedAt().Time user.UpdatedAt = &updated } - batch.Owners = append(batch.Owners, user) + batch.Owners = append(batch.Owners, &user) return &user, nil } @@ -198,8 +198,8 @@ func fromMilestone(batch *dvmodel.Batch, input *github.Milestone) (*dvmodel.Task ID: quad.IRI(entity.String()), LocalID: entity.LocalID(), Kind: dvmodel.Task_Milestone, - CreatedAt: input.GetCreatedAt(), - UpdatedAt: input.GetUpdatedAt(), + CreatedAt: input.CreatedAt, + UpdatedAt: input.UpdatedAt, Title: input.GetTitle(), Description: input.GetDescription(), Driver: dvmodel.Driver_GitHub, @@ -236,7 +236,7 @@ func fromMilestone(batch *dvmodel.Batch, input *github.Milestone) (*dvmodel.Task repo := multipmuri.RepoEntity(entity) milestone.HasOwner = quad.IRI(repo.String()) - batch.Tasks = append(batch.Tasks, milestone) + batch.Tasks = append(batch.Tasks, &milestone) return &milestone, err } @@ -257,7 +257,7 @@ func fromRepoURL(batch *dvmodel.Batch, url string) (*dvmodel.Owner, error) { repoOwner := multipmuri.OwnerEntity(entity) repo.HasOwner = quad.IRI(repoOwner.String()) - batch.Owners = append(batch.Owners, repo) + batch.Owners = append(batch.Owners, &repo) return &repo, err } @@ -278,6 +278,6 @@ func fromLabel(batch *dvmodel.Batch, input *github.Label) (*dvmodel.Topic, error repo := multipmuri.RepoEntity(entity) topic.HasOwner = quad.IRI(repo.String()) - batch.Topics = append(batch.Topics, topic) + batch.Topics = append(batch.Topics, &topic) return &topic, nil }