Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump tower-http from 0.4.4 to 0.5.0 #34

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

- package-ecosystem: "cargo" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

- package-ecosystem: "gomod"
directory: "/backend/gateway"
schedule:
interval: "weekly"

- package-ecosystem: "gomod"
directory: "/kubernetes/operators/application"
schedule:
interval: "weekly"

- package-ecosystem: "npm"
directory: "/frontend"
schedule:
interval: "weekly"

- package-ecosystem: "terraform"
directory: "/cloud"
schedule:
interval: "weekly"
87 changes: 57 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ tokio-util = "0.7.10"
tonic = { version = "0.10.2", features = ["gzip"] }
tonic-reflection = "0.10.2"
tower = "0.4.13"
tower-http = { version = "0.4", features = ["trace"] }
tower-http = { version = "0.5", features = ["trace"] }
tracing = { version = "0.1.40", default-features = false }
tracing-opentelemetry = { version = "0.22.0", default-features = false }
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["fmt", "env-filter"] }
Expand Down
10 changes: 5 additions & 5 deletions backend/gateway/authentication_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ func authenticationMiddleware(next http.Handler) http.Handler {

jwt, err := utils.ExtractJwtFromAuthorizationHeader(authorizationHeader)
if err != nil {
http.Error(w, err.Error( ), http.StatusBadRequest)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}

// TODO: Add a timeout.
response, err := usersMicroserviceConnector.VerifyJwt(context.Background( ),
&grpc_generated.VerifyJwtRequest{ Jwt: jwt })
response, err := usersMicroserviceConnector.VerifyJwt(context.Background(),
&grpc_generated.VerifyJwtRequest{Jwt: jwt})
if err != nil {
http.Error(w, "server error occurred", http.StatusInternalServerError)
return
}

// Add the user-id in context.
ctx := context.WithValue(r.Context( ), utils.USER_ID_CONTEXT_KEY, response.UserId)
ctx := context.WithValue(r.Context(), utils.USER_ID_CONTEXT_KEY, response.UserId)
r = r.WithContext(ctx)

next.ServeHTTP(w, r)
})
}
}
13 changes: 7 additions & 6 deletions backend/gateway/connectors/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ import (
)

type Connector interface {
Healthcheck( ) error
Healthcheck() error

Disconnect( )
Disconnect()
}

func createGrpcConnection(serviceName, address string) *grpc.ClientConn {
connection, err := grpc.Dial(address,
grpc.WithTransportCredentials(insecure.NewCredentials( )),
grpc.WithStatsHandler(otelgrpc.NewClientHandler( )),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithStatsHandler(otelgrpc.NewClientHandler()),
)
if err != nil {
log.Fatalf("Couldn't connect to %s at %s : %v", serviceName, address, err)}
log.Fatalf("Couldn't connect to %s at %s : %v", serviceName, address, err)
}

return connection
}
}
35 changes: 19 additions & 16 deletions backend/gateway/connectors/feeds_microservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,39 @@ type FeedsMicroserviceConnector struct {
grpcConnection *grpc.ClientConn
}

func NewFeedsMicroserviceConnector( ) *FeedsMicroserviceConnector {
u := &FeedsMicroserviceConnector {
func NewFeedsMicroserviceConnector() *FeedsMicroserviceConnector {
u := &FeedsMicroserviceConnector{
serviceName: "feeds microservice",
address: utils.Envs.FEEDS_MICROSERVICE_URL,
address: utils.Envs.FEEDS_MICROSERVICE_URL,
}

u.grpcConnection= createGrpcConnection(u.serviceName, u.address)
u.FeedsServiceClient= grpc_generated.NewFeedsServiceClient(u.grpcConnection)
u.grpcConnection = createGrpcConnection(u.serviceName, u.address)
u.FeedsServiceClient = grpc_generated.NewFeedsServiceClient(u.grpcConnection)

if err := u.Healthcheck( ); err != nil {
log.Fatalf("Couldn't connect to feeds microservice : %v", err)}
if err := u.Healthcheck(); err != nil {
log.Fatalf("Couldn't connect to feeds microservice : %v", err)
}

log.Debugf("Connected to %s", u.serviceName)

return u
}

func(u *FeedsMicroserviceConnector) Healthcheck( ) error {
ctx, cancel := context.WithTimeout(context.Background( ), 5 * time.Second)
defer cancel( )
func (u *FeedsMicroserviceConnector) Healthcheck() error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

if _, err := u.Ping(ctx, &emptypb.Empty{ }); err != nil {
return fmt.Errorf("error pinging %s: %v", u.serviceName, err)}
if _, err := u.Ping(ctx, &emptypb.Empty{}); err != nil {
return fmt.Errorf("error pinging %s: %v", u.serviceName, err)
}

return nil
}

func(u *FeedsMicroserviceConnector) Disconnect( ) {
if err := u.grpcConnection.Close( ); err != nil {
log.Errorf("Error closing connection to %s : %v", u.serviceName, err)}
func (u *FeedsMicroserviceConnector) Disconnect() {
if err := u.grpcConnection.Close(); err != nil {
log.Errorf("Error closing connection to %s : %v", u.serviceName, err)
}

log.Debugf("Closed connection to %s", u.serviceName)
}
}
Loading
Loading