1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-11 02:13:49 +09:00
any-sync/commonspace/sync/synctest/counterresponsecollector.go
2024-06-13 09:47:47 +02:00

22 lines
588 B
Go

package synctest
import (
"context"
"github.com/anyproto/any-sync/commonspace/sync/syncdeps"
"github.com/anyproto/any-sync/commonspace/sync/synctestproto"
)
type CounterResponseCollector struct {
counter *Counter
}
func NewCounterResponseCollector(counter *Counter) *CounterResponseCollector {
return &CounterResponseCollector{counter: counter}
}
func (c *CounterResponseCollector) CollectResponse(ctx context.Context, peerId, objectId string, resp syncdeps.Response) error {
counterResp := resp.(*synctestproto.CounterIncrease)
c.counter.Add(counterResp.Value)
return nil
}