func (p *Payload) Produce(c model.Cluster) error { leader, err := c.Leader(p.Topic, p.Partition) if err != nil { return err } if err := p.DoProduce(leader); err != nil { if IsNotLeader(err) { c.LeaderIsDown(p.Topic, p.Partition) } return err } return nil }
func (o *OffsetByTime) Fetch(c model.Cluster) (int64, error) { leader, err := c.Leader(o.Topic, o.Partition) if err != nil { return -1, err } offset, err := o.DoFetch(leader) if err != nil { if IsNotLeader(err) { c.LeaderIsDown(o.Topic, o.Partition) } return -1, err } return offset, nil }
func (m *Messages) Consume(c model.Cluster) (MessageSet, error) { leader, err := c.Leader(m.Topic, m.Partition) if err != nil { return nil, err } ms, err := m.DoConsume(leader) if err != nil { if IsNotLeader(err) { c.LeaderIsDown(m.Topic, m.Partition) } return nil, err } return ms, nil }