示例#1
0
文件: command.go 项目: h12w/kpax
func (cmd *MetaCommand) Exec(cl model.Cluster) error {
	b, err := cl.Leader(cmd.Topic, int32(cmd.Partition))
	if err != nil {
		return err
	}
	res, err := proto.Metadata(cmd.Topic).Fetch(b)
	if err != nil {
		return err
	}
	fmt.Println(toJSON(res))
	return nil
}
示例#2
0
文件: api.go 项目: h12w/kpax
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
}
示例#3
0
文件: api.go 项目: h12w/kpax
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
}
示例#4
0
文件: api.go 项目: h12w/kpax
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
}