From a9573b7cc5f2071ece6e28f5e1edbe3de5499378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Montes?= Date: Mon, 6 Jun 2022 20:36:24 +0200 Subject: [PATCH] Migrated to go 1.18 and imrovements in CI/CD --- .github/workflows/ci.yml | 63 ++++ .github/workflows/release.yml | 83 ++++- .golangci.yml | 37 +++ .goreleaser.yml | 24 ++ Dockerfile | 16 +- Makefile | 98 ++++++ README.md | 2 +- cmd/catalog/Makefile | 17 - cmd/catalog/api/handlers.go | 6 +- cmd/catalog/model/dao.go | 5 +- cmd/route/Makefile | 26 -- cmd/route/client/client.go | 90 ----- cmd/route/config/config.go | 10 - cmd/route/main.go | 21 -- cmd/route/scripts/run-dev.sh | 21 -- cmd/route/server/data.go | 603 ---------------------------------- cmd/route/server/geom.go | 47 --- cmd/route/server/server.go | 140 -------- cmd/stock/Makefile | 17 - cmd/stock/api/handlers.go | 8 +- docker-compose.redis.yml | 11 + docker-compose.yml | 9 - go.mod | 13 +- go.sum | 28 -- pkg/route/data.go | 44 --- pkg/route/pb/Makefile | 4 - pkg/route/pb/route.pb.go | 490 --------------------------- pkg/route/pb/route.proto | 39 --- pkg/route/pb/route_grpc.pb.go | 303 ----------------- pkg/route/route.go | 133 -------- scripts/tmux.sh | 24 -- 31 files changed, 339 insertions(+), 2093 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .golangci.yml create mode 100644 .goreleaser.yml create mode 100644 Makefile delete mode 100644 cmd/catalog/Makefile delete mode 100644 cmd/route/Makefile delete mode 100644 cmd/route/client/client.go delete mode 100644 cmd/route/config/config.go delete mode 100644 cmd/route/main.go delete mode 100755 cmd/route/scripts/run-dev.sh delete mode 100644 cmd/route/server/data.go delete mode 100644 cmd/route/server/geom.go delete mode 100644 cmd/route/server/server.go delete mode 100644 cmd/stock/Makefile create mode 100644 docker-compose.redis.yml delete mode 100644 pkg/route/data.go delete mode 100644 pkg/route/pb/Makefile delete mode 100644 pkg/route/pb/route.pb.go delete mode 100644 pkg/route/pb/route.proto delete mode 100644 pkg/route/pb/route_grpc.pb.go delete mode 100644 pkg/route/route.go delete mode 100755 scripts/tmux.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4922611 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: CI + +on: + pull_request: + branches: + - "**" + push: + branches: + - "**" + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 + + - name: Checkout code + uses: actions/checkout@v3 + + - name: GolangCI Lint + uses: golangci/golangci-lint-action@v3 + with: + version: v1.46.2 + + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build + run: make build + + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.18 + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Test + run: make cover + + - name: Coverage + uses: actions/upload-artifact@v2 + with: + name: cover + path: ./cover.html diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6012bb4..ad15e74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,24 +3,91 @@ name: Release on: push: tags: - - "v*" + - "*" jobs: release: - name: Release runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Fetch tags + run: git fetch --force --tags + - name: Setup QEMU uses: docker/setup-qemu-action@v1 - name: Setup Docker Buildx uses: docker/setup-buildx-action@v1 + id: buildx - - name: Check out code - uses: actions/checkout@v2 + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Prepare + id: prep + run: | + VERSION=sha-${GITHUB_SHA::8} + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF/refs\/tags\//} + fi + echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=VERSION::${VERSION} + + - name: Publish multi-arch Catalog Docker image + uses: docker/build-push-action@v2 + with: + push: true + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + build-args: | + SERVICE=catalog + platforms: linux/arm64,linux/amd64 + tags: | + docker.io/gotwaygateway/catalog:${{ steps.prep.outputs.VERSION }} + docker.io/gotwaygateway/catalog:latest + labels: | + org.opencontainers.image.title=catalog + org.opencontainers.image.description=${{ github.event.repository.description }} + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.url=${{ github.event.repository.html_url }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }} + org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }} + + - name: Publish multi-arch Stock Docker image + uses: docker/build-push-action@v2 + with: + push: true + builder: ${{ steps.buildx.outputs.name }} + context: . + file: ./Dockerfile + build-args: | + SERVICE=stock + platforms: linux/arm64,linux/amd64 + tags: | + docker.io/gotwaygateway/stock:${{ steps.prep.outputs.VERSION }} + docker.io/gotwaygateway/stock:latest + labels: | + org.opencontainers.image.title=stock + org.opencontainers.image.description=${{ github.event.repository.description }} + org.opencontainers.image.source=${{ github.event.repository.html_url }} + org.opencontainers.image.url=${{ github.event.repository.html_url }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }} + org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }} - - name: Release + - name: GoReleaser + uses: goreleaser/goreleaser-action@v3 + with: + version: latest + args: release env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: ./scripts/release.sh + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..e89969f --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,37 @@ +linters-settings: + dupl: + threshold: 100 + gocyclo: + min-complexity: 15 + lll: + line-length: 140 + misspell: + locale: US + +linters: + disable-all: true + enable: + - deadcode + - dupl + - errcheck + - gocyclo + - gofmt + - goimports + - gosimple + - govet + - ineffassign + - lll + - misspell + - nestif + - staticcheck + - typecheck + - unused + - varcheck + # not compatible with go 1.18 yet + # - bodyclose + # - noctx + # - structcheck + +run: + timeout: 5m + go: "1.18" diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..8955bc8 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,24 @@ +project_name: services +builds: + - id: catalog + main: ./cmd/catalog + binary: catalog + goos: + - linux + goarch: + - arm64 + - amd64 + env: + - CGO_ENABLED=0 + - id: stock + main: ./cmd/stock + binary: stock + goos: + - linux + goarch: + - arm64 + - amd64 + env: + - CGO_ENABLED=0 +archives: + - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" diff --git a/Dockerfile b/Dockerfile index bec9fc9..edb471b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,21 @@ -FROM golang:1.15-alpine3.12 AS builder +FROM golang:1.18.3-alpine3.16 AS builder ARG SERVICE - -ENV WORKDIR /go/src/gotway +RUN test -n "$SERVICE" || (echo "Build argument \"SERVICE\" not set" && false) +ENV WORKDIR /go/src/services RUN mkdir -p ${WORKDIR} WORKDIR ${WORKDIR} +RUN apk update && \ + apk add --no-cache --update make bash git ca-certificates && \ + update-ca-certificates + COPY . . -RUN CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' -o bin/app cmd/$SERVICE/*.go +RUN make build-$SERVICE -FROM alpine:3.12.0 +FROM alpine:3.16.0 -COPY --from=builder /go/src/gotway/bin/app /app +COPY --from=builder /go/src/services/bin/app /app CMD [ "/app" ] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..377fd0c --- /dev/null +++ b/Makefile @@ -0,0 +1,98 @@ +ROOT := $(shell git rev-parse --show-toplevel) +OS := $(shell uname -s | awk '{print tolower($$0)}') +ARCH := amd64 +VERSION := $(shell git describe --abbrev=0 --tags) +LD_FLAGS := -X main.version=$(VERSION) -s -w +SOURCE_FILES ?= ./internal/... ./pkg/... ./cmd/... + +export CGO_ENABLED := 0 +export GO111MODULE := on +export GOBIN := $(shell pwd)/bin + +.PHONY: all +all: help + +.PHONY: help +help: ### Show targets documentation +ifeq ($(OS), linux) + @grep -P '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \ + awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' +else + @awk -F ':.*###' '$$0 ~ FS {printf "%15s%s\n", $$1 ":", $$2}' \ + $(MAKEFILE_LIST) | grep -v '@awk' | sort +endif + +GOLANGCI_LINT := $(GOBIN)/golangci-lint +GOLANGCI_LINT_VERSION := v1.46.2 +golangci-lint: + $(call go-install,github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)) + +GORELEASER := $(GOBIN)/goreleaser +GORELEASER_VERSION := v1.9.2 +goreleaser: + $(call go-install,github.com/goreleaser/goreleaser@$(GORELEASER_VERSION)) + +.PHONY: generate +generate: vendor ### Generate code + @bash ./hack/hack.sh + +.PHONY: docker-redis + docker-redis: ### Spin up docker redis + @docker compose -f docker-compose.redis.yml up -d + +.PHONY: docker +docker: ### Spin up docker services + @docker compose -f docker-compose.redis.yml -f docker-compose.yml up -d + +.PHONY: clean +clean: ### Clean build files + @rm -rf ./bin + @go clean + +.PHONY: build +build: build-catalog build-stock ### Build all binaries + +.PHONY: build-% +build-%: clean ### Build binary + @go build -tags netgo -a -v -ldflags "${LD_FLAGS}" -o ./bin/app ./cmd/$*/*.go + @chmod +x ./bin/* + +.PHONY: run-% +run-%: lint ### Quick run + @CGO_ENABLED=1 go run -race cmd/$*/*.go + +.PHONY: deps +deps: ### Optimize dependencies + @go mod tidy + +.PHONY: vendor +vendor: ### Vendor dependencies + @go mod vendor + +.PHONY: lint +lint: golangci-lint ### Lint + $(GOLANGCI_LINT) run + +.PHONY: release +release: goreleaser ### Dry-run release + $(GORELEASER) release --snapshot --rm-dist + +.PHONY: test-clean +test-clean: ### Clean test cache + @go clean -testcache ./... + +.PHONY: test +test: ### Run tests + @go test -v -coverprofile=cover.out -timeout 10s ./... + +.PHONY: cover +cover: test ### Run tests and generate coverage + @go tool cover -html=cover.out -o=cover.html + +# go-get-tool will 'go get' any package $2 and install it to $1. +PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) +define go-install +@[ -f $(1) ] || { \ +go install $(1) ; \ +} +endef diff --git a/README.md b/README.md index 1ffba96..5dbb433 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # service-examples +[![CI](https://github.com/gotway/service-examples/actions/workflows/ci.yml/badge.svg)](https://github.com/gotway/service-examples/actions/workflows/ci.yml) [![Release](https://github.com/gotway/service-examples/actions/workflows/release.yml/badge.svg)](https://github.com/gotway/service-examples/actions/workflows/release.yml) Service examples used for testing purposes @@ -8,4 +9,3 @@ Service examples used for testing purposes |-------|------|-----| |[Catalog](./cmd/catalog)|[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/ac7596f337b868ab0e6c#?env%5BGotway%20Local%5D=W3sia2V5IjoidXJsIiwidmFsdWUiOiJodHRwczovL2xvY2FsaG9zdDo4MDAwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJ1cmxDYXRhbG9nIiwidmFsdWUiOiJodHRwOi8vbG9jYWxob3N0OjkwMDAiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6InVybFJvdXRlIiwidmFsdWUiOiJodHRwOi8vbG9jYWxob3N0OjExMDAwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJ1cmxTdG9jayIsInZhbHVlIjoiaHR0cDovL2xvY2FsaG9zdDoxMDAwMCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoicHJvZHVjdElkIiwidmFsdWUiOiIxMjM0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJwcm9kdWN0SWQyIiwidmFsdWUiOiI0NTYiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6InByb2R1Y3RJZDMiLCJ2YWx1ZSI6Ijc4OSIsImVuYWJsZWQiOnRydWV9XQ==)|[gotwaygateway/catalog](https://hub.docker.com/r/gotwaygateway/catalog/tags)| |[Stock](./cmd/stock)|[![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/bdb7fe928c1e93fb15e5#?env%5BGotway%20Local%5D=W3sia2V5IjoidXJsIiwidmFsdWUiOiJodHRwczovL2xvY2FsaG9zdDo4MDAwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJ1cmxDYXRhbG9nIiwidmFsdWUiOiJodHRwOi8vbG9jYWxob3N0OjkwMDAiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6InVybFJvdXRlIiwidmFsdWUiOiJodHRwOi8vbG9jYWxob3N0OjExMDAwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJ1cmxTdG9jayIsInZhbHVlIjoiaHR0cDovL2xvY2FsaG9zdDoxMDAwMCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoicHJvZHVjdElkIiwidmFsdWUiOiIxMjM0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJwcm9kdWN0SWQyIiwidmFsdWUiOiI0NTYiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6InByb2R1Y3RJZDMiLCJ2YWx1ZSI6Ijc4OSIsImVuYWJsZWQiOnRydWV9XQ==)|[gotwaygateway/stock](https://hub.docker.com/r/gotwaygateway/stock/tags)| -|[Route](./cmd/route)|[Go client](./cmd/route/client)|[gotwaygateway/route](https://hub.docker.com/r/gotwaygateway/route/tags)| diff --git a/cmd/catalog/Makefile b/cmd/catalog/Makefile deleted file mode 100644 index 5255412..0000000 --- a/cmd/catalog/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean deps deps-sync format build install run - -all: build -clean: - rm -rf bin/ -deps: - go get -u -v -deps-sync: - go mod vendor -format: - go fmt . -build: clean format - go build -o bin/catalog -v . -install: - go install -v . -run: build - ./bin/catalog \ No newline at end of file diff --git a/cmd/catalog/api/handlers.go b/cmd/catalog/api/handlers.go index 1ee0a4b..26ade97 100644 --- a/cmd/catalog/api/handlers.go +++ b/cmd/catalog/api/handlers.go @@ -42,7 +42,7 @@ func getProducts(w http.ResponseWriter, r *http.Request) { setHeaders(w) w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(productPage) + _ = json.NewEncoder(w).Encode(productPage) } func createProduct(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func createProduct(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) - json.NewEncoder(w).Encode(res) + _ = json.NewEncoder(w).Encode(res) } func getProduct(w http.ResponseWriter, r *http.Request) { @@ -81,7 +81,7 @@ func getProduct(w http.ResponseWriter, r *http.Request) { setHeaders(w) w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(p) + _ = json.NewEncoder(w).Encode(p) } func deleteProduct(w http.ResponseWriter, r *http.Request) { diff --git a/cmd/catalog/model/dao.go b/cmd/catalog/model/dao.go index cdc0c4c..d83e5b2 100644 --- a/cmd/catalog/model/dao.go +++ b/cmd/catalog/model/dao.go @@ -39,7 +39,10 @@ func (dao *ProductDAO) GetProducts( return nil, catalog.NotFoundError } - productPage := &catalog.ProductPage{slicedProducts, len(products)} + productPage := &catalog.ProductPage{ + Products: slicedProducts, + TotalCount: len(products), + } return productPage, nil } diff --git a/cmd/route/Makefile b/cmd/route/Makefile deleted file mode 100644 index ae7dc83..0000000 --- a/cmd/route/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -.PHONY: clean deps deps-sync fmt-srv fmt-cli fmt proto build srv run cli cli.mgw - -LOCAL_ARGS ?= -server localhost:11000 -tls true -PRO_ARGS ?= -server gotway.duckdns.org:4433 -tls true - -all: build -clean: - rm -rf bin/ -deps: - go get -u -v -deps-sync: - go mod vendor -fmt-srv: - go fmt server/*.go -fmt-cli: - go fmt client/*.go -fmt: fmt-srv fmt-cli -build: fmt-srv clean - go build -o bin/route -v . -srv: build - ./bin/route -run: srv -cli: fmt-cli - go run client/*.go $(LOCAL_ARGS) -cli-pro: fmt-cli - go run client/*.go $(PRO_ARGS) diff --git a/cmd/route/client/client.go b/cmd/route/client/client.go deleted file mode 100644 index c055ff4..0000000 --- a/cmd/route/client/client.go +++ /dev/null @@ -1,90 +0,0 @@ -package main - -import ( - "context" - "flag" - "os" - "time" - - "github.com/gotway/gotway/pkg/log" - "github.com/gotway/gotway/pkg/tlstest" - route "github.com/gotway/service-examples/pkg/route" -) - -var ( - server = flag.String( - "server", - "localhost:11000", - "The server address in the format of host:port", - ) - timeoutSeconds = flag.Int("timeout", 10, "Request timeout in seconds") - timeout = time.Duration(*timeoutSeconds) * time.Second - tls = flag.Bool("tls", false, "Enable TLS") - tlsCa = flag.String( - "tls_ca", - tlstest.CA(), - "Certificate authority file for TLS", - ) - tlsServerHost = flag.String( - "tls_server_host", - tlstest.Server(), - "The server name used to verify the hostname returned by the TLS handshake", - ) - ctx = context.Background() -) - -func main() { - flag.Parse() - - logger := log.NewLogger(log.Fields{ - "service": "route", - }, "local", "debug", os.Stdout) - logger.Info("starting...") - - opts := route.ClientOptions{ - Timeout: timeout, - TLS: route.TLSOptions{ - Enabled: *tls, - CA: *tlsCa, - ServerHost: *tlsServerHost, - }, - } - logger.Debug(opts) - - logger.Infof("connecting to server at %s...", *server) - client, err := route.NewClient(*server, opts) - if err != nil { - logger.Error(err) - } - defer client.Close() - - res, err := client.HealthCheck(ctx) - if err != nil { - logger.Error("health check failed ", err) - } - logger.Info("health check ", res) - - feature, err := client.GetFeature(ctx, route.ValidPoint) - if err != nil { - logger.Error("get feature failed ", err) - } - logger.Info("get feature ", feature) - - features, err := client.ListFeatures(ctx, route.Rect) - if err != nil { - logger.Error("list features failed ", err) - } - logger.Info("list features ", features) - - summary, err := client.RecordRoute(ctx) - if err != nil { - logger.Error("record route failed ", err) - } - logger.Info("record route ", summary) - - notes, err := client.RouteChat(ctx) - if err != nil { - logger.Error("route chat failed ", err) - } - logger.Info("route chat ", notes) -} diff --git a/cmd/route/config/config.go b/cmd/route/config/config.go deleted file mode 100644 index 6d189ac..0000000 --- a/cmd/route/config/config.go +++ /dev/null @@ -1,10 +0,0 @@ -package config - -import ( - c "github.com/gotway/gotway/pkg/config" -) - -var ( - // Port indicates the server port - Port = c.GetEnv("PORT", "14000") -) diff --git a/cmd/route/main.go b/cmd/route/main.go deleted file mode 100644 index dd73778..0000000 --- a/cmd/route/main.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import ( - "fmt" - "log" - "net" - - "github.com/gotway/service-examples/cmd/route/config" - "github.com/gotway/service-examples/cmd/route/server" -) - -func main() { - server := server.NewServer() - lis, err := net.Listen("tcp", fmt.Sprintf(":%s", config.Port)) - if err != nil { - log.Fatalf("Failed to listen: %v", err) - } else { - log.Printf("Server listening on port %s", config.Port) - } - server.Serve(lis) -} diff --git a/cmd/route/scripts/run-dev.sh b/cmd/route/scripts/run-dev.sh deleted file mode 100755 index 74acaca..0000000 --- a/cmd/route/scripts/run-dev.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -set -e - -tmux new-session -d -s grpc -tab=0 - -function new_tab() { - name="$1" - cmd="$2" - tab=$(($tab + 1)) - tmux new-window -t grpc:"$tab" -n "$name" - tmux send-keys -t grpc:"$tab" "$cmd" enter -} - -new_tab "client" "make cli" -new_tab "server" "make srv" -tmux rename-window -t grpc:0 'workspace' -tmux select-window -t grpc:0 - -tmux attach -t grpc diff --git a/cmd/route/server/data.go b/cmd/route/server/data.go deleted file mode 100644 index a03bd35..0000000 --- a/cmd/route/server/data.go +++ /dev/null @@ -1,603 +0,0 @@ -package server - -var data = []byte(`[{ - "location": { - "latitude": 407838351, - "longitude": -746143763 - }, - "name": "Patriots Path, Mendham, NJ 07945, USA" -}, { - "location": { - "latitude": 408122808, - "longitude": -743999179 - }, - "name": "101 New Jersey 10, Whippany, NJ 07981, USA" -}, { - "location": { - "latitude": 413628156, - "longitude": -749015468 - }, - "name": "U.S. 6, Shohola, PA 18458, USA" -}, { - "location": { - "latitude": 419999544, - "longitude": -740371136 - }, - "name": "5 Conners Road, Kingston, NY 12401, USA" -}, { - "location": { - "latitude": 414008389, - "longitude": -743951297 - }, - "name": "Mid Hudson Psychiatric Center, New Hampton, NY 10958, USA" -}, { - "location": { - "latitude": 419611318, - "longitude": -746524769 - }, - "name": "287 Flugertown Road, Livingston Manor, NY 12758, USA" -}, { - "location": { - "latitude": 406109563, - "longitude": -742186778 - }, - "name": "4001 Tremley Point Road, Linden, NJ 07036, USA" -}, { - "location": { - "latitude": 416802456, - "longitude": -742370183 - }, - "name": "352 South Mountain Road, Wallkill, NY 12589, USA" -}, { - "location": { - "latitude": 412950425, - "longitude": -741077389 - }, - "name": "Bailey Turn Road, Harriman, NY 10926, USA" -}, { - "location": { - "latitude": 412144655, - "longitude": -743949739 - }, - "name": "193-199 Wawayanda Road, Hewitt, NJ 07421, USA" -}, { - "location": { - "latitude": 415736605, - "longitude": -742847522 - }, - "name": "406-496 Ward Avenue, Pine Bush, NY 12566, USA" -}, { - "location": { - "latitude": 413843930, - "longitude": -740501726 - }, - "name": "162 Merrill Road, Highland Mills, NY 10930, USA" -}, { - "location": { - "latitude": 410873075, - "longitude": -744459023 - }, - "name": "Clinton Road, West Milford, NJ 07480, USA" -}, { - "location": { - "latitude": 412346009, - "longitude": -744026814 - }, - "name": "16 Old Brook Lane, Warwick, NY 10990, USA" -}, { - "location": { - "latitude": 402948455, - "longitude": -747903913 - }, - "name": "3 Drake Lane, Pennington, NJ 08534, USA" -}, { - "location": { - "latitude": 406337092, - "longitude": -740122226 - }, - "name": "6324 8th Avenue, Brooklyn, NY 11220, USA" -}, { - "location": { - "latitude": 406421967, - "longitude": -747727624 - }, - "name": "1 Merck Access Road, Whitehouse Station, NJ 08889, USA" -}, { - "location": { - "latitude": 416318082, - "longitude": -749677716 - }, - "name": "78-98 Schalck Road, Narrowsburg, NY 12764, USA" -}, { - "location": { - "latitude": 415301720, - "longitude": -748416257 - }, - "name": "282 Lakeview Drive Road, Highland Lake, NY 12743, USA" -}, { - "location": { - "latitude": 402647019, - "longitude": -747071791 - }, - "name": "330 Evelyn Avenue, Hamilton Township, NJ 08619, USA" -}, { - "location": { - "latitude": 412567807, - "longitude": -741058078 - }, - "name": "New York State Reference Route 987E, Southfields, NY 10975, USA" -}, { - "location": { - "latitude": 416855156, - "longitude": -744420597 - }, - "name": "103-271 Tempaloni Road, Ellenville, NY 12428, USA" -}, { - "location": { - "latitude": 404663628, - "longitude": -744820157 - }, - "name": "1300 Airport Road, North Brunswick Township, NJ 08902, USA" -}, { - "location": { - "latitude": 407113723, - "longitude": -749746483 - }, - "name": "" -}, { - "location": { - "latitude": 402133926, - "longitude": -743613249 - }, - "name": "" -}, { - "location": { - "latitude": 400273442, - "longitude": -741220915 - }, - "name": "" -}, { - "location": { - "latitude": 411236786, - "longitude": -744070769 - }, - "name": "" -}, { - "location": { - "latitude": 411633782, - "longitude": -746784970 - }, - "name": "211-225 Plains Road, Augusta, NJ 07822, USA" -}, { - "location": { - "latitude": 415830701, - "longitude": -742952812 - }, - "name": "" -}, { - "location": { - "latitude": 413447164, - "longitude": -748712898 - }, - "name": "165 Pedersen Ridge Road, Milford, PA 18337, USA" -}, { - "location": { - "latitude": 405047245, - "longitude": -749800722 - }, - "name": "100-122 Locktown Road, Frenchtown, NJ 08825, USA" -}, { - "location": { - "latitude": 418858923, - "longitude": -746156790 - }, - "name": "" -}, { - "location": { - "latitude": 417951888, - "longitude": -748484944 - }, - "name": "650-652 Willi Hill Road, Swan Lake, NY 12783, USA" -}, { - "location": { - "latitude": 407033786, - "longitude": -743977337 - }, - "name": "26 East 3rd Street, New Providence, NJ 07974, USA" -}, { - "location": { - "latitude": 417548014, - "longitude": -740075041 - }, - "name": "" -}, { - "location": { - "latitude": 410395868, - "longitude": -744972325 - }, - "name": "" -}, { - "location": { - "latitude": 404615353, - "longitude": -745129803 - }, - "name": "" -}, { - "location": { - "latitude": 406589790, - "longitude": -743560121 - }, - "name": "611 Lawrence Avenue, Westfield, NJ 07090, USA" -}, { - "location": { - "latitude": 414653148, - "longitude": -740477477 - }, - "name": "18 Lannis Avenue, New Windsor, NY 12553, USA" -}, { - "location": { - "latitude": 405957808, - "longitude": -743255336 - }, - "name": "82-104 Amherst Avenue, Colonia, NJ 07067, USA" -}, { - "location": { - "latitude": 411733589, - "longitude": -741648093 - }, - "name": "170 Seven Lakes Drive, Sloatsburg, NY 10974, USA" -}, { - "location": { - "latitude": 412676291, - "longitude": -742606606 - }, - "name": "1270 Lakes Road, Monroe, NY 10950, USA" -}, { - "location": { - "latitude": 409224445, - "longitude": -748286738 - }, - "name": "509-535 Alphano Road, Great Meadows, NJ 07838, USA" -}, { - "location": { - "latitude": 406523420, - "longitude": -742135517 - }, - "name": "652 Garden Street, Elizabeth, NJ 07202, USA" -}, { - "location": { - "latitude": 401827388, - "longitude": -740294537 - }, - "name": "349 Sea Spray Court, Neptune City, NJ 07753, USA" -}, { - "location": { - "latitude": 410564152, - "longitude": -743685054 - }, - "name": "13-17 Stanley Street, West Milford, NJ 07480, USA" -}, { - "location": { - "latitude": 408472324, - "longitude": -740726046 - }, - "name": "47 Industrial Avenue, Teterboro, NJ 07608, USA" -}, { - "location": { - "latitude": 412452168, - "longitude": -740214052 - }, - "name": "5 White Oak Lane, Stony Point, NY 10980, USA" -}, { - "location": { - "latitude": 409146138, - "longitude": -746188906 - }, - "name": "Berkshire Valley Management Area Trail, Jefferson, NJ, USA" -}, { - "location": { - "latitude": 404701380, - "longitude": -744781745 - }, - "name": "1007 Jersey Avenue, New Brunswick, NJ 08901, USA" -}, { - "location": { - "latitude": 409642566, - "longitude": -746017679 - }, - "name": "6 East Emerald Isle Drive, Lake Hopatcong, NJ 07849, USA" -}, { - "location": { - "latitude": 408031728, - "longitude": -748645385 - }, - "name": "1358-1474 New Jersey 57, Port Murray, NJ 07865, USA" -}, { - "location": { - "latitude": 413700272, - "longitude": -742135189 - }, - "name": "367 Prospect Road, Chester, NY 10918, USA" -}, { - "location": { - "latitude": 404310607, - "longitude": -740282632 - }, - "name": "10 Simon Lake Drive, Atlantic Highlands, NJ 07716, USA" -}, { - "location": { - "latitude": 409319800, - "longitude": -746201391 - }, - "name": "11 Ward Street, Mount Arlington, NJ 07856, USA" -}, { - "location": { - "latitude": 406685311, - "longitude": -742108603 - }, - "name": "300-398 Jefferson Avenue, Elizabeth, NJ 07201, USA" -}, { - "location": { - "latitude": 419018117, - "longitude": -749142781 - }, - "name": "43 Dreher Road, Roscoe, NY 12776, USA" -}, { - "location": { - "latitude": 412856162, - "longitude": -745148837 - }, - "name": "Swan Street, Pine Island, NY 10969, USA" -}, { - "location": { - "latitude": 416560744, - "longitude": -746721964 - }, - "name": "66 Pleasantview Avenue, Monticello, NY 12701, USA" -}, { - "location": { - "latitude": 405314270, - "longitude": -749836354 - }, - "name": "" -}, { - "location": { - "latitude": 414219548, - "longitude": -743327440 - }, - "name": "" -}, { - "location": { - "latitude": 415534177, - "longitude": -742900616 - }, - "name": "565 Winding Hills Road, Montgomery, NY 12549, USA" -}, { - "location": { - "latitude": 406898530, - "longitude": -749127080 - }, - "name": "231 Rocky Run Road, Glen Gardner, NJ 08826, USA" -}, { - "location": { - "latitude": 407586880, - "longitude": -741670168 - }, - "name": "100 Mount Pleasant Avenue, Newark, NJ 07104, USA" -}, { - "location": { - "latitude": 400106455, - "longitude": -742870190 - }, - "name": "517-521 Huntington Drive, Manchester Township, NJ 08759, USA" -}, { - "location": { - "latitude": 400066188, - "longitude": -746793294 - }, - "name": "" -}, { - "location": { - "latitude": 418803880, - "longitude": -744102673 - }, - "name": "40 Mountain Road, Napanoch, NY 12458, USA" -}, { - "location": { - "latitude": 414204288, - "longitude": -747895140 - }, - "name": "" -}, { - "location": { - "latitude": 414777405, - "longitude": -740615601 - }, - "name": "" -}, { - "location": { - "latitude": 415464475, - "longitude": -747175374 - }, - "name": "48 North Road, Forestburgh, NY 12777, USA" -}, { - "location": { - "latitude": 404062378, - "longitude": -746376177 - }, - "name": "" -}, { - "location": { - "latitude": 405688272, - "longitude": -749285130 - }, - "name": "" -}, { - "location": { - "latitude": 400342070, - "longitude": -748788996 - }, - "name": "" -}, { - "location": { - "latitude": 401809022, - "longitude": -744157964 - }, - "name": "" -}, { - "location": { - "latitude": 404226644, - "longitude": -740517141 - }, - "name": "9 Thompson Avenue, Leonardo, NJ 07737, USA" -}, { - "location": { - "latitude": 410322033, - "longitude": -747871659 - }, - "name": "" -}, { - "location": { - "latitude": 407100674, - "longitude": -747742727 - }, - "name": "" -}, { - "location": { - "latitude": 418811433, - "longitude": -741718005 - }, - "name": "213 Bush Road, Stone Ridge, NY 12484, USA" -}, { - "location": { - "latitude": 415034302, - "longitude": -743850945 - }, - "name": "" -}, { - "location": { - "latitude": 411349992, - "longitude": -743694161 - }, - "name": "" -}, { - "location": { - "latitude": 404839914, - "longitude": -744759616 - }, - "name": "1-17 Bergen Court, New Brunswick, NJ 08901, USA" -}, { - "location": { - "latitude": 414638017, - "longitude": -745957854 - }, - "name": "35 Oakland Valley Road, Cuddebackville, NY 12729, USA" -}, { - "location": { - "latitude": 412127800, - "longitude": -740173578 - }, - "name": "" -}, { - "location": { - "latitude": 401263460, - "longitude": -747964303 - }, - "name": "" -}, { - "location": { - "latitude": 412843391, - "longitude": -749086026 - }, - "name": "" -}, { - "location": { - "latitude": 418512773, - "longitude": -743067823 - }, - "name": "" -}, { - "location": { - "latitude": 404318328, - "longitude": -740835638 - }, - "name": "42-102 Main Street, Belford, NJ 07718, USA" -}, { - "location": { - "latitude": 419020746, - "longitude": -741172328 - }, - "name": "" -}, { - "location": { - "latitude": 404080723, - "longitude": -746119569 - }, - "name": "" -}, { - "location": { - "latitude": 401012643, - "longitude": -744035134 - }, - "name": "" -}, { - "location": { - "latitude": 404306372, - "longitude": -741079661 - }, - "name": "" -}, { - "location": { - "latitude": 403966326, - "longitude": -748519297 - }, - "name": "" -}, { - "location": { - "latitude": 405002031, - "longitude": -748407866 - }, - "name": "" -}, { - "location": { - "latitude": 409532885, - "longitude": -742200683 - }, - "name": "" -}, { - "location": { - "latitude": 416851321, - "longitude": -742674555 - }, - "name": "" -}, { - "location": { - "latitude": 406411633, - "longitude": -741722051 - }, - "name": "3387 Richmond Terrace, Staten Island, NY 10303, USA" -}, { - "location": { - "latitude": 413069058, - "longitude": -744597778 - }, - "name": "261 Van Sickle Road, Goshen, NY 10924, USA" -}, { - "location": { - "latitude": 418465462, - "longitude": -746859398 - }, - "name": "" -}, { - "location": { - "latitude": 411733222, - "longitude": -744228360 - }, - "name": "" -}, { - "location": { - "latitude": 410248224, - "longitude": -747127767 - }, - "name": "3 Hasta Way, Newton, NJ 07860, USA" -}]`) diff --git a/cmd/route/server/geom.go b/cmd/route/server/geom.go deleted file mode 100644 index 598db83..0000000 --- a/cmd/route/server/geom.go +++ /dev/null @@ -1,47 +0,0 @@ -package server - -import ( - "math" - - pb "github.com/gotway/service-examples/pkg/route/pb" -) - -func toRadians(num float64) float64 { - return num * math.Pi / float64(180) -} - -// calcDistance calculates the distance between two points using the "haversine" formula. -// The formula is based on http://mathforum.org/library/drmath/view/51879.html. -func calcDistance(p1 *pb.Point, p2 *pb.Point) int32 { - const CordFactor float64 = 1e7 - const R = float64(6371000) // earth radius in metres - lat1 := toRadians(float64(p1.Latitude) / CordFactor) - lat2 := toRadians(float64(p2.Latitude) / CordFactor) - lng1 := toRadians(float64(p1.Longitude) / CordFactor) - lng2 := toRadians(float64(p2.Longitude) / CordFactor) - dlat := lat2 - lat1 - dlng := lng2 - lng1 - - a := math.Sin(dlat/2)*math.Sin(dlat/2) + - math.Cos(lat1)*math.Cos(lat2)* - math.Sin(dlng/2)*math.Sin(dlng/2) - c := 2 * math.Atan2(math.Sqrt(a), math.Sqrt(1-a)) - - distance := R * c - return int32(distance) -} - -func inRange(point *pb.Point, rect *pb.Rectangle) bool { - left := math.Min(float64(rect.Lo.Longitude), float64(rect.Hi.Longitude)) - right := math.Max(float64(rect.Lo.Longitude), float64(rect.Hi.Longitude)) - top := math.Max(float64(rect.Lo.Latitude), float64(rect.Hi.Latitude)) - bottom := math.Min(float64(rect.Lo.Latitude), float64(rect.Hi.Latitude)) - - if float64(point.Longitude) >= left && - float64(point.Longitude) <= right && - float64(point.Latitude) >= bottom && - float64(point.Latitude) <= top { - return true - } - return false -} diff --git a/cmd/route/server/server.go b/cmd/route/server/server.go deleted file mode 100644 index cb4ab90..0000000 --- a/cmd/route/server/server.go +++ /dev/null @@ -1,140 +0,0 @@ -package server - -import ( - ctx "context" - "encoding/json" - "errors" - "fmt" - "io" - "log" - "sync" - "time" - - "github.com/golang/protobuf/proto" - pb "github.com/gotway/service-examples/pkg/route/pb" - "google.golang.org/grpc" - "google.golang.org/grpc/health" - healthpb "google.golang.org/grpc/health/grpc_health_v1" -) - -type routeServer struct { - pb.UnimplementedRouteServer - savedFeatures []*pb.Feature - - mux sync.Mutex - routeNotes map[string][]*pb.RouteNote -} - -var errNotFound = errors.New("Not found") - -func (s *routeServer) GetFeature(ctx ctx.Context, point *pb.Point) (*pb.Feature, error) { - return s.findFeature(point) -} - -func (s *routeServer) ListFeatures(rect *pb.Rectangle, stream pb.Route_ListFeaturesServer) error { - for _, feature := range s.savedFeatures { - if inRange(feature.Location, rect) { - if err := stream.Send(feature); err != nil { - return err - } - } - } - return nil -} - -func (s *routeServer) RecordRoute(stream pb.Route_RecordRouteServer) error { - var pointCount, featureCount, distance int32 - var lastPoint *pb.Point - startTime := time.Now() - for { - point, err := stream.Recv() - if err == io.EOF { - endTime := time.Now() - return stream.SendAndClose(&pb.RouteSummary{ - PointCount: pointCount, - FeatureCount: featureCount, - Distance: distance, - ElapsedTime: int32(endTime.Sub(startTime).Seconds()), - }) - } - if err != nil { - return err - } - pointCount++ - feature, _ := s.findFeature(point) - if feature != nil { - featureCount++ - } - if lastPoint != nil { - distance += calcDistance(lastPoint, point) - } - lastPoint = point - } -} - -func (s *routeServer) RouteChat(stream pb.Route_RouteChatServer) error { - defer s.resetRouteNotes() - for { - in, err := stream.Recv() - if err == io.EOF { - return nil - } - if err != nil { - return err - } - key := serialize(in.Location) - s.mux.Lock() - s.routeNotes[key] = append(s.routeNotes[key], in) - rn := make([]*pb.RouteNote, len(s.routeNotes[key])) - copy(rn, s.routeNotes[key]) - s.mux.Unlock() - for _, note := range rn { - if err := stream.Send(note); err != nil { - return err - } - } - } -} - -func (s *routeServer) resetRouteNotes() { - s.mux.Lock() - defer s.mux.Unlock() - s.routeNotes = make(map[string][]*pb.RouteNote) -} - -func (s *routeServer) loadFeatures() { - if err := json.Unmarshal(data, &s.savedFeatures); err != nil { - log.Fatalf("Failed to load default features: %v", err) - } -} - -func (s *routeServer) findFeature(point *pb.Point) (*pb.Feature, error) { - for _, feature := range s.savedFeatures { - if proto.Equal(feature.Location, point) { - return feature, nil - } - } - return nil, errNotFound -} - -func serialize(point *pb.Point) string { - return fmt.Sprintf("%d %d", point.Latitude, point.Longitude) -} - -func newRouteServer() *routeServer { - s := &routeServer{routeNotes: make(map[string][]*pb.RouteNote)} - s.loadFeatures() - return s -} - -// NewServer creates a new gRPC server -func NewServer() *grpc.Server { - grpcServer := grpc.NewServer() - routeServer := newRouteServer() - pb.RegisterRouteServer(grpcServer, routeServer) - - healthServer := health.NewServer() - healthpb.RegisterHealthServer(grpcServer, healthServer) - - return grpcServer -} diff --git a/cmd/stock/Makefile b/cmd/stock/Makefile deleted file mode 100644 index b696331..0000000 --- a/cmd/stock/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -.PHONY: clean deps deps-sync format build install run - -all: build -clean: - rm -rf bin/ -deps: - go get -u -v -deps-sync: - go mod vendor -format: - go fmt . -build: clean format - go build -o bin/stock -v . -install: - go install -v . -run: build - ./bin/stock \ No newline at end of file diff --git a/cmd/stock/api/handlers.go b/cmd/stock/api/handlers.go index df47e92..fb8bea7 100644 --- a/cmd/stock/api/handlers.go +++ b/cmd/stock/api/handlers.go @@ -38,7 +38,7 @@ func upsertStock(w http.ResponseWriter, r *http.Request) { } setHeaders(w) w.WriteHeader(http.StatusCreated) - json.NewEncoder(w).Encode(resultStock) + _ = json.NewEncoder(w).Encode(resultStock) } func upsertStockList(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func upsertStockList(w http.ResponseWriter, r *http.Request) { } setHeaders(w) w.WriteHeader(http.StatusCreated) - json.NewEncoder(w).Encode(&resultStockList) + _ = json.NewEncoder(w).Encode(&resultStockList) } func getStock(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func getStock(w http.ResponseWriter, r *http.Request) { } setHeaders(w) w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(stock) + _ = json.NewEncoder(w).Encode(stock) } func getStockList(w http.ResponseWriter, r *http.Request) { @@ -92,7 +92,7 @@ func getStockList(w http.ResponseWriter, r *http.Request) { } setHeaders(w) w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(&stockList) + _ = json.NewEncoder(w).Encode(&stockList) } func getProductID(r *http.Request) (int, error) { diff --git a/docker-compose.redis.yml b/docker-compose.redis.yml new file mode 100644 index 0000000..a25bd71 --- /dev/null +++ b/docker-compose.redis.yml @@ -0,0 +1,11 @@ +version: "3.3" + +services: + redis: + container_name: services-redis + image: redis:6.2.4-alpine3.13 + restart: unless-stopped + ports: + - "6379" + volumes: + - ./data/redis:/data diff --git a/docker-compose.yml b/docker-compose.yml index 415f00c..01df8d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,15 +22,6 @@ services: ports: - "13000:13000" - redis: - container_name: stock-redis - image: redis:6.2.4-alpine3.13 - restart: unless-stopped - ports: - - "6379" - volumes: - - ./data/redis:/data - route: container_name: route image: gotwaygateway/route:v0.0.3 diff --git a/go.mod b/go.mod index 74d32d2..81268fd 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,17 @@ module github.com/gotway/service-examples -go 1.15 +go 1.18 require ( github.com/go-redis/redis/v8 v8.10.0 - github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 github.com/gotway/gotway v0.0.11-0.20210626195829-33aaa245bf30 - google.golang.org/grpc v1.38.0 - google.golang.org/protobuf v1.27.0 +) + +require ( + github.com/cespare/xxhash/v2 v2.1.1 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + go.opentelemetry.io/otel v1.0.0-RC1 // indirect + go.opentelemetry.io/otel/internal/metric v0.21.0 // indirect + go.opentelemetry.io/otel/metric v0.21.0 // indirect ) diff --git a/go.sum b/go.sum index 3583afc..b82289b 100644 --- a/go.sum +++ b/go.sum @@ -50,7 +50,6 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -103,7 +102,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -115,7 +113,6 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= @@ -135,8 +132,6 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/gotway/gotway v0.0.11-0.20210626192635-a68e86c00598 h1:cdqTZ9rjugfrZ0T8wnqf7h02OcfxNMhEJo/NxCF2tug= -github.com/gotway/gotway v0.0.11-0.20210626192635-a68e86c00598/go.mod h1:i0UgMDR9X57tNCeElAuWhRagwSQLmDoOSixtyn7h+p8= github.com/gotway/gotway v0.0.11-0.20210626195829-33aaa245bf30 h1:zM5kS8ZLp3CA8A4SAJUotx/iEMmijzGjChH7LXAr7dQ= github.com/gotway/gotway v0.0.11-0.20210626195829-33aaa245bf30/go.mod h1:i0UgMDR9X57tNCeElAuWhRagwSQLmDoOSixtyn7h+p8= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -156,10 +151,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -204,7 +197,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -226,21 +218,16 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/otel v0.20.0 h1:eaP0Fqu7SXHwvjiqDq83zImeehOHX8doTvU9AwXON8g= go.opentelemetry.io/otel v0.20.0/go.mod h1:Y3ugLH2oa81t5QO+Lty+zXf8zC9L26ax4Nzoxm/dooo= go.opentelemetry.io/otel v1.0.0-RC1 h1:4CeoX93DNTWt8awGK9JmNXzF9j7TyOu9upscEdtcdXc= go.opentelemetry.io/otel v1.0.0-RC1/go.mod h1:x9tRa9HK4hSSq7jf2TKbqFbtt58/TGk0f9XiEYISI1I= go.opentelemetry.io/otel/internal/metric v0.21.0 h1:gZlIBo5O51hZOOZz8vEcuRx/l5dnADadKfpT70AELoo= go.opentelemetry.io/otel/internal/metric v0.21.0/go.mod h1:iOfAaY2YycsXfYD4kaRSbLx2LKmfpKObWBEv9QK5zFo= -go.opentelemetry.io/otel/metric v0.20.0 h1:4kzhXFP+btKm4jwxpjIqjs41A7MakRFUS86bqLHTIw8= go.opentelemetry.io/otel/metric v0.20.0/go.mod h1:598I5tYlH1vzBjn+BTuhzTCSb/9debfNp6R3s7Pr1eU= go.opentelemetry.io/otel/metric v0.21.0 h1:ZtcJlHqVE4l8Su0WOLOd9fEPheJuYEiQ0wr9wv2p25I= go.opentelemetry.io/otel/metric v0.21.0/go.mod h1:JWCt1bjivC4iCrz/aCrM1GSw+ZcvY44KCbaeeRhzHnc= -go.opentelemetry.io/otel/oteltest v0.20.0 h1:HiITxCawalo5vQzdHfKeZurV8x7ljcqAgiWzF6Vaeaw= go.opentelemetry.io/otel/oteltest v0.20.0/go.mod h1:L7bgKf9ZB7qCwT9Up7i9/pn0PWIa9FqQ2IQ8LoxiGnw= -go.opentelemetry.io/otel/oteltest v1.0.0-RC1 h1:G685iP3XiskCwk/z0eIabL55XUl2gk0cljhGk9sB0Yk= go.opentelemetry.io/otel/oteltest v1.0.0-RC1/go.mod h1:+eoIG0gdEOaPNftuy1YScLr1Gb4mL/9lpDkZ0JjMRq4= -go.opentelemetry.io/otel/trace v0.20.0 h1:1DL6EXUdcg95gukhuRRvLDO/4X5THh/5dIV52lqtnbw= go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16gUEi0Nf1iBdgw= go.opentelemetry.io/otel/trace v1.0.0-RC1 h1:jrjqKJZEibFrDz+umEASeU3LvdVyWKlnTh7XEfwrT58= go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg= @@ -313,7 +300,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -374,14 +360,11 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40 h1:JWgyZ1qgdTaF3N3oxC+MdTV7qvEEgHo3otj+HB5CM7Q= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -390,7 +373,6 @@ golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fq golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= @@ -443,7 +425,6 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -491,13 +472,11 @@ google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 h1:R1r5J0u6Cx+RNl/6mezTw6oA14cmKC96FeUwL6A9bd4= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -511,7 +490,6 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.38.0 h1:/9BgsAsa5nWe26HqOlvlgJnqBuktYOLCgjCPqsa56W0= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -524,15 +502,11 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.0 h1:KhgSLlr/moiqjv0qUsSnLvdUL7NH7PHW8aZGn7Jpjko= google.golang.org/protobuf v1.27.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -542,11 +516,9 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/route/data.go b/pkg/route/data.go deleted file mode 100644 index 96f49b3..0000000 --- a/pkg/route/data.go +++ /dev/null @@ -1,44 +0,0 @@ -package route - -import ( - "math/rand" - "time" - - pb "github.com/gotway/service-examples/pkg/route/pb" -) - -var ValidPoint = &pb.Point{Latitude: 409146138, Longitude: -746188906} - -var InvalidPoint = &pb.Point{Latitude: 0, Longitude: 0} - -var Rect = &pb.Rectangle{ - Lo: &pb.Point{Latitude: 410000000, Longitude: -740000000}, - Hi: &pb.Point{Latitude: 415000000, Longitude: -745000000}, -} - -func randomPoints() []*pb.Point { - r := rand.New(rand.NewSource(time.Now().UnixNano())) - pointCount := int(r.Int31n(100)) + 2 - var points []*pb.Point - for i := 0; i < pointCount; i++ { - points = append(points, randomPoint(r)) - } - return points -} - -func randomPoint(r *rand.Rand) *pb.Point { - lat := (r.Int31n(180) - 90) * 1e7 - long := (r.Int31n(360) - 180) * 1e7 - return &pb.Point{Latitude: lat, Longitude: long} -} - -func notes() []*pb.RouteNote { - return []*pb.RouteNote{ - {Location: &pb.Point{Latitude: 0, Longitude: 1}, Message: "First message"}, - {Location: &pb.Point{Latitude: 0, Longitude: 2}, Message: "Second message"}, - {Location: &pb.Point{Latitude: 0, Longitude: 3}, Message: "Third message"}, - {Location: &pb.Point{Latitude: 0, Longitude: 1}, Message: "Fourth message"}, - {Location: &pb.Point{Latitude: 0, Longitude: 2}, Message: "Fifth message"}, - {Location: &pb.Point{Latitude: 0, Longitude: 3}, Message: "Sixth message"}, - } -} diff --git a/pkg/route/pb/Makefile b/pkg/route/pb/Makefile deleted file mode 100644 index 5bd513c..0000000 --- a/pkg/route/pb/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -.PHONY: proto - -proto: - protoc --go_out=. --go-grpc_out=. *.proto \ No newline at end of file diff --git a/pkg/route/pb/route.pb.go b/pkg/route/pb/route.pb.go deleted file mode 100644 index 85e1377..0000000 --- a/pkg/route/pb/route.pb.go +++ /dev/null @@ -1,490 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.26.0 -// protoc v3.15.6 -// source: route.proto - -package route - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Point struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Latitude int32 `protobuf:"varint,1,opt,name=latitude,proto3" json:"latitude,omitempty"` - Longitude int32 `protobuf:"varint,2,opt,name=longitude,proto3" json:"longitude,omitempty"` -} - -func (x *Point) Reset() { - *x = Point{} - if protoimpl.UnsafeEnabled { - mi := &file_route_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Point) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Point) ProtoMessage() {} - -func (x *Point) ProtoReflect() protoreflect.Message { - mi := &file_route_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Point.ProtoReflect.Descriptor instead. -func (*Point) Descriptor() ([]byte, []int) { - return file_route_proto_rawDescGZIP(), []int{0} -} - -func (x *Point) GetLatitude() int32 { - if x != nil { - return x.Latitude - } - return 0 -} - -func (x *Point) GetLongitude() int32 { - if x != nil { - return x.Longitude - } - return 0 -} - -type Feature struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Location *Point `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"` -} - -func (x *Feature) Reset() { - *x = Feature{} - if protoimpl.UnsafeEnabled { - mi := &file_route_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Feature) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Feature) ProtoMessage() {} - -func (x *Feature) ProtoReflect() protoreflect.Message { - mi := &file_route_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Feature.ProtoReflect.Descriptor instead. -func (*Feature) Descriptor() ([]byte, []int) { - return file_route_proto_rawDescGZIP(), []int{1} -} - -func (x *Feature) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Feature) GetLocation() *Point { - if x != nil { - return x.Location - } - return nil -} - -type Rectangle struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Lo *Point `protobuf:"bytes,1,opt,name=lo,proto3" json:"lo,omitempty"` - Hi *Point `protobuf:"bytes,2,opt,name=hi,proto3" json:"hi,omitempty"` -} - -func (x *Rectangle) Reset() { - *x = Rectangle{} - if protoimpl.UnsafeEnabled { - mi := &file_route_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Rectangle) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Rectangle) ProtoMessage() {} - -func (x *Rectangle) ProtoReflect() protoreflect.Message { - mi := &file_route_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Rectangle.ProtoReflect.Descriptor instead. -func (*Rectangle) Descriptor() ([]byte, []int) { - return file_route_proto_rawDescGZIP(), []int{2} -} - -func (x *Rectangle) GetLo() *Point { - if x != nil { - return x.Lo - } - return nil -} - -func (x *Rectangle) GetHi() *Point { - if x != nil { - return x.Hi - } - return nil -} - -type RouteSummary struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PointCount int32 `protobuf:"varint,1,opt,name=point_count,json=pointCount,proto3" json:"point_count,omitempty"` - FeatureCount int32 `protobuf:"varint,2,opt,name=feature_count,json=featureCount,proto3" json:"feature_count,omitempty"` - Distance int32 `protobuf:"varint,3,opt,name=distance,proto3" json:"distance,omitempty"` - ElapsedTime int32 `protobuf:"varint,4,opt,name=elapsed_time,json=elapsedTime,proto3" json:"elapsed_time,omitempty"` -} - -func (x *RouteSummary) Reset() { - *x = RouteSummary{} - if protoimpl.UnsafeEnabled { - mi := &file_route_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RouteSummary) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RouteSummary) ProtoMessage() {} - -func (x *RouteSummary) ProtoReflect() protoreflect.Message { - mi := &file_route_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RouteSummary.ProtoReflect.Descriptor instead. -func (*RouteSummary) Descriptor() ([]byte, []int) { - return file_route_proto_rawDescGZIP(), []int{3} -} - -func (x *RouteSummary) GetPointCount() int32 { - if x != nil { - return x.PointCount - } - return 0 -} - -func (x *RouteSummary) GetFeatureCount() int32 { - if x != nil { - return x.FeatureCount - } - return 0 -} - -func (x *RouteSummary) GetDistance() int32 { - if x != nil { - return x.Distance - } - return 0 -} - -func (x *RouteSummary) GetElapsedTime() int32 { - if x != nil { - return x.ElapsedTime - } - return 0 -} - -type RouteNote struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Location *Point `protobuf:"bytes,1,opt,name=location,proto3" json:"location,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *RouteNote) Reset() { - *x = RouteNote{} - if protoimpl.UnsafeEnabled { - mi := &file_route_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *RouteNote) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RouteNote) ProtoMessage() {} - -func (x *RouteNote) ProtoReflect() protoreflect.Message { - mi := &file_route_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RouteNote.ProtoReflect.Descriptor instead. -func (*RouteNote) Descriptor() ([]byte, []int) { - return file_route_proto_rawDescGZIP(), []int{4} -} - -func (x *RouteNote) GetLocation() *Point { - if x != nil { - return x.Location - } - return nil -} - -func (x *RouteNote) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_route_proto protoreflect.FileDescriptor - -var file_route_proto_rawDesc = []byte{ - 0x0a, 0x0b, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x22, 0x41, 0x0a, 0x05, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, - 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x08, 0x6c, 0x61, 0x74, 0x69, 0x74, 0x75, 0x64, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x6e, - 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6c, 0x6f, - 0x6e, 0x67, 0x69, 0x74, 0x75, 0x64, 0x65, 0x22, 0x47, 0x0a, 0x07, 0x46, 0x65, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, - 0x2e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x22, 0x47, 0x0a, 0x09, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6e, 0x67, 0x6c, 0x65, 0x12, 0x1c, 0x0a, - 0x02, 0x6c, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x2e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x02, 0x6c, 0x6f, 0x12, 0x1c, 0x0a, 0x02, 0x68, - 0x69, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, - 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x02, 0x68, 0x69, 0x22, 0x93, 0x01, 0x0a, 0x0c, 0x52, 0x6f, - 0x75, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, - 0x69, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x66, - 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0c, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x08, 0x64, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x21, 0x0a, 0x0c, - 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0b, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x22, - 0x4f, 0x0a, 0x09, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x4e, 0x6f, 0x74, 0x65, 0x12, 0x28, 0x0a, 0x08, - 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, - 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x08, 0x6c, 0x6f, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x32, 0xd8, 0x01, 0x0a, 0x05, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x2c, 0x0a, 0x0a, 0x47, 0x65, - 0x74, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x0c, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, - 0x2e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x1a, 0x0e, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x46, - 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, - 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x12, 0x10, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, - 0x2e, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6e, 0x67, 0x6c, 0x65, 0x1a, 0x0e, 0x2e, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x34, - 0x0a, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x0c, 0x2e, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x1a, 0x13, 0x2e, 0x72, 0x6f, - 0x75, 0x74, 0x65, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, - 0x22, 0x00, 0x28, 0x01, 0x12, 0x35, 0x0a, 0x09, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x43, 0x68, 0x61, - 0x74, 0x12, 0x10, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x4e, - 0x6f, 0x74, 0x65, 0x1a, 0x10, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x2e, 0x52, 0x6f, 0x75, 0x74, - 0x65, 0x4e, 0x6f, 0x74, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x2a, 0x5a, 0x28, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x74, 0x77, 0x61, 0x79, - 0x2f, 0x67, 0x6f, 0x74, 0x77, 0x61, 0x79, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_route_proto_rawDescOnce sync.Once - file_route_proto_rawDescData = file_route_proto_rawDesc -) - -func file_route_proto_rawDescGZIP() []byte { - file_route_proto_rawDescOnce.Do(func() { - file_route_proto_rawDescData = protoimpl.X.CompressGZIP(file_route_proto_rawDescData) - }) - return file_route_proto_rawDescData -} - -var file_route_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_route_proto_goTypes = []interface{}{ - (*Point)(nil), // 0: route.Point - (*Feature)(nil), // 1: route.Feature - (*Rectangle)(nil), // 2: route.Rectangle - (*RouteSummary)(nil), // 3: route.RouteSummary - (*RouteNote)(nil), // 4: route.RouteNote -} -var file_route_proto_depIdxs = []int32{ - 0, // 0: route.Feature.location:type_name -> route.Point - 0, // 1: route.Rectangle.lo:type_name -> route.Point - 0, // 2: route.Rectangle.hi:type_name -> route.Point - 0, // 3: route.RouteNote.location:type_name -> route.Point - 0, // 4: route.Route.GetFeature:input_type -> route.Point - 2, // 5: route.Route.ListFeatures:input_type -> route.Rectangle - 0, // 6: route.Route.RecordRoute:input_type -> route.Point - 4, // 7: route.Route.RouteChat:input_type -> route.RouteNote - 1, // 8: route.Route.GetFeature:output_type -> route.Feature - 1, // 9: route.Route.ListFeatures:output_type -> route.Feature - 3, // 10: route.Route.RecordRoute:output_type -> route.RouteSummary - 4, // 11: route.Route.RouteChat:output_type -> route.RouteNote - 8, // [8:12] is the sub-list for method output_type - 4, // [4:8] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_route_proto_init() } -func file_route_proto_init() { - if File_route_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_route_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Point); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_route_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Feature); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_route_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Rectangle); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_route_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RouteSummary); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_route_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*RouteNote); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_route_proto_rawDesc, - NumEnums: 0, - NumMessages: 5, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_route_proto_goTypes, - DependencyIndexes: file_route_proto_depIdxs, - MessageInfos: file_route_proto_msgTypes, - }.Build() - File_route_proto = out.File - file_route_proto_rawDesc = nil - file_route_proto_goTypes = nil - file_route_proto_depIdxs = nil -} diff --git a/pkg/route/pb/route.proto b/pkg/route/pb/route.proto deleted file mode 100644 index 9d15283..0000000 --- a/pkg/route/pb/route.proto +++ /dev/null @@ -1,39 +0,0 @@ -syntax = "proto3"; - -option go_package = "github.com/gotway/service-examples/pkg/route"; - -package route; - -service Route { - rpc GetFeature(Point) returns (Feature) {} - rpc ListFeatures(Rectangle) returns (stream Feature) {} - rpc RecordRoute(stream Point) returns (RouteSummary) {} - rpc RouteChat(stream RouteNote) returns (stream RouteNote) {} -} - -message Point { - int32 latitude = 1; - int32 longitude = 2; -} - -message Feature { - string name = 1; - Point location = 2; -} - -message Rectangle { - Point lo = 1; - Point hi = 2; -} - -message RouteSummary { - int32 point_count = 1; - int32 feature_count = 2; - int32 distance = 3; - int32 elapsed_time = 4; -} - -message RouteNote { - Point location = 1; - string message = 2; -} \ No newline at end of file diff --git a/pkg/route/pb/route_grpc.pb.go b/pkg/route/pb/route_grpc.pb.go deleted file mode 100644 index a54e7ec..0000000 --- a/pkg/route/pb/route_grpc.pb.go +++ /dev/null @@ -1,303 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package route - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// RouteClient is the client API for Route service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type RouteClient interface { - GetFeature(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Feature, error) - ListFeatures(ctx context.Context, in *Rectangle, opts ...grpc.CallOption) (Route_ListFeaturesClient, error) - RecordRoute(ctx context.Context, opts ...grpc.CallOption) (Route_RecordRouteClient, error) - RouteChat(ctx context.Context, opts ...grpc.CallOption) (Route_RouteChatClient, error) -} - -type routeClient struct { - cc grpc.ClientConnInterface -} - -func NewRouteClient(cc grpc.ClientConnInterface) RouteClient { - return &routeClient{cc} -} - -func (c *routeClient) GetFeature(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Feature, error) { - out := new(Feature) - err := c.cc.Invoke(ctx, "/route.Route/GetFeature", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *routeClient) ListFeatures(ctx context.Context, in *Rectangle, opts ...grpc.CallOption) (Route_ListFeaturesClient, error) { - stream, err := c.cc.NewStream(ctx, &Route_ServiceDesc.Streams[0], "/route.Route/ListFeatures", opts...) - if err != nil { - return nil, err - } - x := &routeListFeaturesClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Route_ListFeaturesClient interface { - Recv() (*Feature, error) - grpc.ClientStream -} - -type routeListFeaturesClient struct { - grpc.ClientStream -} - -func (x *routeListFeaturesClient) Recv() (*Feature, error) { - m := new(Feature) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *routeClient) RecordRoute(ctx context.Context, opts ...grpc.CallOption) (Route_RecordRouteClient, error) { - stream, err := c.cc.NewStream(ctx, &Route_ServiceDesc.Streams[1], "/route.Route/RecordRoute", opts...) - if err != nil { - return nil, err - } - x := &routeRecordRouteClient{stream} - return x, nil -} - -type Route_RecordRouteClient interface { - Send(*Point) error - CloseAndRecv() (*RouteSummary, error) - grpc.ClientStream -} - -type routeRecordRouteClient struct { - grpc.ClientStream -} - -func (x *routeRecordRouteClient) Send(m *Point) error { - return x.ClientStream.SendMsg(m) -} - -func (x *routeRecordRouteClient) CloseAndRecv() (*RouteSummary, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(RouteSummary) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *routeClient) RouteChat(ctx context.Context, opts ...grpc.CallOption) (Route_RouteChatClient, error) { - stream, err := c.cc.NewStream(ctx, &Route_ServiceDesc.Streams[2], "/route.Route/RouteChat", opts...) - if err != nil { - return nil, err - } - x := &routeRouteChatClient{stream} - return x, nil -} - -type Route_RouteChatClient interface { - Send(*RouteNote) error - Recv() (*RouteNote, error) - grpc.ClientStream -} - -type routeRouteChatClient struct { - grpc.ClientStream -} - -func (x *routeRouteChatClient) Send(m *RouteNote) error { - return x.ClientStream.SendMsg(m) -} - -func (x *routeRouteChatClient) Recv() (*RouteNote, error) { - m := new(RouteNote) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// RouteServer is the server API for Route service. -// All implementations must embed UnimplementedRouteServer -// for forward compatibility -type RouteServer interface { - GetFeature(context.Context, *Point) (*Feature, error) - ListFeatures(*Rectangle, Route_ListFeaturesServer) error - RecordRoute(Route_RecordRouteServer) error - RouteChat(Route_RouteChatServer) error - mustEmbedUnimplementedRouteServer() -} - -// UnimplementedRouteServer must be embedded to have forward compatible implementations. -type UnimplementedRouteServer struct { -} - -func (UnimplementedRouteServer) GetFeature(context.Context, *Point) (*Feature, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetFeature not implemented") -} -func (UnimplementedRouteServer) ListFeatures(*Rectangle, Route_ListFeaturesServer) error { - return status.Errorf(codes.Unimplemented, "method ListFeatures not implemented") -} -func (UnimplementedRouteServer) RecordRoute(Route_RecordRouteServer) error { - return status.Errorf(codes.Unimplemented, "method RecordRoute not implemented") -} -func (UnimplementedRouteServer) RouteChat(Route_RouteChatServer) error { - return status.Errorf(codes.Unimplemented, "method RouteChat not implemented") -} -func (UnimplementedRouteServer) mustEmbedUnimplementedRouteServer() {} - -// UnsafeRouteServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to RouteServer will -// result in compilation errors. -type UnsafeRouteServer interface { - mustEmbedUnimplementedRouteServer() -} - -func RegisterRouteServer(s grpc.ServiceRegistrar, srv RouteServer) { - s.RegisterService(&Route_ServiceDesc, srv) -} - -func _Route_GetFeature_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Point) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RouteServer).GetFeature(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/route.Route/GetFeature", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RouteServer).GetFeature(ctx, req.(*Point)) - } - return interceptor(ctx, in, info, handler) -} - -func _Route_ListFeatures_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Rectangle) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(RouteServer).ListFeatures(m, &routeListFeaturesServer{stream}) -} - -type Route_ListFeaturesServer interface { - Send(*Feature) error - grpc.ServerStream -} - -type routeListFeaturesServer struct { - grpc.ServerStream -} - -func (x *routeListFeaturesServer) Send(m *Feature) error { - return x.ServerStream.SendMsg(m) -} - -func _Route_RecordRoute_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(RouteServer).RecordRoute(&routeRecordRouteServer{stream}) -} - -type Route_RecordRouteServer interface { - SendAndClose(*RouteSummary) error - Recv() (*Point, error) - grpc.ServerStream -} - -type routeRecordRouteServer struct { - grpc.ServerStream -} - -func (x *routeRecordRouteServer) SendAndClose(m *RouteSummary) error { - return x.ServerStream.SendMsg(m) -} - -func (x *routeRecordRouteServer) Recv() (*Point, error) { - m := new(Point) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _Route_RouteChat_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(RouteServer).RouteChat(&routeRouteChatServer{stream}) -} - -type Route_RouteChatServer interface { - Send(*RouteNote) error - Recv() (*RouteNote, error) - grpc.ServerStream -} - -type routeRouteChatServer struct { - grpc.ServerStream -} - -func (x *routeRouteChatServer) Send(m *RouteNote) error { - return x.ServerStream.SendMsg(m) -} - -func (x *routeRouteChatServer) Recv() (*RouteNote, error) { - m := new(RouteNote) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -// Route_ServiceDesc is the grpc.ServiceDesc for Route service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Route_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "route.Route", - HandlerType: (*RouteServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetFeature", - Handler: _Route_GetFeature_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "ListFeatures", - Handler: _Route_ListFeatures_Handler, - ServerStreams: true, - }, - { - StreamName: "RecordRoute", - Handler: _Route_RecordRoute_Handler, - ClientStreams: true, - }, - { - StreamName: "RouteChat", - Handler: _Route_RouteChat_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "route.proto", -} diff --git a/pkg/route/route.go b/pkg/route/route.go deleted file mode 100644 index 7a8d25c..0000000 --- a/pkg/route/route.go +++ /dev/null @@ -1,133 +0,0 @@ -package route - -import ( - "context" - "fmt" - "io" - "time" - - pb "github.com/gotway/service-examples/pkg/route/pb" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - healthpb "google.golang.org/grpc/health/grpc_health_v1" -) - -type TLSOptions struct { - Enabled bool - CA string - ServerHost string -} - -type ClientOptions struct { - Timeout time.Duration - TLS TLSOptions -} - -type Client struct { - conn *grpc.ClientConn - healthClient healthpb.HealthClient - routeClient pb.RouteClient - options ClientOptions -} - -func (c *Client) HealthCheck(ctx context.Context) (*healthpb.HealthCheckResponse, error) { - return c.healthClient.Check(ctx, &healthpb.HealthCheckRequest{}) -} - -func (c *Client) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) { - return c.routeClient.GetFeature(ctx, point) -} - -func (c *Client) ListFeatures(ctx context.Context, rect *pb.Rectangle) ([]*pb.Feature, error) { - stream, err := c.routeClient.ListFeatures(ctx, rect) - if err != nil { - return nil, err - } - var features []*pb.Feature - for { - feature, err := stream.Recv() - if err == io.EOF { - return features, nil - } - if err != nil { - return features, err - } - features = append(features, feature) - } -} - -func (c *Client) RecordRoute(ctx context.Context) (*pb.RouteSummary, error) { - stream, err := c.routeClient.RecordRoute(ctx) - if err != nil { - return nil, err - } - for _, point := range randomPoints() { - if err := stream.Send(point); err != nil { - return nil, err - } - } - summary, err := stream.CloseAndRecv() - if err != nil { - return nil, err - } - return summary, nil -} - -func (c *Client) RouteChat(ctx context.Context) ([]*pb.RouteNote, error) { - stream, err := c.routeClient.RouteChat(ctx) - if err != nil { - return nil, err - } - done := make(chan struct{}) - var recvNotes []*pb.RouteNote - go func() { - for { - note, err := stream.Recv() - if err == io.EOF { - close(done) - return - } - recvNotes = append(recvNotes, note) - } - }() - for _, note := range notes() { - if err := stream.Send(note); err != nil { - return nil, err - } - } - stream.CloseSend() - <-done - - return recvNotes, nil -} - -func (c *Client) Close() { - c.conn.Close() -} - -func getConn(server string, clientOpts ClientOptions) (*grpc.ClientConn, error) { - opts := []grpc.DialOption{ - grpc.WithBlock(), - grpc.WithTimeout(clientOpts.Timeout), - } - if clientOpts.TLS.Enabled { - creds, err := credentials.NewClientTLSFromFile(clientOpts.TLS.CA, clientOpts.TLS.ServerHost) - if err != nil { - return nil, fmt.Errorf("Failed to create TLS credentials %v", err) - } - opts = append(opts, grpc.WithTransportCredentials(creds)) - } else { - opts = append(opts, grpc.WithInsecure()) - } - return grpc.Dial(server, opts...) -} - -func NewClient(server string, opts ClientOptions) (*Client, error) { - conn, err := getConn(server, opts) - if err != nil { - return nil, err - } - client := pb.NewRouteClient(conn) - healthClient := healthpb.NewHealthClient(conn) - return &Client{conn, healthClient, client, opts}, nil -} diff --git a/scripts/tmux.sh b/scripts/tmux.sh deleted file mode 100755 index 767f6bc..0000000 --- a/scripts/tmux.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -set -e - -tmux new-session -d -s services -tab=0 - -function new_tab() { - name="$1" - path="$2" - tab=$(($tab + 1)) - tmux new-window -t services:"$tab" -n "$name" - tmux send-keys -t services:"$tab" "cd $path; make run" enter -} - -for ms in $(ls -d cmd/*); do - name=$(basename "$ms") - path="$ms" - new_tab "$name" "$path" -done - -tmux select-window -t services:1 - -tmux attach -t services