From ebd15082945ccb2f42bd2f775d6ce073fcd5a27e Mon Sep 17 00:00:00 2001 From: matst80 Date: Tue, 2 Dec 2025 09:26:30 +0100 Subject: [PATCH] update --- cmd/cart/pool-server.go | 11 +++++++++++ pkg/actor/grain_pool.go | 1 + pkg/proxy/remotehost.go | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cmd/cart/pool-server.go b/cmd/cart/pool-server.go index 66c5b05..1894037 100644 --- a/cmd/cart/pool-server.go +++ b/cmd/cart/pool-server.go @@ -768,6 +768,17 @@ func (s *PoolServer) AdyenSessionHandler(w http.ResponseWriter, r *http.Request, } +func (s *PoolServer) GetAnywhere(ctx context.Context, cartId cart.CartId) (*cart.CartGrain, error) { + id := uint64(cartId) + if host, isOnOtherHost := s.OwnerHost(id); isOnOtherHost { + grain := &cart.CartGrain{} + + err := host.Get(ctx, id, grain) + return grain, err + } + return s.Get(ctx, id) +} + func (s *PoolServer) ApplyAnywhere(ctx context.Context, cartId cart.CartId, msgs ...proto.Message) error { id := uint64(cartId) if host, isOnOtherHost := s.OwnerHost(id); isOnOtherHost { diff --git a/pkg/actor/grain_pool.go b/pkg/actor/grain_pool.go index be048fb..182e46f 100644 --- a/pkg/actor/grain_pool.go +++ b/pkg/actor/grain_pool.go @@ -37,6 +37,7 @@ type Host interface { Name() string Proxy(id uint64, w http.ResponseWriter, r *http.Request, customBody io.Reader) (bool, error) Apply(ctx context.Context, id uint64, mutation ...proto.Message) (bool, error) + Get(ctx context.Context, id uint64, grain any) error GetActorIds() []uint64 Close() error Ping() bool diff --git a/pkg/proxy/remotehost.go b/pkg/proxy/remotehost.go index f0864c5..550f906 100644 --- a/pkg/proxy/remotehost.go +++ b/pkg/proxy/remotehost.go @@ -131,7 +131,7 @@ func (h *RemoteHost[V]) Ping() bool { return true } -func (h *RemoteHost[V]) Get(ctx context.Context, id uint64, grain *V) error { +func (h *RemoteHost[V]) Get(ctx context.Context, id uint64, grain any) error { ctx, cancel := context.WithTimeout(ctx, 5*time.Second) defer cancel() reply, error := h.controlClient.Get(ctx, &messages.GetRequest{Id: id})