Files
go-cart-actor/pkg/actor/grain_pool.go
matst80 9fc3871e84 better
2025-10-13 15:39:41 +02:00

37 lines
871 B
Go

package actor
import (
"net/http"
"github.com/gogo/protobuf/proto"
)
type GrainPool[V any] interface {
Apply(id uint64, mutation proto.Message) (V, error)
Get(id uint64) (V, error)
OwnerHost(id uint64) (Host, bool)
Hostname() string
TakeOwnership(id uint64)
HandleOwnershipChange(host string, ids []uint64) error
HandleRemoteExpiry(host string, ids []uint64) error
Negotiate(otherHosts []string)
GetLocalIds() []uint64
RemoveHost(host string)
IsHealthy() bool
IsKnown(string) bool
Close()
}
// Host abstracts a remote node capable of proxying cart requests.
type Host interface {
AnnounceExpiry(ids []uint64)
Negotiate(otherHosts []string) ([]string, error)
Name() string
Proxy(id uint64, w http.ResponseWriter, r *http.Request) (bool, error)
GetActorIds() []uint64
Close() error
Ping() bool
IsHealthy() bool
AnnounceOwnership(ids []uint64)
}