Skip to content

Commit

Permalink
Remove cache implementation (#2206)
Browse files Browse the repository at this point in the history
* feat: remove cache

* fxi: fix events and event_delivery queries

* chore: go generate

* chore: delete useless comment

* chore: fix test helper
  • Loading branch information
jirevwe authored Dec 21, 2024
1 parent b8acf19 commit 7e6d440
Show file tree
Hide file tree
Showing 78 changed files with 920 additions and 1,451 deletions.
76 changes: 36 additions & 40 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ func (a *ApplicationHandler) BuildControlPlaneRoutes() *chi.Mux {
})
})



// Dashboard API.
router.Route("/ui", func(uiRouter chi.Router) {
uiRouter.Use(middleware.JsonResponse)
Expand All @@ -274,11 +272,11 @@ func (a *ApplicationHandler) BuildControlPlaneRoutes() *chi.Mux {
authRouter.Post("/logout", handler.LogoutUser)
})

uiRouter.Route("/saml", func(samlRouter chi.Router) {
samlRouter.Use(middleware.RequireValidEnterpriseSSOLicense(handler.A.Licenser))
samlRouter.Get("/login", handler.RedeemLoginSSOToken)
samlRouter.Get("/register", handler.RedeemRegisterSSOToken)
})
uiRouter.Route("/saml", func(samlRouter chi.Router) {
samlRouter.Use(middleware.RequireValidEnterpriseSSOLicense(handler.A.Licenser))
samlRouter.Get("/login", handler.RedeemLoginSSOToken)
samlRouter.Get("/register", handler.RedeemRegisterSSOToken)
})

uiRouter.Route("/users", func(userRouter chi.Router) {
userRouter.Route("/{userID}", func(userSubRouter chi.Router) {
Expand Down Expand Up @@ -475,29 +473,29 @@ func (a *ApplicationHandler) BuildControlPlaneRoutes() *chi.Mux {
})
})

portalLinkRouter.Route("/event-types", func(eventTypesRouter chi.Router) {
eventTypesRouter.Get("/", handler.GetEventTypes)
eventTypesRouter.With(handler.RequireEnabledProject()).Post("/", handler.CreateEventType)
eventTypesRouter.With(handler.RequireEnabledProject()).Put("/{eventTypeId}", handler.UpdateEventType)
eventTypesRouter.With(handler.RequireEnabledProject()).Post("/{eventTypeId}/deprecate", handler.DeprecateEventType)
})

portalLinkRouter.Route("/eventdeliveries", func(eventDeliveryRouter chi.Router) {
eventDeliveryRouter.With(middleware.Pagination).Get("/", handler.GetEventDeliveriesPaged)
eventDeliveryRouter.Post("/forceresend", handler.ForceResendEventDeliveries)
eventDeliveryRouter.Post("/batchretry", handler.BatchRetryEventDelivery)
eventDeliveryRouter.Get("/countbatchretryevents", handler.CountAffectedEventDeliveries)

eventDeliveryRouter.Route("/{eventDeliveryID}", func(eventDeliverySubRouter chi.Router) {
eventDeliverySubRouter.Get("/", handler.GetEventDelivery)
eventDeliverySubRouter.Put("/resend", handler.ResendEventDelivery)

eventDeliverySubRouter.Route("/deliveryattempts", func(deliveryRouter chi.Router) {
deliveryRouter.Get("/", handler.GetDeliveryAttempts)
deliveryRouter.Get("/{deliveryAttemptID}", handler.GetDeliveryAttempt)
})
})
})
portalLinkRouter.Route("/event-types", func(eventTypesRouter chi.Router) {
eventTypesRouter.Get("/", handler.GetEventTypes)
eventTypesRouter.With(handler.RequireEnabledProject()).Post("/", handler.CreateEventType)
eventTypesRouter.With(handler.RequireEnabledProject()).Put("/{eventTypeId}", handler.UpdateEventType)
eventTypesRouter.With(handler.RequireEnabledProject()).Post("/{eventTypeId}/deprecate", handler.DeprecateEventType)
})

portalLinkRouter.Route("/eventdeliveries", func(eventDeliveryRouter chi.Router) {
eventDeliveryRouter.With(middleware.Pagination).Get("/", handler.GetEventDeliveriesPaged)
eventDeliveryRouter.Post("/forceresend", handler.ForceResendEventDeliveries)
eventDeliveryRouter.Post("/batchretry", handler.BatchRetryEventDelivery)
eventDeliveryRouter.Get("/countbatchretryevents", handler.CountAffectedEventDeliveries)

eventDeliveryRouter.Route("/{eventDeliveryID}", func(eventDeliverySubRouter chi.Router) {
eventDeliverySubRouter.Get("/", handler.GetEventDelivery)
eventDeliverySubRouter.Put("/resend", handler.ResendEventDelivery)

eventDeliverySubRouter.Route("/deliveryattempts", func(deliveryRouter chi.Router) {
deliveryRouter.Get("/", handler.GetDeliveryAttempts)
deliveryRouter.Get("/{deliveryAttemptID}", handler.GetDeliveryAttempt)
})
})
})

portalLinkRouter.Route("/subscriptions", func(subscriptionRouter chi.Router) {
subscriptionRouter.Post("/", handler.CreateSubscription)
Expand Down Expand Up @@ -595,8 +593,6 @@ func (a *ApplicationHandler) BuildDataPlaneRoutes() *chi.Mux {
})
})



// Dashboard API.
router.Route("/ui", func(uiRouter chi.Router) {
uiRouter.Use(middleware.JsonResponse)
Expand All @@ -612,11 +608,11 @@ func (a *ApplicationHandler) BuildDataPlaneRoutes() *chi.Mux {
authRouter.Post("/logout", handler.LogoutUser)
})

uiRouter.Route("/saml", func(samlRouter chi.Router) {
samlRouter.Use(middleware.RequireValidEnterpriseSSOLicense(handler.A.Licenser))
samlRouter.Get("/login", handler.RedeemLoginSSOToken)
samlRouter.Get("/register", handler.RedeemRegisterSSOToken)
})
uiRouter.Route("/saml", func(samlRouter chi.Router) {
samlRouter.Use(middleware.RequireValidEnterpriseSSOLicense(handler.A.Licenser))
samlRouter.Get("/login", handler.RedeemLoginSSOToken)
samlRouter.Get("/register", handler.RedeemRegisterSSOToken)
})

uiRouter.Route("/organisations", func(orgRouter chi.Router) {
orgRouter.Route("/{orgID}", func(orgSubRouter chi.Router) {
Expand Down Expand Up @@ -705,7 +701,7 @@ func (a *ApplicationHandler) RegisterPolicy() error {
err = a.A.Authz.RegisterPolicy(func() authz.Policy {
po := &policies.OrganisationPolicy{
BasePolicy: authz.NewBasePolicy(),
OrganisationMemberRepo: postgres.NewOrgMemberRepo(a.A.DB, a.A.Cache),
OrganisationMemberRepo: postgres.NewOrgMemberRepo(a.A.DB),
}

po.SetRule("manage", authz.RuleFunc(po.Manage))
Expand All @@ -721,8 +717,8 @@ func (a *ApplicationHandler) RegisterPolicy() error {
po := &policies.ProjectPolicy{
BasePolicy: authz.NewBasePolicy(),
Licenser: a.A.Licenser,
OrganisationRepo: postgres.NewOrgRepo(a.A.DB, a.A.Cache),
OrganisationMemberRepo: postgres.NewOrgMemberRepo(a.A.DB, a.A.Cache),
OrganisationRepo: postgres.NewOrgRepo(a.A.DB),
OrganisationMemberRepo: postgres.NewOrgMemberRepo(a.A.DB),
}

po.SetRule("manage", authz.RuleFunc(po.Manage))
Expand Down
Loading

0 comments on commit 7e6d440

Please sign in to comment.