support multiple mutations
All checks were successful
Build and Publish / Metadata (push) Successful in 9s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 1m13s
Build and Publish / BuildAndDeployArm64 (push) Successful in 3m54s

This commit is contained in:
2025-10-13 19:51:27 +02:00
parent 91e398dcc3
commit 8e60cc2239
5 changed files with 33 additions and 26 deletions

View File

@@ -362,17 +362,17 @@ func (p *SimpleGrainPool[V]) getOrClaimGrain(id uint64) (Grain[V], error) {
// var ErrNotOwner = fmt.Errorf("not owner")
// Apply applies a mutation to a grain.
func (p *SimpleGrainPool[V]) Apply(id uint64, mutation proto.Message) (*V, error) {
func (p *SimpleGrainPool[V]) Apply(id uint64, mutation ...proto.Message) (*V, error) {
grain, err := p.getOrClaimGrain(id)
if err != nil {
return nil, err
}
if applyErr := p.mutationRegistry.Apply(grain, mutation); applyErr != nil {
if applyErr := p.mutationRegistry.Apply(grain, mutation...); applyErr != nil {
return nil, applyErr
}
if p.storage != nil {
go func() {
if err := p.storage.AppendEvent(id, mutation); err != nil {
if err := p.storage.AppendEvent(id, mutation...); err != nil {
log.Printf("failed to store mutation for grain %d: %v", id, err)
}
}()