more
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 36s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m29s

This commit is contained in:
matst80
2025-11-28 14:33:26 +01:00
parent 47e69f18a5
commit 330093bdec
13 changed files with 200 additions and 184 deletions

View File

@@ -8,13 +8,13 @@ import (
"time"
messages "git.k6n.net/go-cart-actor/pkg/messages"
"github.com/gogo/protobuf/proto"
"go.opentelemetry.io/contrib/bridges/otelslog"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/metric"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"google.golang.org/protobuf/proto"
)
// ControlServer implements the ControlPlane gRPC services.
@@ -142,56 +142,10 @@ func (s *ControlServer[V]) Ping(ctx context.Context, _ *messages.Empty) (*messag
func (s *ControlServer[V]) Apply(ctx context.Context, in *messages.ApplyRequest) (*messages.ApplyResult, error) {
msgs := make([]proto.Message, len(in.Messages))
for i, mut := range in.Messages {
var msg proto.Message
if m := mut.GetClearCart(); m != nil {
msg = m
} else if m := mut.GetAddItem(); m != nil {
msg = m
} else if m := mut.GetRemoveItem(); m != nil {
msg = m
} else if m := mut.GetChangeQuantity(); m != nil {
msg = m
} else if m := mut.GetSetDelivery(); m != nil {
msg = m
} else if m := mut.GetSetPickupPoint(); m != nil {
msg = m
} else if m := mut.GetRemoveDelivery(); m != nil {
msg = m
} else if m := mut.GetSetUserId(); m != nil {
msg = m
} else if m := mut.GetLineItemMarking(); m != nil {
msg = m
} else if m := mut.GetRemoveLineItemMarking(); m != nil {
msg = m
} else if m := mut.GetSubscriptionAdded(); m != nil {
msg = m
} else if m := mut.GetPaymentDeclined(); m != nil {
msg = m
} else if m := mut.GetConfirmationViewed(); m != nil {
msg = m
} else if m := mut.GetCreateCheckoutOrder(); m != nil {
msg = m
} else if m := mut.GetOrderCreated(); m != nil {
msg = m
} else if m := mut.GetNoop(); m != nil {
msg = m
} else if m := mut.GetInitializeCheckout(); m != nil {
msg = m
} else if m := mut.GetInventoryReserved(); m != nil {
msg = m
} else if m := mut.GetAddVoucher(); m != nil {
msg = m
} else if m := mut.GetRemoveVoucher(); m != nil {
msg = m
} else if m := mut.GetUpsertSubscriptionDetails(); m != nil {
msg = m
} else if m := mut.GetPreConditionFailed(); m != nil {
msg = m
} else if m := mut.GetAddGiftcard(); m != nil {
msg = m
} else if m := mut.GetRemoveGiftcard(); m != nil {
msg = m
for i, anyMsg := range in.Messages {
msg, err := anyMsg.UnmarshalNew()
if err != nil {
return &messages.ApplyResult{Accepted: false}, fmt.Errorf("failed to unmarshal message: %w", err)
}
msgs[i] = msg
}