fix go builds after deleting pkg internal
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
dff246a3d7
commit
61cf05844d
13 changed files with 56 additions and 57 deletions
|
@ -8,7 +8,7 @@ RUN go build -o /cartservice_probe .
|
|||
# cartservice
|
||||
FROM gcr.io/google-appengine/aspnetcore:2.1.0
|
||||
COPY --from=builder /cartservice_probe /cartservice_probe
|
||||
RUN apt update && apt install net-tools telnet
|
||||
RUN apt-get update && apt-get install net-tools telnet
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN dotnet restore && \
|
||||
|
|
|
@ -6,10 +6,9 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"microservices-demo/src/internal"
|
||||
|
||||
pb "./genproto"
|
||||
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
@ -24,7 +23,8 @@ func main() {
|
|||
"127.0.0.1:"+port,
|
||||
grpc.WithBlock(),
|
||||
grpc.WithTimeout(time.Second*3),
|
||||
internal.DefaultDialOptions(),
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithStatsHandler(&ocgrpc.ClientHandler{}),
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("probe failed: failed to connect: %+v", err)
|
||||
|
|
|
@ -6,7 +6,8 @@ WORKDIR /go/src/checkoutservice
|
|||
RUN go get -d github.com/google/uuid \
|
||||
google.golang.org/grpc \
|
||||
google.golang.org/grpc/codes \
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/status \
|
||||
go.opencensus.io/plugin/ocgrpc
|
||||
COPY . .
|
||||
# get remaining dependencies
|
||||
RUN go get -d ./...
|
||||
|
|
|
@ -7,9 +7,8 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
|
||||
"microservices-demo/src/internal"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -52,7 +51,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
srv := grpc.NewServer(internal.DefaultServerOptions()...)
|
||||
srv := grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{}))
|
||||
pb.RegisterCheckoutServiceServer(srv, svc)
|
||||
log.Printf("starting to listen on tcp: %q", lis.Addr().String())
|
||||
log.Fatal(srv.Serve(lis))
|
||||
|
@ -149,7 +148,9 @@ func (cs *checkoutService) prepareOrderItemsAndShippingQuoteFromCart(ctx context
|
|||
}
|
||||
|
||||
func (cs *checkoutService) quoteShipping(ctx context.Context, address *pb.Address, items []*pb.CartItem) (*pb.Money, error) {
|
||||
conn, err := grpc.DialContext(ctx, cs.shippingSvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.shippingSvcAddr,
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not connect shipping service: %+v", err)
|
||||
}
|
||||
|
@ -166,7 +167,7 @@ func (cs *checkoutService) quoteShipping(ctx context.Context, address *pb.Addres
|
|||
}
|
||||
|
||||
func (cs *checkoutService) getUserCart(ctx context.Context, userID string) ([]*pb.CartItem, error) {
|
||||
conn, err := grpc.DialContext(ctx, cs.cartSvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.cartSvcAddr, grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not connect cart service: %+v", err)
|
||||
}
|
||||
|
@ -180,7 +181,7 @@ func (cs *checkoutService) getUserCart(ctx context.Context, userID string) ([]*p
|
|||
}
|
||||
|
||||
func (cs *checkoutService) emptyUserCart(ctx context.Context, userID string) error {
|
||||
conn, err := grpc.DialContext(ctx, cs.cartSvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.cartSvcAddr, grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not connect cart service: %+v", err)
|
||||
}
|
||||
|
@ -195,7 +196,7 @@ func (cs *checkoutService) emptyUserCart(ctx context.Context, userID string) err
|
|||
func (cs *checkoutService) prepOrderItems(ctx context.Context, items []*pb.CartItem, userCurrency string) ([]*pb.OrderItem, error) {
|
||||
out := make([]*pb.OrderItem, len(items))
|
||||
|
||||
conn, err := grpc.DialContext(ctx, cs.productCatalogSvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.productCatalogSvcAddr, grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not connect product catalog service: %+v", err)
|
||||
}
|
||||
|
@ -219,7 +220,7 @@ func (cs *checkoutService) prepOrderItems(ctx context.Context, items []*pb.CartI
|
|||
}
|
||||
|
||||
func (cs *checkoutService) convertCurrency(ctx context.Context, from *pb.Money, toCurrency string) (*pb.Money, error) {
|
||||
conn, err := grpc.DialContext(ctx, cs.currencySvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.currencySvcAddr, grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not connect currency service: %+v", err)
|
||||
}
|
||||
|
@ -234,7 +235,7 @@ func (cs *checkoutService) convertCurrency(ctx context.Context, from *pb.Money,
|
|||
}
|
||||
|
||||
func (cs *checkoutService) chargeCard(ctx context.Context, amount *pb.Money, paymentInfo *pb.CreditCardInfo) (string, error) {
|
||||
conn, err := grpc.DialContext(ctx, cs.paymentSvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.paymentSvcAddr, grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to connect payment service: %+v", err)
|
||||
}
|
||||
|
@ -250,7 +251,7 @@ func (cs *checkoutService) chargeCard(ctx context.Context, amount *pb.Money, pay
|
|||
}
|
||||
|
||||
func (cs *checkoutService) sendOrderConfirmation(ctx context.Context, email string, order *pb.OrderResult) error {
|
||||
conn, err := grpc.DialContext(ctx, cs.emailSvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.emailSvcAddr, grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect email service: %+v", err)
|
||||
}
|
||||
|
@ -262,7 +263,7 @@ func (cs *checkoutService) sendOrderConfirmation(ctx context.Context, email stri
|
|||
}
|
||||
|
||||
func (cs *checkoutService) shipOrder(ctx context.Context, address *pb.Address, items []*pb.CartItem) (string, error) {
|
||||
conn, err := grpc.DialContext(ctx, cs.shippingSvcAddr, internal.DefaultDialOptions()...)
|
||||
conn, err := grpc.DialContext(ctx, cs.shippingSvcAddr, grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to connect email service: %+v", err)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,9 @@ RUN go get -d github.com/google/uuid \
|
|||
github.com/sirupsen/logrus \
|
||||
google.golang.org/grpc \
|
||||
google.golang.org/grpc/codes \
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/status \
|
||||
go.opencensus.io/plugin/ochttp \
|
||||
go.opencensus.io/plugin/ochttp/propagation/b3
|
||||
|
||||
# copy go-only part of the build
|
||||
COPY *.go ./
|
||||
|
|
|
@ -7,11 +7,10 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"microservices-demo/src/internal"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"go.opencensus.io/plugin/ochttp/propagation/b3"
|
||||
"google.golang.org/grpc"
|
||||
|
@ -117,7 +116,10 @@ func mustMapEnv(target *string, envKey string) {
|
|||
|
||||
func mustConnGRPC(ctx context.Context, conn **grpc.ClientConn, addr string) {
|
||||
var err error
|
||||
*conn, err = grpc.DialContext(ctx, addr, grpc.WithTimeout(time.Second*3), internal.DefaultDialOptions()...)
|
||||
*conn, err = grpc.DialContext(ctx, addr,
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithTimeout(time.Second*3),
|
||||
grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
panic(errors.Wrapf(err, "grpc: failed to connect %s", addr))
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package internal
|
||||
|
||||
import "google.golang.org/grpc"
|
||||
import "go.opencensus.io/plugin/ocgrpc"
|
||||
|
||||
func DefaultDialOptions() []grpc.DialOption {
|
||||
return []grpc.DialOption{
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithStatsHandler(&ocgrpc.ClientHandler{}),
|
||||
}
|
||||
}
|
||||
|
||||
func DefaultServerOptions() []grpc.ServerOption {
|
||||
return []grpc.ServerOption{
|
||||
grpc.StatsHandler(&ocgrpc.ServerHandler{}),
|
||||
}
|
||||
}
|
|
@ -6,7 +6,8 @@ WORKDIR /src/microservices-demo/productcatalogservice
|
|||
# get known dependencies
|
||||
RUN go get -d google.golang.org/grpc \
|
||||
google.golang.org/grpc/codes \
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/status \
|
||||
go.opencensus.io/plugin/ocgrpc
|
||||
|
||||
COPY . .
|
||||
# get remaining dependencies
|
||||
|
|
|
@ -8,9 +8,8 @@ import (
|
|||
"net"
|
||||
"strings"
|
||||
|
||||
"microservices-demo/src/internal"
|
||||
|
||||
pb "./genproto"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -95,7 +94,7 @@ func run(port int) string {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
srv := grpc.NewServer(internal.DefaultServerOptions()...)
|
||||
srv := grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{}))
|
||||
pb.RegisterProductCatalogServiceServer(srv, &productCatalog{})
|
||||
go srv.Serve(l)
|
||||
return l.Addr().String()
|
||||
|
|
|
@ -2,12 +2,12 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"microservices-demo/src/internal"
|
||||
"testing"
|
||||
|
||||
pb "./genproto"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
@ -16,7 +16,9 @@ import (
|
|||
func TestServer(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
addr := run(0)
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ RUN apk add --no-cache \
|
|||
WORKDIR /src/microservices-demo/shippingservice
|
||||
# get known dependencies
|
||||
RUN go get -d golang.org/x/net/context \
|
||||
google.golang.org/grpc \
|
||||
google.golang.org/grpc/reflection
|
||||
google.golang.org/grpc \
|
||||
google.golang.org/grpc/reflection \
|
||||
go.opencensus.io/plugin/ocgrpc
|
||||
|
||||
COPY . .
|
||||
# get other dependencies
|
||||
RUN go get -d ./...
|
||||
|
|
|
@ -6,8 +6,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
|
||||
"microservices-demo/src/internal"
|
||||
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
|
@ -72,7 +71,7 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatalf("failed to listen: %v", err)
|
||||
}
|
||||
s := grpc.NewServer(internal.DefaultServerOptions()...)
|
||||
s := grpc.NewServer(grpc.StatsHandler(&ocgrpc.ServerHandler{}))
|
||||
pb.RegisterShippingServiceServer(s, &server{})
|
||||
log.Printf("Shipping Service listening on port %s", port)
|
||||
|
||||
|
|
|
@ -5,9 +5,8 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
|
||||
"microservices-demo/src/internal"
|
||||
|
||||
pb "./genproto"
|
||||
"go.opencensus.io/plugin/ocgrpc"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
@ -72,7 +71,8 @@ func main() {
|
|||
|
||||
func testProductCatalogService() error {
|
||||
addr := os.Getenv("PRODUCT_CATALOG_SERVICE_ADDR")
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -107,7 +107,8 @@ func testProductCatalogService() error {
|
|||
|
||||
func testShippingService() error {
|
||||
addr := os.Getenv("SHIPPING_SERVICE_ADDR")
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -153,7 +154,9 @@ func testShippingService() error {
|
|||
|
||||
func testRecommendationService() error {
|
||||
addr := os.Getenv("RECOMMENDATION_SERVICE_ADDR")
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(),
|
||||
grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -175,7 +178,8 @@ func testRecommendationService() error {
|
|||
|
||||
func testPaymentService() error {
|
||||
addr := os.Getenv("PAYMENT_SERVICE_ADDR")
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -203,7 +207,8 @@ func testPaymentService() error {
|
|||
|
||||
func testEmailService() error {
|
||||
addr := os.Getenv("EMAIL_SERVICE_ADDR")
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -256,7 +261,8 @@ func testEmailService() error {
|
|||
|
||||
func testCurrencyService() error {
|
||||
addr := os.Getenv("CURRENCY_SERVICE_ADDR")
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -287,7 +293,8 @@ func testCurrencyService() error {
|
|||
|
||||
func testCartService() error {
|
||||
addr := os.Getenv("CART_SERVICE_ADDR")
|
||||
conn, err := grpc.Dial(addr, internal.DefaultDialOptions())
|
||||
conn, err := grpc.Dial(addr,
|
||||
grpc.WithInsecure(), grpc.WithStatsHandler(&ocgrpc.ClientHandler{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue