major changes
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 43s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m43s

This commit is contained in:
matst80
2025-12-04 20:56:54 +01:00
parent 6d5358b53b
commit f67eeb3c49
21 changed files with 572 additions and 242 deletions

View File

@@ -46,7 +46,7 @@ var (
)
type CheckoutPoolServer struct {
actor.GrainPool[*checkout.CheckoutGrain]
actor.GrainPool[checkout.CheckoutGrain]
pod_name string
klarnaClient *KlarnaClient
adyenClient *adyen.APIClient
@@ -54,7 +54,7 @@ type CheckoutPoolServer struct {
inventoryService *inventory.RedisInventoryService
}
func NewCheckoutPoolServer(pool actor.GrainPool[*checkout.CheckoutGrain], pod_name string, klarnaClient *KlarnaClient, cartClient *CartClient, adyenClient *adyen.APIClient) *CheckoutPoolServer {
func NewCheckoutPoolServer(pool actor.GrainPool[checkout.CheckoutGrain], pod_name string, klarnaClient *KlarnaClient, cartClient *CartClient, adyenClient *adyen.APIClient) *CheckoutPoolServer {
srv := &CheckoutPoolServer{
GrainPool: pool,
pod_name: pod_name,
@@ -66,7 +66,7 @@ func NewCheckoutPoolServer(pool actor.GrainPool[*checkout.CheckoutGrain], pod_na
return srv
}
func (s *CheckoutPoolServer) ApplyLocal(ctx context.Context, id checkout.CheckoutId, mutation ...proto.Message) (*actor.MutationResult[*checkout.CheckoutGrain], error) {
func (s *CheckoutPoolServer) ApplyLocal(ctx context.Context, id checkout.CheckoutId, mutation ...proto.Message) (*actor.MutationResult[checkout.CheckoutGrain], error) {
return s.Apply(ctx, uint64(id), mutation...)
}
@@ -90,7 +90,7 @@ func (s *CheckoutPoolServer) SetDeliveryHandler(w http.ResponseWriter, r *http.R
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) RemoveDeliveryHandler(w http.ResponseWriter, r *http.Request, id checkout.CheckoutId) error {
@@ -108,7 +108,7 @@ func (s *CheckoutPoolServer) RemoveDeliveryHandler(w http.ResponseWriter, r *htt
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) SetPickupPointHandler(w http.ResponseWriter, r *http.Request, id checkout.CheckoutId) error {
@@ -122,7 +122,7 @@ func (s *CheckoutPoolServer) SetPickupPointHandler(w http.ResponseWriter, r *htt
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) InitializeCheckoutHandler(w http.ResponseWriter, r *http.Request, id checkout.CheckoutId) error {
@@ -136,7 +136,7 @@ func (s *CheckoutPoolServer) InitializeCheckoutHandler(w http.ResponseWriter, r
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) InventoryReservedHandler(w http.ResponseWriter, r *http.Request, id checkout.CheckoutId) error {
@@ -150,7 +150,7 @@ func (s *CheckoutPoolServer) InventoryReservedHandler(w http.ResponseWriter, r *
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) OrderCreatedHandler(w http.ResponseWriter, r *http.Request, id checkout.CheckoutId) error {
@@ -164,7 +164,7 @@ func (s *CheckoutPoolServer) OrderCreatedHandler(w http.ResponseWriter, r *http.
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) ConfirmationViewedHandler(w http.ResponseWriter, r *http.Request, id checkout.CheckoutId) error {
@@ -178,7 +178,7 @@ func (s *CheckoutPoolServer) ConfirmationViewedHandler(w http.ResponseWriter, r
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) ContactDetailsUpdatedHandler(w http.ResponseWriter, r *http.Request, id checkout.CheckoutId) error {
@@ -192,7 +192,7 @@ func (s *CheckoutPoolServer) ContactDetailsUpdatedHandler(w http.ResponseWriter,
return err
}
return s.WriteResult(w, result.Result)
return s.WriteResult(w, result)
}
func (s *CheckoutPoolServer) StartCheckoutHandler(w http.ResponseWriter, r *http.Request) {
@@ -256,7 +256,7 @@ func (s *CheckoutPoolServer) StartCheckoutHandler(w http.ResponseWriter, r *http
// Set checkout cookie
setCheckoutCookie(w, checkoutId, r.TLS != nil)
if err := s.WriteResult(w, result.Result); err != nil {
if err := s.WriteResult(w, &result.Result); err != nil {
logger.Error("failed to write result", "error", err)
}
}
@@ -299,7 +299,7 @@ func (s *CheckoutPoolServer) CreateOrUpdateCheckout(r *http.Request, grain *chec
}
}
func (s *CheckoutPoolServer) ApplyKlarnaPaymentStarted(ctx context.Context, klarnaOrder *CheckoutOrder, id checkout.CheckoutId) (*actor.MutationResult[*checkout.CheckoutGrain], error) {
func (s *CheckoutPoolServer) ApplyKlarnaPaymentStarted(ctx context.Context, klarnaOrder *CheckoutOrder, id checkout.CheckoutId) (*actor.MutationResult[checkout.CheckoutGrain], error) {
method := "checkout"
return s.ApplyLocal(ctx, id, &messages.PaymentStarted{
PaymentId: klarnaOrder.ID,
@@ -329,28 +329,22 @@ func init() {
}
}
func (s *CheckoutPoolServer) applyAnywhere(ctx context.Context, id uint64, msgs ...proto.Message) error {
host, found := s.OwnerHost(id)
if !found {
_, err := s.Apply(ctx, id, msgs...)
return err
func (s *CheckoutPoolServer) GetAnywhere(ctx context.Context, checkoutId cart.CartId) (*checkout.CheckoutGrain, error) {
id := uint64(checkoutId)
if host, isOnOtherHost := s.OwnerHost(id); isOnOtherHost {
return host.Get(ctx, id)
}
_, err := host.Apply(ctx, id, msgs...)
return err
return s.Get(ctx, id)
}
func (s *CheckoutPoolServer) getAnywhere(ctx context.Context, id uint64) (*checkout.CheckoutGrain, error) {
host, found := s.OwnerHost(id)
if !found {
grain, err := s.Get(ctx, id)
return grain, err
func (s *CheckoutPoolServer) ApplyAnywhere(ctx context.Context, checkoutId cart.CartId, msgs ...proto.Message) error {
id := uint64(checkoutId)
if host, isOnOtherHost := s.OwnerHost(id); isOnOtherHost {
_, err := host.Apply(ctx, id, msgs...)
return err
}
ret := &checkout.CheckoutGrain{}
err := host.Get(ctx, id, ret)
if err != nil {
return nil, err
}
return ret, nil
_, err := s.Apply(ctx, id, msgs...)
return err
}
type StartPayment struct {