2024-10-07 15:25:13 +05:30
|
|
|
package elastic
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-10-07 22:41:59 +05:30
|
|
|
"fmt"
|
2024-10-07 16:26:41 +05:30
|
|
|
|
|
|
|
"elasticstream/source"
|
2024-10-07 15:25:13 +05:30
|
|
|
)
|
|
|
|
|
2024-10-07 16:26:41 +05:30
|
|
|
func (c *Client) Ack(ctx context.Context, position source.Position) error {
|
2024-10-07 22:41:59 +05:30
|
|
|
curr := c.offsets[position.Index]
|
2024-10-07 15:25:13 +05:30
|
|
|
|
2024-10-07 22:41:59 +05:30
|
|
|
fmt.Println("curr:", curr)
|
|
|
|
fmt.Println("asked:", position.Pos)
|
|
|
|
|
|
|
|
for _, p := range c.positions {
|
|
|
|
if p.Index == position.Index {
|
|
|
|
fmt.Println("initial:", p.Pos)
|
|
|
|
if p.Pos > position.Pos {
|
|
|
|
return fmt.Errorf("not acknowledged pos less than initial position")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if curr < position.Pos {
|
|
|
|
return fmt.Errorf("not acknowledged pos more than current position")
|
|
|
|
}
|
2024-10-07 15:25:13 +05:30
|
|
|
return nil
|
|
|
|
}
|