more
This commit is contained in:
@@ -371,13 +371,15 @@ 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) (*MutationResult[*V], error) {
|
||||
grain, err := p.getOrClaimGrain(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if applyErr := p.mutationRegistry.Apply(grain, mutation...); applyErr != nil {
|
||||
return nil, applyErr
|
||||
|
||||
mutations, err := p.mutationRegistry.Apply(grain, mutation...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if p.storage != nil {
|
||||
go func() {
|
||||
@@ -386,7 +388,14 @@ func (p *SimpleGrainPool[V]) Apply(id uint64, mutation ...proto.Message) (*V, er
|
||||
}
|
||||
}()
|
||||
}
|
||||
return grain.GetCurrentState()
|
||||
result, err := grain.GetCurrentState()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &MutationResult[*V]{
|
||||
Result: result,
|
||||
Mutations: mutations,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Get returns the current state of a grain.
|
||||
|
||||
Reference in New Issue
Block a user