package elastic import ( "context" ) func (c *Client) Read(context.Context) (*Data, error) { data, ok := <-c.ch if !ok { return nil, fmt.Errorf("error reading data from channel") } index := data.Header.Index if !ok { return nil, fmt.Errorf("error index not found in data header") } offset, ok := c.offsets[index] if !ok { return nil, fmt.Errorf("error offset index not found") } c.offsets[index] = offset + 1 err := setOffset(c.db, index, c.offsets[index]) if err != nil { return nil, err } return &data, nil }